Commits

ZyX_I committed 817118b

Added g:aurum_hypsites option
Moved gitbranch from hypfunc to @aurum/drivers/mercurial

Comments (0)

Files changed (4)

 This plugin provides a vim <--> VCS (currently only mercurial) integration for 
 your projects. Features:
 
-  - Partially committing changes ([:AuRecord](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line318-0)).
+  - Partially committing changes ([:AuRecord](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line325-0)).
 
-  - Viewing file state at particular revision ([aurum://file](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line549-0), [:AuFile](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line143-0)).
+  - Viewing file state at particular revision ([aurum://file](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line556-0), [:AuFile](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line146-0)).
 
   - Viewing uncommited changes in a vimdiff, as well as changes between 
-    specific revisions ([:AuVimDiff](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line358-0)). It is also possible to open multiple 
+    specific revisions ([:AuVimDiff](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line365-0)). It is also possible to open multiple 
     tabs with all changes to all files viewed as side-by-side diffs.
 
-  - Viewing revisions log ([:AuLog](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line219-0)). Output is highly customizable.
+  - Viewing revisions log ([:AuLog](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line226-0)). Output is highly customizable.
 
-  - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line322-0)).
+  - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line329-0)).
 
-  - Commiting changes ([:AuCommit](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line84-0)), commit messages are remembered in case of 
-    rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line794-0)).
+  - Commiting changes ([:AuCommit](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line87-0)), commit messages are remembered in case of 
+    rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line801-0)).
+
+  - Obtaining various URL’s out of remote repository URL (like URL of the HTML 
+    version of the current file with URL fragment pointing to the current line 
+    attached: useful for sharing) ([:AuHyperlink](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line177-0)).
 
   - Frontends for various VCS commands.
 
-Most commands can be reached with a set of mappings (see [aurum-mappings](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line691-0)), 
+Most commands can be reached with a set of mappings (see [aurum-mappings](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line698-0)), 
 all mappings are customizable.
 
 
   - Viewing working directory status (|:AuStatus|).
   - Commiting changes (|:AuCommit|), commit messages are remembered in case of 
     rollback (|g:aurum_remembermsg|).
+  - Obtaining various URL’s out of remote repository URL (like URL of the HTML 
+    version of the current file with URL fragment pointing to the current line 
+    attached: useful for sharing) (|:AuHyperlink|).
   - Frontends for various VCS commands.
 Most commands can be reached with a set of mappings (see |aurum-mappings|), 
 all mappings are customizable.
     rev       Revision that is to be refered. Defaults:
                   URL types                   Default ~
                   html,raw,annotate,filehist  |aurum-current-revision|
-                  bundle,changeset,log        working directory revision
+                  bundle,changeset            working directory revision
+                  log                         same as above, but mainly ignored
                   clone,push                  not applicable (not used)
               Note: Depending on specific repository this argument may be 
                     unsupported (mostly hgsubversion repositories), supported 
                 execute printf(cmd, string(URL))
 <   repo      Path. Repository that should be used.
 
+    Note: you can extend list of supported remote repositories by using 
+          |g:aurum_hypsites| option.
+
 AuJunk [forget] [ignore] [remove] [ignoreglobs] glob1 [...]          *:AuJunk*
     Forget, ignore or remove (default: remove) files matching given globs 
     (specify “:” to act on current file). With “ignoreglobs” it will ignore 
     directory if they have not changed since revision found.
     Default: 1.
 
+hypsites                                                    *g:aurum_hypsites*
+    List of pairs, just like |aurum-repo.hypsites|. Defines additional 
+    repository information in case some repository support is not/can not be 
+    added to the aurum.
+    Values of this option are checked before |aurum-repo.hypsites|.
+
 ==============================================================================
 5. Globs                                                         *aurum-globs*
 
     Additional keys “hline” and “aline” stand for URL fragments pointing to 
     the specified line (“hline” for “html”, “aline” for “annotate”) (without 
     the leading hash).
