ZyX_I avatar ZyX_I committed 89d75eb

Added urlescaping of file argument to :AuHyperlink (untested)
Moved s:hypsites to aurum/drivers/mercurial
Added support for almost all free hostings mentioned in http://mercurial.selenic.com/wiki/MercurialHosting

Comments (0)

Files changed (2)

     call FraworLoad('@/commands')
     call FraworLoad('@/functions')
     " TODO improve files completion
-    " TODO :AuSearch
+    " TODO :AuGrep
     " TODO :AuMerge ?
     " TODO :AuExplore
     " TODO aurum#changeset(), aurum#repository() and aurum#status()
     endfor
     return r
 endfunction
+"▶1 urlescape :: String → String
+function s:F.urlescape(str)
+    let r=''
+    let lstr=len(a:str)
+    let i=0
+    while i<lstr
+        let c=a:str[i]
+        if c=~#'^[^A-Za-z0-9\-_.!~*''()/]'
+            let r.=printf('%%%02X', char2nr(c))
+        else
+            let r.=c
+        endif
+        let i+=1
+    endwhile
+    return r
+endfunction
 "▶1 auefunc
 "▶2 repotuplesplit :: str, UInt → (repo, String, ...)
 function s:F.repotuplesplit(str, num)
             \substitute(s:tracfunc['@FWC'][0],
             \'\V+ type ""', '+ (path)', ''))
 "▶1 hypfunc
-" len("hgroot")=6
-" TODO Move this to mercurial driver
-let s:hypsites=[
-\['domain is? "bitbucket.org"', '"https://".domain.path."/src/".cs.hex."/".file', '"cl-".line'],
-\['domain is? "github.com"',    '"https://".domain."/".substitute(path, "\\v^\\:|\\.git$", "", "g").'.
-\                                                 '"/blob/".gitbranch."/".file',
-\                               '"L".line'],
-\['domain =~? "\\Vhg.sourceforge.net\\$"',
-\                               '"http://".domain."/hgweb".path[7:]."/file/".cs.hex."/".file',
-\                               '"l".line'],
-\['domain =~? "\\Vgooglecode.com\\$" && path[:2] is? "/hg"',
-\                               '"http://code.google.com/p/".matchstr(domain, "\\v^[^.]+").'.
-\                                                     '"/source/browse/".file."?r=".cs.hex',
-\                               'line'],
-\]
 " TODO urlescape file
-" TODO More domains support
-" TODO aurum#hyperlink ?
 function s:hypfunc.function(opts)
     let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(a:opts, 'nocurf', 0)
     call s:_r.cmdutils.checkrepo(repo)
         endif
         let rev=repo.work_hex
     endif
+    let file=s:F.urlescape(file)
     let cs=repo.functions.getcs(repo, rev)
     let url=repo.functions.getrepoprop(repo, 'url')
     let [dummystr, protocol, user, domain, port, path; dummylst]=
     if empty(domain)
         call s:_f.throw('invurl', url, repo.path)
     endif
-    let gitbranch=substitute(get(cs.bookmarks, 0, 'master'), '\m^origin/', '', '')
-    for sitedef in s:hypsites
+    let gitbranch=s:F.urlescape(substitute(get(cs.bookmarks, 0, 'master'),
+                \                          '\m^origin/', '', ''))
+    for sitedef in repo.hypsites
         if eval(sitedef[0])
             let r=eval(sitedef[1])
-            if has_key(opts, 'line')
+            if has_key(opts, 'line') && sitedef[2] isnot 0
                 if opts.line
                     let line=opts.line
                 elseif hasbuf

plugin/aurum/drivers/mercurial.vim

             \'reponwr': 'Unable to write to repository root (%s)',
             \  'nocfg': 'Failed to get property %s of repository %s ',
         \}
