Commits

ZyX_I committed bcb2de4 Merge

Merge

Comments (0)

Files changed (8)

 This plugin provides a vim <--> VCS (currently mercurial, git and subversion) 
 integration for your projects. Features:
 
-  - Partially committing changes ([:AuRecord](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line398-0)).
+  - Partially committing changes ([:AuRecord](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line405-0)).
 
-  - Viewing file state at particular revision ([aurum://file](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line670-0), [:AuFile](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line161-0)).
+  - Viewing file state at particular revision ([aurum://file](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line677-0), [:AuFile](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line161-0)).
 
   - Viewing uncommited changes in a vimdiff, as well as changes between 
-    specific revisions ([:AuVimDiff](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line441-0)). It is also possible to open multiple 
+    specific revisions ([:AuVimDiff](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line448-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#line253-0)). Output is highly customizable.
+  - Viewing revisions log ([:AuLog](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line260-0)). Output is highly customizable.
 
-  - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line402-0)).
+  - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line409-0)).
 
   - Commiting changes ([:AuCommit](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line102-0)), commit messages are remembered in case of 
-    rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line1036-0)).
+    rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line1049-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#line196-0)). For mercurial it also 
+    attached: useful for sharing) ([:AuHyperlink](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line203-0)). For mercurial it also 
     supports git and subversion revisions (in case you are using hg-git and 
     hgsubversion respectively).
 