-    You should not normally use or alter this key.
+    Local variables you can use in expressions:
+        Variable   Description ~
+        repo       Repository object (|aurum-repository|).
+        cs         Changeset object (|aurum-changeset|) (url≠clone,push).
+        url        URL of remote repository from local repository 
+                   configuration.
+        protocol, user, domain, port, path
+                   Parts of the URL: {protocol}://{user}@{domain}{path}, 
+                   {path} must start with either forward slash or colon.
+        matcher    First item in the current pair.
+        dict       Second item in the current pair.
+        utype      URL type.
+        line       Line number (only inside “hline” and “aline” expressions).
+    You should not normally use or alter this key, use |g:aurum_hypsites| if 
+    you want to add support for particular remote repository.
 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 
 endif
 "▶1 Globals
 let s:_messages={
-            \ 'invurl': 'Failed to parse url %s of repository %s',
             \ 'uknurl': 'Failed to process url %s of repository %s',
             \ 'uunsup': 'Url type `%s'' is not supported for repository %s '.
             \           'linked with %s',
             \  'nrepo': 'Not a repository: %s',
             \'_mvheader': ['Source', 'Destination'],
         \}
+let s:utypes=['html', 'raw', 'annotate', 'filehist', 'bundle', 'changeset',
+            \ 'log', 'clone', 'push']
 let s:_options={
             \'workdirfiles': {'default': 1,
             \                  'filter': 'bool',},
+            \'hypsites': {'default': [],
+            \             'checker': 'list tuple ((type ""), '.
+            \                                    'dict {?in utypes     type ""'.
+            \                                          '/\v^[ah]line$/ type ""'.
+            \                                         '})'
+            \            },
         \}
 "▶1 getexsttrckdfiles
 function s:F.getexsttrckdfiles(repo)
             \'\V+ type ""', '+ (path)', ''))
 "▶1 hypfunc
 " TODO diff ?
-" TODO user hypsites
 function s:hypfunc.function(opts)
     let opts=copy(a:opts)
     let utype=get(opts, 'url', 'html')
         else
             let cs=repo.functions.getcs(repo, rev)
         endif
-        let gitbranch=s:F.urlescape(substitute(get(cs.bookmarks, 0, 'master'),
-                    \                          '\m^origin/', '', ''))
     else
         let repo=s:_r.repo.get(a:opts.repo)
         call s:_r.cmdutils.checkrepo(repo)
-        if utype is# 'bundle' || utype is# 'changeset'
+        if utype is# 'bundle' || utype is# 'changeset' || utype is# 'log'
             if has_key(a:opts, 'rev')
                 let cs=repo.functions.getwork(repo)
             else
                 let cs=repo.functions.getcs(repo, a:opts.rev)
             endif
-            let gitbranch=s:F.urlescape(substitute(get(cs.bookmarks,0,'master'),
-                        \                          '\m^origin/', '', ''))
         endif
     endif
     let url=repo.functions.getrepoprop(repo, 'url')
                 \                   '([^/:]*)'.
                 \                  '%(\:(\d+))?'.
                 \                   '(.*)$')