+"▶1 s:hypsites
+" len("hgroot")=6
+" examples: (t: only tip is shown; g: git branches only, u: unstable)
+"  https://bitbucket.org/ZyX_I/aurum / ssh://hg@bitbucket.org/ZyX_I/aurum
+"g git+ssh://git@github.com:MarcWeber/vim-addon-manager /
+"       git://github.com/MarcWeber/vim-addon-manager
+"  ssh://zyxsf@translit3.hg.sourceforge.net/hgroot/translit3/translit3 /
+"       http://translit3.hg.sourceforge.net:8000/hgroot/translit3/translit3
+"  https://vim-pyinteractive-plugin.googlecode.com/hg/
+"t svn+http://conque.googlecode.com/svn/trunk
+"? (unable to clone with hg-git) https://code.google.com/p/tortoisegit/
+"t http://anonscm.debian.org/hg/minicom/
+"  http://hg.assembla.com/CMakeLua
+"  https://zyx@zyx.codebasehq.com/test/test.hg /
+"       ssh://hg@codebasehq.com/zyx/test/test.hg
+"  https://hg01.codeplex.com/visualhg
+"  http://mercurial.intuxication.org/hg/tryton-client_ru
+"  https://mirrors.kilnhg.com/Repo/Mirrors/Hg/Mercurial
+"  http://hg.mozdev.org/maf/ / ssh://USER:PASS@hg.mozdev.org/maf
+"u https://projectkenai.com/hg/sonichg~test (rev numbers must match)
+"  http://hg.savannah.nongnu.org/hgweb/mechsys/
+"  https://sharesource.org/hg/alqua/
+"  http://mercurial.tuxfamily.org/mercurialroot/slitaz/tazlito/
+let s:hypsites=[
+\['domain is? "bitbucket.org"',  '"https://".domain.path."/src/".cs.hex."/".file', '"cl-".line'],
+\['domain is? "github.com"',     '"https://".domain."/".substitute(path, "\\v^[:/]|\\.git$", "", "g").'.
+\                      '"/blob/".gitbranch."/".file',
+\    '"L".line'],
+\['domain =~? "\\Vhg.sourceforge.net\\$"',
+\    '"http://".domain."/hgweb".path[7:]."/file/".cs.hex."/".file',
+\    '"l".line'],
+\['domain =~? "\\Vgooglecode.com\\$" && path[:2] is? "/hg"',
+\    '"http://code.google.com/p/".matchstr(domain, "\\v^[^.]+").'.
+\                          '"/source/browse/".file."?r=".cs.hex',
+\    'line'],
+\['domain =~? "\\Vgooglecode.com\\$" && path[:3] is? "/svn"',
+\    '"http://code.google.com/p/".matchstr(domain, "\\v^[^.]+").'.
+\                          '"/source/browse".path[4:]."/".file',
+\    'line'],
+\['domain is? "code.google.com"','"http://code.google.com/".substitute(path, "/$", "", "").'.
+\                          '"/source/browse/".file."?r=".gitbranch'],
+\['domain is? "anonscm.debian.org" && path[:2] is? "/hg"', '"http://".domain.path."/".file', 0],
+\['domain is? "hg.assembla.com"','"http://trac-".domain.path."/browser/".file."?rev=".cs.hex',
+\    '"L".line'],
+\['domain is? "codebasehq.com" && path[-3:] is? ".hg"',
+\    '"https://".matchstr(path, "\\v^[^/]+", 1).".".'.
+\             'domain."/projects/".matchstr(path, "\\v[^/]+(\/[^/]+$)@=").'.
+\                             '"/repositories/".matchstr(path[:-4], "\\v[^/]+$").'.
+\                             '"/blob/".cs.hex."/".file',
+\    '"L".line'],
+\['domain =~? "\\Vcodebasehq.com\\$" && path[-3:] is? ".hg"',
+\    '"https://".domain."/projects/".matchstr(path, "\\v^[^/]+", 1).'.
+\                               '"/repositories/".matchstr(path[:-4], "\\v[^/]+$").'.
+\                               '"/blob/".cs.hex."/".file',
+\    '"L".line'],
+\['domain =~? "\\V\\^hg\\d\\+.codeplex.com\\$"',
+\    '"http://".path[1:].".codeplex.com/SourceControl/changeset/view/".'.
+\                                      'cs.hex[:11].'.
+\                                      '"#".substitute(file, "/", "%2f", "g")', 0],
+\['domain =~? "\\Vkilnhg.com\\$"', '"http://".domain.path."/File/".file."?rev=".cs.hex', 'line'],
+\['domain =~? "\\Vprojectkenai.com\\$" && path[:2] is? "/hg"',
+\    '"http://projectkenai.com/projects/".matchstr(path, "\\v^[^~]+", 4).'.
+\                           '"/sources/". matchstr(path, "\\v[^~]+$")."/content/".file.'.
+\                           '"?rev=".cs.rev', 0],
+\['domain is? "mercurial.intuxication.org"',             '"http://".domain.path."/file/".cs.hex."/".file', '"l".line'],
+\['domain is? "hg.mozdev.org"',                          '"http://".domain.path."/file/".cs.hex."/".file', '"l".line'],
+\['domain =~? "\\v^hg\\.savannah\\.(non)?gnu\\.org$"',   '"http://".domain.path."/file/".cs.hex."/".file', '"l".line'],
+\['domain is? "sharesource.org" && path[:2] is? "/hg"', '"https://".domain.path."/file/".cs.hex."/".file', '"l".line'],
+\['domain is? "mercurial.tuxfamily.org"',                '"http://".domain.path."/file/".cs.hex."/".file', '"l".line'],
+\]
 "▶1 addchangesets :: repo, [cs] → _ + repo
 function s:F.addchangesets(repo, css)
     call map(copy(a:css), 'extend(a:repo.changesets, {v:val.hex : v:val})')
     catch /\V\^Frawor:\[^:]\+:norepo:/
         return 0
     endtry
+    let repo.hypsites=deepcopy(s:hypsites)
     let s:repos[a:path]=repo
     return repo
 endfunction
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.