Commits

ZyX_I committed 4bf4f79

Added :AuHyperlink url option: support for url types other then file url

Comments (0)

Files changed (3)

                    process all changesets in order to find out files matching 
                    pattern(s) given in `files' option.
 
-                                                                *:AuHyperlink*
-AuHyperlink [rev {rev}] [file {file}] [line {line}] [cmd {cmd}] [repo {repo}]
-    Construct a URL that refers to revision {rev} of a file {file} (default: 
-    see |:AuAnnotate|). If `line' is given, then url fragment pointing to 
-    given line will be added to constructed URL (use line=0 to refer to 
-    current line). {cmd} determines what should be done with constructed URL: 
-    by default it is copied to clipboard (cmd=`let @+=%s'). It is run using >
-        execute printf(cmd, string(URL))
+AuHyperlink {opts}                                              *:AuHyperlink*
+    Constructs a URL and puts it into system clipboard (see |quote+|).
+    Possible options:
+    Option    Description ~
+    rev       Revision that is to be refered.
+              Default: see |:AuAnnotate| (for url=file and url=raw),
+                       tip (for url=bundle),
+                       not applicable (for url=clone, url=push and url=cslog).
+    file      File that is to be refered (only for url=file or raw)
+              Default: see |:AuAnnotate|.
+    url       URL type. Accepted types (default: file):
+                  Type    Description ~
+                  file    URL of the file, HTML formatted
+                  raw     URL of the file, raw bundle
+                  clone   URL of the repository, read-only
+                  push    URL of the repository, read-write
+                  bundle  URL of the repository snapshot
+                  log     URL of the commit log
+    line      Determines whether URL fragment refering to given line should be 
+              added to the URL. Only for url=file.
+              Default: not added. If given line is 0 then current line number 
+              will be used unless `rev' or `file' options are given or refered 
+              file is not the current one.
+    cmd       Command that is used to copy url to register.
+              Default: "let @+=%s". Do not forget to escape spaces.
+              Value of this option is used in this fashion: >
+                execute printf(cmd, string(URL))
+<   repo      Path. Repository that should be used.
 
 AuJunk [forget] [ignore] [remove] [ignoreglobs] glob1 [...]          *:AuJunk*
     Forget, ignore or remove (default: remove) files matching given globs 
     Note that aurum is really useless for working with remote repositories.
 path :: path                                                 *aurum-repo.path*
     String which was passed to |aurum-rf-repo| function.
-hypsites :: [(expr, expr, expr | 0)]                     *aurum-repo.hypsites*
-    List of typles that determines how string returned by 
+hypsites :: [(expr, dict)]                               *aurum-repo.hypsites*
+    List of pairs that determines how string returned by 
     |aurum-rf-getrepoprop| with (repo, "url") as arguments should be 
     transformed into a URL by |:AuHyperlink| command. First expression is 
-    `matcher': if it evaluates to true, then following expressions will be 
-    used: second to construct a URL, third to construct a URL fragment (if it 
-    is 0, then no URL fragments will be added even if requested). You should 
-    not normally use or alter this key.
+    `matcher': if it evaluates to true, then expressions from the following 
+    dictionary will be used: dict.file, dict.line, dict.raw, dict.bundle, 
+    dict.clone, dict.push, dict.log. Unsupported URL types should not be 
+    represented by dictionary key. Key `line' stands for URL fragment pointing 
+    to the specified line (without the leading hash).
+    You should not normally use or alter this key.
 functions :: {String : FRef}                            *aurum-repo.functions*
     Dictionary that contains all driver-specific functions. All functions 
     except |aurum-rf-repo| accept repository object as its first argument, so 
             \'nocread': 'Cannot read aurum://commit',
             \ 'invurl': 'Failed to parse url %s of repository %s',
             \ 'unkurl': 'Failed to process url %s of repository %s',
+            \ 'uunsup': 'Url type `%s'' is not supported for repository %s '.
+            \           'linked with %s',
             \'nofiles': 'No files were specified',
             \   'nogf': 'No files found',
             \  'nrepo': 'Not a repository: %s',
             \substitute(s:tracfunc['@FWC'][0],
             \'\V+ type ""', '+ (path)', ''))
 "▶1 hypfunc
-" TODO bundle, raw urls ?
-" TODO clone url
 function s:hypfunc.function(opts)
-    let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(a:opts, 'nocurf', 0)
-    call s:_r.cmdutils.checkrepo(repo)
     let opts=copy(a:opts)