-    if empty(domain)
-        call s:_f.throw('invurl', url, repo.path)
-    endif
-    for [matcher, dict] in repo.hypsites
+    for [matcher, dict] in s:_f.getoption('hypsites')+repo.hypsites
         if eval(matcher)
             if !has_key(dict, utype)
                 call s:_f.throw('uunsup', utype, repo.path, url)
             let r=eval(dict[utype])
             if (utype is# 'html' || utype is# 'annotate') &&
                         \has_key(opts, 'line')
-                let lkey=utype[0].line
+                let lkey=utype[0].'line'
                 if has_key(dict, lkey)
                     if opts.line
                         let line=opts.line
             \                       ' ?file  type ""'.
             \                       ' ?line  range 0 inf'.
             \                       ' ?cmd   type ""'.
-            \                       ' ?url   in [html raw annotate filehist'.
-            \                                  ' bundle changeset log clone'.
-            \                                  ' push] '.
-            \                                  '~start'.
+            \                       ' ?url   in utypes ~start'.
             \                       '}', 'filter']
 call add(s:hypcomp,
             \substitute(substitute(substitute(s:hypfunc['@FWC'][0],

plugin/aurum/drivers/mercurial.vim

             \                  'matchstr(path, "\\v^[^/]+")',
             \                  'matchstr(path[:-4], "\\v[^/]+$")')
 unlet s:cbbase
+let s:gb  =  '((!empty(cs.bookmarks))?'.
+            \   '(cs.bookmarks[0]):'.
+            \'((!empty(cs.tags))?'.
+            \   '(get(filter(copy(cs.tags), "v:val[:7] is# ''default/''"), 0, '.
+            \        '"default/master")[8:])'.
+            \':'.
+            \   '("master")))'
 let s:hypsites=[
 \['domain is? "bitbucket.org"',
 \ {     'html': '"https://".domain.path."/src/".cs.hex."/".file',      'hline': '"cl-".line',
 \      'clone': '"https://".domain.path',
 \       'push': '"ssh://hg@".domain.path',}],
 \['domain is? "github.com"',
-\ {     'html': '"https://".domain."/".'.s:ghpath.'."/blob/".gitbranch."/".file',   'hline': '"L".line',
-\        'raw': '"https://".domain."/".'.s:ghpath.'."/raw/". gitbranch."/".file',
-\   'annotate': '"https://".domain."/".'.s:ghpath.'."/blame/". gitbranch."/".file', 'aline': '"LID".line',
-\   'filehist': '"https://".domain."/".'.s:ghpath.'."/commits/".gitbranch."/".file',
-\     'bundle': '"https://".domain."/".'.s:ghpath.'."/zipball/".gitbranch',
-\  'changeset': '"https://".domain."/".'.s:ghpath.'."/commit/".gitbranch',
+\ {     'html': '"https://".domain."/".'.s:ghpath.'."/blob/".'.s:gb.'."/".file',   'hline': '"L".line',
+\        'raw': '"https://".domain."/".'.s:ghpath.'."/raw/". '.s:gb.'."/".file',
+\   'annotate': '"https://".domain."/".'.s:ghpath.'."/blame/". '.s:gb.'."/".file', 'aline': '"LID".line',
+\   'filehist': '"https://".domain."/".'.s:ghpath.'."/commits/".'.s:gb.'."/".file',
+\     'bundle': '"https://".domain."/".'.s:ghpath.'."/zipball/".'.s:gb.'',
+\  'changeset': '"https://".domain."/".'.s:ghpath.'."/commit/".'.s:gb.'',
 \        'log': '"https://".domain."/".'.s:ghpath.'."/commits"',
 \      'clone': '"git://".domain."/".'.s:ghpath,
 \       'push': '"git+ssh://git@".domain.":".'.s:ghpath,}],
 \      'clone': '"http://".domain.":8000".path',
 \       'push': '"ssh://".user."@".domain.path',}],
 \['domain =~? "\\Vgit.sourceforge.net\\$"',
-\ {     'html': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=blob;hb=".gitbranch.";f=".file', 'hline': '"l".line',
-\        'raw': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=blob_plain;hb=".gitbranch.";f=".file',
-\   'filehist': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=history;hb=".gitbranch.";f=".file',
-\  'changeset': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=commitdiff;hb=".gitbranch',
+\ {     'html': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=blob;hb=".'.s:gb.'.";f=".file', 'hline': '"l".line',
+\        'raw': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=blob_plain;hb=".'.s:gb.'.";f=".file',
+\   'filehist': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=history;hb=".'.s:gb.'.";f=".file',
+\  'changeset': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=commitdiff;hb=".'.s:gb,
 \        'log': '"http://".domain."/git/gitweb.cgi?p=".path[9:].";a=log"',
 \      'clone': '"http://".domain.":8000".path',
 \       'push': '"ssh://".user."@".domain.path',}],
 \        'log': '"http://code.google.com/p/".'.s:gcproj.'."/source/list"',
 \      'clone': 'url',}],
 \['domain is? "code.google.com"',
-\ {     'html': '"http://code.google.com/".substitute(path, "/$", "", "")."/source/browse/".file."?r=".gitbranch',}],
+\ {     'html': '"http://code.google.com/".substitute(path, "/$", "", "")."/source/browse/".file."?r=".'.s:gb,}],
 \['domain is? "hg.assembla.com"',
 \ {     'html': '"http://trac-".domain.path."/browser/".file."?rev=".cs.hex',                'hline': '"L".line',
 \   'annotate': '"http://trac-".domain.path."/browser/".file."?annotate=blame&rev=".cs.hex', 'aline': '"L".line',
 \        'log': '"http://".domain.path."/graph"',
 \      'clone': '"http://".domain.path',}],
 \]
-unlet s:ghpath s:gcproj s:cbssh s:cbhttps s:pkbase s:cpbase
+unlet s:ghpath s:gcproj s:cbssh s:cbhttps s:pkbase s:cpbase s:gb
 "▶1 removechangesets :: repo, start_rev_num → + repo
 function s:F.removechangesets(repo, start)
     let changesets=a:repo.changesets
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.