-  - [aurum#changeset()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line490-0), [aurum#repository()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line486-0) and [aurum#status()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line494-0) functions 
+  - [aurum#changeset()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line497-0), [aurum#repository()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line493-0) and [aurum#status()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line501-0) functions 
     that are to be used from modeline.
 
   - Frontends for various other VCS commands.
 
-Most commands can be reached with a set of mappings (see [aurum-mappings](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line832-0)), 
+Most commands can be reached with a set of mappings (see [aurum-mappings](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line839-0)), 
 all mappings are customizable.
 
 

autoload/aurum.vim

         return [cbvar, cbvar.repo, cbvar.__relfname]
     endif
     try
-        silent let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf({'repo': ':'},
-                    \                                             0,"getsilent")
+        silent let [repo, rev, file]=s:_r.cmdutils.getrrf({'repo': ':'}, 0,
+                    \                                     'getsilent')[1:]
     catch /^Frawor:[^:]\+:nrepo:/
         return [cbvar, 0, 0]
     endtry

autoload/aurum/cmdutils.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('4.0', {'@/resources': '0.0',
+execute frawor#Setup('4.1', {'@/resources': '0.0',
             \                       '@/os': '0.0',
             \               '@%aurum/repo': '5.0',
             \               '@%aurum/edit': '1.0',
         let r.file=a:bvar.file
     else
         let r.repo=s:_r.repo.get(s:_r.os.path.dirname(a:bvar.file))
-        let r.file=r.repo.functions.reltorepo(r.repo, a:bvar.file)
+        if a:act isnot# 'getrr'
+            let r.file=r.repo.functions.reltorepo(r.repo, a:bvar.file)
+        endif
     endif
     let r.rev=0
     let r.hasbuf=1
     let  r.rev=empty(a:bvar.rev2) ? a:bvar.rev1 : a:bvar.rev2
     " XXX Maybe it should pull in all filenames instead when act='getfiles'?
     let r.file=s:r.getdifffile(a:bvar)
-    if r.file is 0 && a:failmsg isnot 0
+    if r.file is 0 && a:failmsg isnot 0 && a:act isnot# 'getrr'
         return 0
     endif
     if a:act is# 'annotate' || a:act is# 'open'
     let r.repo=a:bvar.repo
     if a:act is# 'getfiles'
         let r.files=a:bvar.files
-    elseif a:act isnot# 'getsilent'
+    elseif a:act isnot# 'getsilent' && a:act isnot# 'getrr'
         let r.file=s:r.getfile(a:bvar.files)
         if r.file is 0 && a:failmsg isnot 0
             return 0
         let r.file=a:bvar.files[line('.')-1]
         if !has_key(a:opts, 'rev')
             let r.rev=a:bvar.revisions[line('.')-1]
-            if r.rev is# r.repo.functions.getrevhex(r.repo, a:bvar.rev)
+            if r.rev is# a:bvar.rev
                 if a:act isnot# 'annotate'
                     " Don't do the following if we are not annotating
                 elseif has_key(a:bvar, 'annbuf') &&
 endfunction
 "▲2
 "▶1 getrrf :: opts, failmsg, act + buf → (hasbuf, repo, rev, file)
+" Actions: getfile   : Used to get trivial filename only. Non-last arguments 
+"                      should be ignored
+"          getfiles  : Used to get a list of files (if user specified no 
+"                      patterns), or, at least, repository (but not revision)
+"          get       : Used to get repo, revision and file. If it is not 
+"                      aurum:// buffer, revision is zero
+"          getsilent : Like get, but won’t prompt for a file in aurum://commit 
+"                      buffers
+"          getrr     : Gets repository and revision, but not file
+" TODO Move open and annotate actions out of here.
+"          open      : Prepare a window for opening file as well
+"          annotate  : Like open, except for aurum://annotate when current 
+"                      revision is the same as annotated revision. In latter 
+"                      case it just switches to annotated file (or opens a new 
+"                      one if it does not exist)
 let s:rrffailresult=[0, 0, 0, 0]
 function s:r.getrrf(opts, failmsg, act)
     let hasbuf=0
     if has_key(a:opts, 'file') && a:opts.file isnot# ':'
         if a:act isnot# 'getfile' && a:opts.repo is# ':'
             let repo=s:_r.repo.get(s:_r.os.path.dirname(a:opts.file))
-            let file=repo.functions.reltorepo(repo, a:opts.file)
+            if a:act isnot# 'getrr'
+                let file=repo.functions.reltorepo(repo, a:opts.file)
+            endif
         else
             let file=a:opts.file
         endif
         else
             let repo=s:_r.repo.get(':')
             call s:r.checkrepo(repo)
-            let file=repo.functions.reltorepo(repo, expand('%'))
+            if a:act isnot# 'getrr'
+                let file=repo.functions.reltorepo(repo, expand('%'))
+            endif
         endif
         let  rev=0
         let hasbuf=2
             if rev isnot 0
                 let rev=repo.functions.getrevhex(repo, rev)
             endif
+        elseif a:act is# 'getrr'
+            let rev=repo.functions.getworkhex(repo)
         else
             let rev=0
         endif

autoload/aurum/file.vim

 "▶1 
 scriptencoding utf-8
-execute frawor#Setup('0.0', {'@%aurum/cmdutils': '4.0',
+execute frawor#Setup('0.1', {'@%aurum/cmdutils': '4.1',
             \                '@%aurum/maputils': '0.0',
             \                 '@%aurum/bufvars': '0.0',
             \               '@%aurum/lineutils': '0.0',
             \'wfail': 'Writing to %s failed',
             \'dfail': 'Failed to delete %s',
         \}
+"▶1 callbacks
+let s:F.callbacks={}
+"▶2 callbacks.open
+function s:F.callbacks.open(file, repo, rev, cmd, hasbuf)
+    if a:hasbuf
+        let filetype=&filetype
+    endif
+    let oldlastbuf=bufnr('$')
+    let existed=s:_r.run(a:cmd, 'file', a:repo, a:rev, a:file)
+    if exists('filetype') && &filetype isnot# filetype
+        let &filetype=filetype
+    endif
+    let buf=bufnr('%')
+    if !existed && buf>oldlastbuf
+        setlocal bufhidden=wipe
+    endif
+    call s:_f.mapgroup.map('AuFile', buf)
+endfunction
+"▶2 callbacks.replace
+function s:F.callbacks.replace(file, repo, rev, cmd, hasbuf)
+    let winview=winsaveview()
+    silent %delete _
+    call s:_r.lineutils.setlines(a:repo.functions.readfile(a:repo,a:rev,a:file),
+                \                0)
+    call winrestview(winview)
+endfunction
 "▶1 AuFile
 function s:cmd.function(rev, file, opts)
     let opts=copy(a:opts)
     if a:rev isnot 0 && a:rev isnot ':'
         let opts.rev=a:rev
     endif
-    if a:file isnot 0 && a:file isnot# ':'
+    let prompt=get(a:opts, 'prompt', 0)
+    if !prompt && a:file isnot 0 && a:file isnot# ':'
         let opts.file=a:file
     endif
-    let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(opts, 'noffile', 'open')
+    let action=((prompt)?('getrr'):('open'))
+    let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(opts, 'noffile', action)
     if repo is 0
         return
     endif
         let rev=repo.functions.getrevhex(repo, a:rev)
     endif
     if get(a:opts, 'replace', 0)
-        let winview=winsaveview()
-        silent %delete _
-        call s:_r.lineutils.setlines(repo.functions.readfile(repo, rev, file),0)
-        call winrestview(winview)
-        return
+        let cbargs=[s:F.callbacks.replace]
+    else
+        let cbargs=[s:F.callbacks.open]
     endif
-    if hasbuf
-        let filetype=&filetype
+    let cbargs+=[repo, rev, get(a:opts, 'cmd', 'silent edit'), hasbuf]
+    let pvargs=[s:_r.maputils.readfilewrapper, repo, rev]
+    if prompt
+        let files=repo.functions.getcsprop(repo, rev, 'allfiles')
+        if a:file isnot# ':'
+            let pattern=s:_r.globtopat(a:file)
+            let files=filter(copy(files), 'v:val =~# pattern')
+        endif
+        return s:_r.maputils.promptuser(files, cbargs, pvargs)
+    else
+        call call(cbargs[0], [file]+cbargs[1:], {})
     endif
-    call s:_r.run(get(a:opts, 'cmd', 'silent edit'), 'file', repo, rev, file)
-    if exists('filetype') && &filetype isnot# filetype
-        let &filetype=filetype
-    endif
-    if !has_key(a:opts, 'cmd')
-        setlocal bufhidden=wipe
-    endif
-    call s:_f.mapgroup.map('AuFile', bufnr('%'))
 endfunction
 "▶1 docmd :: [String], read::0|1|2 → _ + ?
 function s:F.docmd(lines, read)

autoload/aurum/hyperlink.vim

     "▶3 File needed: html, annotate, raw, filehist
     if utype is# 'html' || utype is# 'annotate' || utype is# 'raw'
                 \       || utype is# 'filehist'
-        let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(a:opts, 'nocurf',
-                    \                                      'get')
+        let [repo, rev, file]=s:_r.cmdutils.getrrf(a:opts, 'nocurf', 'get')[1:]
         call s:_r.cmdutils.checkrepo(repo)
         let file=s:F.urlescape(file)
         if rev is 0

autoload/aurum/vimdiff.vim

 function s:cmd.function(opts, ...)
     "▶2 repo and revisions
     let full=get(a:opts, 'full', 0)
-    let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(a:opts, 0,
-                \                                      ((full)?('getfiles'):
-                \                                              ('open')))
+    let action=((full)?('getfiles'):('open'))
+    let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(a:opts, 0, action)
     call s:_r.cmdutils.checkrepo(repo)
     let revs=[]
     if rev isnot 0
         endif
     endif
     "▲2
-    if get(a:opts, 'full', 0)
+    if full
         let args=[repo, revs,
                     \((get(a:opts, 'untracked', 0))?
                     \   (2):
     [no]dates     Flag. Determines whether dates should be shown in headers.
     [no]git       Flag. Determines whether extended git format should be used.
 
-AuFile [{rev} [{file}]] [[no]replace] [cmd {cmd}] [repo {repo}]      *:AuFile*
+                                                                     *:AuFile*
+AuFile [{rev} [{file}]] [[no]replace] [[no]prompt] [cmd {cmd}] [repo {repo}]
     View file as it was at given revision. If “replace” option is given, then 
     current buffer contents will be replaced instead of opening new 
     |aurum://file| buffer. “cmd” option determines which command will be used 
     to open aurum://file buffer (default: “silent edit”) (may be overriden by 
     “replace” option).
+    If you need to skip to keyword arguments use “:” in place of file and 
+    revision: in this case these arguments are considered to be absent.
+    If “prompt” option is given then {file} is treated as a glob and prompt is 
+    used to get what file should be actually opened.
+    Note: You may use “{pat1,pat2}” to merge multiple globs into one and “:” 
+          as an equivalent for “all files” or “**”. Also see |aurum-globs|.
 
 AuGrep {pattern} {opts}                                              *:AuGrep*
     Populates |quickfix| list with the results of searching repository for 
                       *g:frawormap_Aurum_URL*    *g:frawormap_Aurum_LineURL*
                       *g:frawormap_Aurum_Track*  *g:frawormap_Aurum_Forget*
                       *g:frawormap_Aurum_Push*   *g:frawormap_Aurum_Pull*
-                      *g:frawormap_Aurum_FVdiff*     *aurum-m-Aurum-FVdiff*
+                      *g:frawormap_Aurum_FVdiff* *g:frawormap_Aurum_OpenAny*
+                          *aurum-m-Aurum-FVdiff*     *aurum-m-Aurum-OpenAny*
                           *aurum-m-Aurum_Commit*     *aurum-m-Aurum_CommitAll*
                           *aurum-m-Aurum_Open*       *aurum-m-Aurum_Revert*
                           *aurum-m-Aurum_Vdiff*      *aurum-m-Aurum_Diff*
 CommitAll   I   AuCommit ** Commit changes to all files
 Open        o   AuFile      View contents of the current file as it was at the 
                             the working directory revision
-Revert      O   AuFile . : replace
+OpenAny     O   AuFile : : prompt
+                            Prompt for the file and view its contents as it 
+                            was at the working directory revision.
+Revert     go   AuFile : : replace
                             Replace current buffer with contents of the 
                             current file as it was at the working directory 
                             revision
 leader, for non-readonly buffers or for global scope (|:AuVimDiff| ones) have 
 “<leader>” as their prefix by default.
 
-               ┌ aurumannotate filetype (aurum://annotate)  ~
-               │┌ aurumcommit filetype (aurum://commit; with leader) ~
-               ││┌ AuDiff command, mappings (aurum://diff) ~
-               │││┌ AuFile command, mappings (aurum://file) ~
-               ││││┌ aurumlog filetype (aurum://log) ~
-               │││││┌ aurumstatus filetype (aurum://status) ~
-               ││││││┌ :AuVimDiff command (with leader) ~
-               │││││││┌ :AuRecord mappings ~
-               ││││││││┌ global mappings (with leader) ~
-               │││││││││ ~
-Name      Key  │││││││││  Description ~
-Enter     <CR> a   ls     Does some default action
-File      gF       l      Shows file history
-User      gu       l      Shows revisions committed by current user
-Date      gM       l      Shows revisions committed in the current month
-Branch    gb       l      Shows revisions that have the same branch
-Rev       gr       l      Shows revisions that are descendants of the current
-FVdiff    gD   a D lS  g  Shows full vimdiff between current revision and WD
-                          (status and diff: between two current revisions)
-RFVdiff   gC   a   ls     Shows changes done in current rev as full vimdiff
-Vdiff      D   a Df S  g  Shows vimdiff between cur. rev. and WD for cur. file
-                          (status and diff: between two current revisions)
-RVdiff     C   a  f s     Shows changes to cur. file in cur. rev. as a vimdiff
-Fdiff     gd   a   lS  g  Shows diff between current revision and working dir
-                          (status: between two current revisions)
-RFdiff    gc   a   ls     Shows changes introduced by current revision
-Diff       d   a  flS  g  Shows diff between rev and WD for current file
-                          (status: between two current revisions)
-Rdiff      c   a  fls     Shows changes done in current rev to current file
-Prev/Next J/K  acdfl      Go to previous/next revision
-Open       o   a d ls  g  Opens current file as it was at current revision
-Annotate   a   a   ls  g  Annotates current file at current revision
-Update     U   a dfl      Update working directory to current revision
-Commit     i    c   s Rg  Commit changes made to current file
-                          (record: record all selected changes)
-CommitAll  I           g  Commit changes made to all files
-Track      A        s Rg  Make current file tracked by VCS
-                          (record: mark it for committing)
-Forget     R        s Rg  Make VCS forget current file
-                          (record: don’t commit changes to this file)
-Exit       X   acdflsvr   Close current buffer (tabpage, tabpage list)
+                ┌ aurumannotate filetype (aurum://annotate)  ~
+                │┌ aurumcommit filetype (aurum://commit; with leader) ~
+                ││┌ AuDiff command, mappings (aurum://diff) ~
+                │││┌ AuFile command, mappings (aurum://file) ~
+                ││││┌ aurumlog filetype (aurum://log) ~
+                │││││┌ aurumstatus filetype (aurum://status) ~
+                ││││││┌ :AuVimDiff command (with leader) ~
+                │││││││┌ :AuRecord mappings ~
+                ││││││││┌ global mappings (with leader) ~
+                │││││││││ ~
+Name       Key  │││││││││  Description ~
+Enter      <CR> a   ls     Does some default action
+File       gF       l      Shows file history
+User       gu       l      Shows revisions committed by current user
+Date       gM       l      Shows revisions committed in the current month
+Branch     gb       l      Shows revisions that have the same branch
+Rev        gr       l      Shows revisions that are descendants of the current
+FVdiff     gD   a D lS  g  Shows full vimdiff between current revision and WD
+                           (status and diff: between two current revisions)
+RFVdiff    gC   a   ls     Shows changes done in current rev as full vimdiff
+Vdiff       D   a Df S  g  Shows vimdiff between cur. rev. and WD for file
+                           (status and diff: between two current revisions)
+RVdiff      C   a  f s     Shows changes to file in cur. rev. as a vimdiff
+Fdiff      gd   a   lS  g  Shows diff between current revision and working dir
+                           (status: between two current revisions)
+RFdiff     gc   a   ls     Shows changes introduced by current revision
+Diff        d   a  flS  g  Shows diff between rev and WD for current file
+                           (status: between two current revisions)
+Rdiff       c   a  fls     Shows changes done in current rev to current file
+Prev/Next  J/K  acdfl      Go to previous/next revision
+Open        o   a d ls  g  Opens current file as it was at current revision
+OpenAny     O       l   g  Prompts user and opens one of the changeset files
+Annotate    a   a   ls  g  Annotates current file at current revision
+AnnotateAny         l      Prompts user and annotates one of changeset files
+Update      U   a dfl      Update working directory to current revision
+Commit      i    c   s Rg  Commit changes made to current file
+                           (record: record all selected changes)
+CommitAll   I           g  Commit changes made to all files
+Track       A        s Rg  Make current file tracked by VCS
+                           (record: mark it for committing)
+Forget      R        s Rg  Make VCS forget current file
+                           (record: don’t commit changes to this file)
+Exit        X   acdflsvr   Close current buffer (tabpage, tabpage list)
 
 There are some more uncommon global and AuRecord mappings not mentioned above.
 
     3.0: Removed _r.cmdutils.nogetrepoarg.
     3.1: Added _r.cmdutils.update (moved from @aurum/repo).
     4.0: Moved _r.cmdutils.update to @%aurum/maputils
+    4.1: Made _r.cmdutils.getrrf recognize “getrr” action
 @%aurum:
     0.1: Added |aurum#branch()| function.
 @aurum/cache:
     1.0: Made _r.utils.getcmd return a list,
          replaced _r.utils.kwargstostr with _r.utils.kwargstolst,
          made _r.utils.run return a pair (output, exit_code)
+@%aurum/file:
+    0.1: Added |:AuFile| prompt option.
 
 vim: ft=help:tw=78
             \                      '[:=(0)   either (match /\L/, path fr)]]'.
             \                      '{  repo '.s:nogetrepoarg.
             \                      ' !?replace'.
+            \                      ' !?prompt'.
             \                      '  ?cmd    '.s:cmdarg.
             \                      '}',
             \              'subs': [['\V:=(0)\s\+either (\[^)]\+)', 'path', ''],
             \'Commit':    {'lhs':  'i', 'rhs': ':<C-u>AuCommit<CR>'               },
             \'CommitAll': {'lhs':  'I', 'rhs': ':<C-u>AuCommit all<CR>'           },
             \'Open':      {'lhs':  'o', 'rhs': ':<C-u>AuFile<CR>'                 },
-            \'Revert':    {'lhs':  'O', 'rhs': ':<C-u>AuFile . : replace<CR>'     },
+            \'OpenAny':   {'lhs':  'O', 'rhs': ':<C-u>AuFile : : prompt<CR>'      },
+            \'Revert':    {'lhs': 'go', 'rhs': ':<C-u>AuFile : : replace<CR>'     },
             \'Vdiff':     {'lhs':  'D', 'rhs': ':<C-u>AuVimDiff<CR>'              },
             \'FVdiff':    {'lhs': 'gD', 'rhs': ':<C-u>AuVimDiff full<CR>'         },
             \'Diff':      {'lhs':  'd', 'rhs': ':<C-u>AuDiff :<CR>'               },