ZyX_I avatar ZyX_I committed db7ee17

@aurum/status: Added :AuStatus changes option

Comments (0)

Files changed (4)

             state and current working directory was revision from repository.
     wdrev   Revision. If given :AuStatus will display status as if {wdrev} was 
             working directory state.
+    changes Revision. Works like specifying {changes} as “rev” option and its 
+            first parent as “wdrev” option. Overrides “rev” and “wdrev” 
+            options.
     show    Either one of modified/added/removed/deleted/unknown/ignored/clean 
             or string containing capitalized first letters of mentined status 
             names (additionally “?” for unknown and “!” for deleted). May be 

plugin/aurum/status.vim

 "▶1 
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('1.0', {'@/resources': '0.0',
+    execute frawor#Setup('1.1', {'@/resources': '0.0',
                 \            '@aurum/cmdutils': '0.0',
                 \                      '@/fwc': '0.2',
                 \                '@aurum/repo': '2.0',
         let repo=s:_r.repo.get(a:repopath)
     endif
     call s:_r.cmdutils.checkrepo(repo)
-    let opts=[]
-    if has_key(a:opts, 'files')
-        call map(a:opts.files, 'repo.functions.reltorepo(repo, v:val)')
+    let opts=copy(a:opts)
+    if has_key(opts, 'changes')
+        let cs=repo.functions.getcs(repo, opts.changes)
+        let opts.rev=cs.hex
+        if empty(cs.parents)
+            return
+        endif
+        let opts.wdrev=cs.parents[0]
     endif
-    if has_key(a:opts, 'cmd')
-        call s:_r.run(a:opts.cmd, 'status', repo, a:opts)
+    if has_key(opts, 'files')
+        call map(opts.files, 'repo.functions.reltorepo(repo, v:val)')
+    endif
+    if has_key(opts, 'cmd')
+        call s:_r.run(opts.cmd, 'status', repo, opts)
     elseif s:_f.getoption('usestatwin') &&
                 \!empty(filter(tabpagebuflist(),
                 \              'bufname(v:val)=~#''\v^aurum:(.)\1status'''))
-        let statf=s:_r.fname('status', repo, a:opts)
+        let statf=s:_r.fname('status', repo, opts)
         if bufexists(statf) && bufwinnr(statf)!=-1
             execute bufwinnr(statf).'wincmd w'
             silent edit
         else
-            call s:_r.run(s:defcmd, 'status', repo, a:opts)
+            call s:_r.run(s:defcmd, 'status', repo, opts)
         endif
     else
-        call s:_r.run(s:defcmd, 'status', repo, a:opts)
+        call s:_r.run(s:defcmd, 'status', repo, opts)
     endif
-    if !has_key(a:opts, 'cmd')
+    if !has_key(opts, 'cmd')
         let lnum=line('$')
         if winnr('$')>1 && ((winheight(0)>lnum) ||
                     \       (winheight(0)!=lnum && lnum<(&lines/3)))
             \           '{ *?files     (type "")'.
             \           '   ?rev       (type "")'.
             \           '   ?wdrev     (type "")'.
+            \           '   ?changes   (type "")'.
             \           '  *?show      (either (in [modified added removed '.
             \                                      'deleted unknown ignored '.
             \                                      'clean all] ~start, '.
             \           '}', 'filter']
 call add(s:statcomp,
             \substitute(substitute(substitute(substitute(s:statfunc['@FWC'][0],
-            \'\V|*_r.repo.get',             '',                    ''),
-            \'\vfiles\s+\([^)]*\)',       'files path',            ''),
-            \'\Vcmd\s\+(type "")',        'cmd '.  s:_r.comp.cmd,  ''),
-            \'\vrev([12])\s+\V(type "")', 'rev\1 '.s:_r.comp.rev,  'g'))
+            \'\V|*_r.repo.get',                     '',                   ''),
+            \'\vfiles\s+\([^)]*\)',                 'files path',         ''),
+            \'\Vcmd\s\+(type "")',                  'cmd '.s:_r.comp.cmd, ''),
+            \'\v(%(wd)?rev|changes)\s+\V(type "")', '\1 '.s:_r.comp.rev,  'g'))
 "▶1 aurum://status
 call s:_f.newcommand({
             \'function': s:F.setup,
 :W{{{1 rev wdrev
 :Run AuStatus rev 1 wdrev 2
 :bwipeout!
+:W{{{1 changes
+:Run AuStatus changes 2
+:bwipeout!
 :W{{{1 show
 :W{{{2 show all
 :Run AuStatus show all
 R hglines2.lst
 {{{1 rev wdrev
 M crepo.zsh
+{{{1 changes
+M crepo.zsh
 {{{1 show
 {{{2 show all
 A addeddef
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.