-    if rev is 0
-        if has_key(opts, 'line') &&
-                    \index(repo.functions.status(repo).clean, file)==-1
-            call remove(opts, 'line')
+    let utype=get(opts, 'url', 'file')
+    if utype is# 'file' || utype is# 'raw'
+        let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(a:opts, 'nocurf', 0)
+        call s:_r.cmdutils.checkrepo(repo)
+        let file=s:F.urlescape(file)
+        if rev is 0
+            if has_key(opts, 'line') &&
+                        \index(repo.functions.status(repo).clean, file)==-1
+                call remove(opts, 'line')
+            endif
+            let rev=repo.work_hex
         endif
-        let rev=repo.work_hex
+        let cs=repo.functions.getcs(repo, rev)
+    else
+        let repo=s:_r.repo.get(a:opts.repo)
+        call s:_r.cmdutils.checkrepo(repo)
+        if utype is# 'bundle'
+            let rev=get(a:opts, 'rev', 'tip')
+            let cs=repo.functions.getcs(repo, rev)
+            let gitbranch=s:F.urlescape(substitute(get(cs.bookmarks,0,'master'),
+                        \                          '\m^origin/', '', ''))
+        endif
     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]=
                 \matchlist(url, '\v^%(([^:]+)\:\/\/)?'.
     if empty(domain)
         call s:_f.throw('invurl', url, repo.path)
     endif
-    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') && sitedef[2] isnot 0
-                if opts.line
-                    let line=opts.line
-                elseif hasbuf
-                    let line=line('.')
+    for [matcher, dict] in repo.hypsites
+        if eval(matcher)
+            if !has_key(dict, utype)
+                call s:_f.throw('uunsup', utype, repo.path, url)
+            endif
+            let r=eval(dict[utype])
+            if utype is# 'file' && has_key(opts, 'line')
+                if has_key(dict, 'line')
+                    if opts.line
+                        let line=opts.line
+                    elseif hasbuf
+                        let line=line('.')
+                    endif
+                    if exists('line')
+                        let r.='#'.eval(dict.line)
+                    endif
+                else
+                    call s:_f.warn('uunsup', 'line', repo.path, url)
                 endif
             endif
-            if exists('line')
-                let r.='#'.eval(sitedef[2])
-            endif
             let cmd=get(opts, 'cmd', 'let @+=%s')
             execute printf(cmd, string(r))
             return
             \                       ' ?file  type ""'.
             \                       ' ?line  range 0 inf'.
             \                       ' ?cmd   type ""'.
+            \                       ' ?url   in [file raw clone push bundle '.
+            \                                   'log] '.
+            \                                  '~start'.
             \                       '}', 'filter']
 call add(s:hypcomp,
             \substitute(substitute(substitute(s:hypfunc['@FWC'][0],

plugin/aurum/drivers/mercurial.vim

 "       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
+"g git://vimpluginloader.git.sourceforge.net/gitroot/vimpluginloader/vam-test-repository
+"       / git+ssh://zyxsf@vimpluginloader.git.sourceforge.net/gitroot/vimpluginloader/vam-test-repository
 "  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/
 "  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 is? "bitbucket.org"',
+\ {  'file': '"https://".domain.path."/src/".cs.hex."/".file',
+\     'raw': '"https://".domain.path."/raw/".cs.hex."/".file',
+\  'bundle': '"https://".domain.path."/get/".cs.hex.".tar.bz2"',
+\     'log': '"https://".domain.path."/changesets"',
+\    'line': '"cl-".line',
+\   'clone': '"https://".domain.path',
+\    'push': '"ssh://hg@".domain.path',}],
+\['domain is? "github.com"',
+\ {  'file': '"https://".domain."/".substitute(path, "\\v^[:/]|\\.git$", "", "g")."/blob/".gitbranch."/".file',
+\     'raw': '"https://".domain."/".substitute(path, "\\v^[:/]|\\.git$", "", "g")."/raw/". gitbranch."/".file',
+\     'log': '"https://".domain."/".substitute(path, "\\v^[:/]|\\.git$", "", "g")."/commits"',
+\    'line': '"L".line',
+\   'clone': '"git://".domain."/".substitute(path, "\\v^[:/]|\\.git$", "", "g")',
+\    'push': '"git+ssh://git@".domain.":".substitute(path, "\\v^[:/]|\\.git$", "", "g")',}],
 \['domain =~? "\\Vhg.sourceforge.net\\$"',
-\    '"http://".domain."/hgweb".path[7:]."/file/".cs.hex."/".file',
-\    '"l".line'],
+\ {  'file': '"http://".domain."/hgweb".path[7:]."/file/".cs.hex."/".file',
+\     'raw': '"http://".domain."/hgweb".path[7:]."/raw-file/".cs.hex."/".file',
+\     'log': '"http://".domain."/hgweb".path[7:]."/log"',
+\    'line': '"l".line',
+\   'clone': '"http://".domain.":8000".path',
+\    'push': '"ssh://".user."@".domain.path',}],
+\['domain =~? "\\Vgit.sourceforge.net\\$"',
+\ {  'file': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=blob;hb=HEAD;f=".file',
+\     'raw': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=blob_plain;hb=HEAD;f=".file',
+\     'log': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=log"',
+\    'line': '"l".line',
+\   'clone': '"http://".domain.":8000".path',
+\    'push': '"ssh://".user."@".domain.path',}],
 \['domain =~? "\\Vgooglecode.com\\$" && path[:2] is? "/hg"',
-\    '"http://code.google.com/p/".matchstr(domain, "\\v^[^.]+").'.
-\                          '"/source/browse/".file."?r=".cs.hex',
-\    'line'],
+\ {  'file': '"http://code.google.com/p/".matchstr(domain, "\\v^[^.]+")."/source/browse/".file."?r=".cs.hex',
+\     'log': '"http://code.google.com/p/".matchstr(domain, "\\v^[^.]+")."/source/list"',
+\     'raw': '"http://".domain."/hg-history/".cs.hex."/".file',
+\    'line': 'line',
+\   'clone': 'url',
+\    'push': 'url',}],
 \['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'],
+\ {  'file': '"http://code.google.com/p/".matchstr(domain, "\\v^[^.]+")."/source/browse".path[4:]."/".file',
+\     'log': '"http://code.google.com/p/".matchstr(domain, "\\v^[^.]+")."/source/list"',
+\    'line': 'line',
+\   'clone': '"http://".domain."/svn/trunk"',}],
+\['domain is? "code.google.com"',
+\ {  'file': '"http://code.google.com/".substitute(path, "/$", "", "")."/source/browse/".file."?r=".gitbranch',}],
+\['domain is? "anonscm.debian.org" && path[:2] is? "/hg"',
+\ {  'file': '"http://".domain.path."/".file'}],
+\['domain is? "hg.assembla.com"',
+\ {  'file': '"http://trac-".domain.path."/browser/".file."?rev=".cs.hex',
+\    'line': '"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'],
+\ {  'file': '"https://".matchstr(path, "\\v^[^/]+", 1).".".'.
+\                     'domain."/projects/".matchstr(path, "\\v[^/]+(\/[^/]+$)@=").'.
+\                                     '"/repositories/".matchstr(path[:-4], "\\v[^/]+$").'.
+\                                     '"/blob/".cs.hex."/".file',
+\    'line': '"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'],
+\ {  'file': '"https://".domain."/projects/".matchstr(path, "\\v^[^/]+", 1).'.
+\                                       '"/repositories/".matchstr(path[:-4], "\\v[^/]+$").'.
+\                                       '"/blob/".cs.hex."/".file',
+\    'line': '"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'],
+\ {  'file': '"http://".path[1:].".codeplex.com/SourceControl/changeset/view/".'.
+\                                              'cs.hex[:11].'.
+\                                              '"#".substitute(file, "/", "%2f", "g")'}],
+\['domain =~? "\\Vkilnhg.com\\$"',
+\ {  'file': '"http://".domain.path."/File/".file."?rev=".cs.hex',
+\    'line': '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'],
+\ {  'file': '"http://projectkenai.com/projects/".matchstr(path, "\\v^[^~]+", 4).'.
+\                                   '"/sources/". matchstr(path, "\\v[^~]+$")."/content/".file.'.
+\                                 '"?rev=".cs.rev',}],
+\['domain is? "mercurial.intuxication.org"',
+\ {  'file': '"http://".domain.path."/file/".cs.hex."/".file',  'line': '"l".line'}],
+\['domain is? "hg.mozdev.org"',
+\ {  'file': '"http://".domain.path."/file/".cs.hex."/".file',  'line': '"l".line'}],
+\['domain =~? "\\v^hg\\.savannah\\.(non)?gnu\\.org$"',
+\ {  'file': '"http://".domain.path."/file/".cs.hex."/".file',  'line': '"l".line'}],
+\['domain is? "sharesource.org" && path[:2] is? "/hg"',
+\ {  'file': '"https://".domain.path."/file/".cs.hex."/".file', 'line': '"l".line'}],
+\['domain is? "mercurial.tuxfamily.org"',
+\ {  'file': '"http://".domain.path."/file/".cs.hex."/".file',  'line': '"l".line'}],
 \]
 "▶1 removechangesets :: repo, start_rev_num → + repo
 function s:F.removechangesets(repo, start)
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.