Commits

ZyX_I committed 4b3af04

@aurum/log: Added processing user input while generating log
(controlled via “procinput” option)
Fixed block column numbers for special items in a git grapher (untested)

  • Participants
  • Parent commits 8ee05f2
  • Branches incrementallog

Comments (0)

Files changed (6)

File README.markdown

 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#line353-0)).
+  - Partially committing changes ([:AuRecord](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line357-0)).
 
-  - Viewing file state at particular revision ([aurum://file](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line584-0), [:AuFile](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line158-0)).
+  - Viewing file state at particular revision ([aurum://file](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line588-0), [:AuFile](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line158-0)).
 
   - Viewing uncommited changes in a vimdiff, as well as changes between 
-    specific revisions ([:AuVimDiff](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line393-0)). It is also possible to open multiple 
+    specific revisions ([:AuVimDiff](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line397-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#line239-0)). Output is highly customizable.
 
-  - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line357-0)).
+  - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line361-0)).
 
   - Commiting changes ([:AuCommit](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line99-0)), commit messages are remembered in case of 
-    rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line829-0)).
+    rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line843-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#line189-0)).
 
-  - [aurum#changeset()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line441-0), [aurum#repository()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line437-0) and [aurum#status()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line445-0) functions 
+  - [aurum#changeset()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line445-0), [aurum#repository()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line441-0) and [aurum#status()](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line449-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#line726-0)), 
+Most commands can be reached with a set of mappings (see [aurum-mappings](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line730-0)), 
 all mappings are customizable.
 
 

File doc/aurum.txt

                 Flag. Determines whether copies should be shown.
     [no]showrenames
                 Flag. Determines whether renames should be shown.
+    [no]procinput
+                Flag. Overrides |g:aurum_procinput|: determines whether user 
+                input will be processed while generating log.
+                Note If enabled, acts like g:aurum_procinput=2.
 
                                                                      *:AuMove*
 AuMove [copy] [rightrepl] [leftpattern] [pretend] [repo {repo}] [args ...]
 closewindow                                              *g:aurum_closewindow*
     Bool. Determines whether log window should be closed when executing 
     mappings (except mappings that add a filter and exit mapping).
-    Default:
+    Default: 1.
+
+procinput                                                  *g:aurum_procinput*
+    0, 1 or 2. If not zero, consumes and passes user input to |:normal| while 
+    generating a log thus allowing you to navigate it while it is being 
+    created. Value 1 will make logger additionally check whether there were 
+    some characters in input buffer before creation of log started. If there 
+    were characters, then processing user input will be disabled (because in 
+    other case it will possibly break mappings that do not expect such 
+    behavior from |:AuLog|).
+    Default value: 1.
 
 recheight                                                  *g:aurum_recheight*
     VimL |expression| that evaluates to unsigned integer or unsigned integer. 
     0.1: Added |aurum-style-git| and |aurum-style-gitoneline| log styles, 
          added skipping of $rev if |aurum-repo.hasrevisions| is false, made it 
          separate graph from content using non-breaking spaces
+    0.2: Added |:AuLog| procinput option
 
 vim: ft=help:tw=78

File plugin/aurum/log.vim

 "▶1
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.1', {'@/table': '0.1',
+    execute frawor#Setup('0.2', {'@/table': '0.1',
                 \        '@aurum/cmdutils': '0.0',
                 \         '@aurum/bufvars': '0.0',
                 \            '@aurum/edit': '1.0',
             \'ignorefiles': {'default': [],
             \                'checker': 'list in [patch renames copies files]'},
             \'closewindow': {'default': 1, 'filter': 'bool'},
+            \'procinput':   {'default': 1, 'checker': 'range 0 2'},
         \}
 let s:_messages={
             \'2multl': 'Two multiline statements on one line',
             \'argmis': 'Missing argument #%u for keyword %s',
+            \  'ebuf': 'Exiting: buffer changed, old buffer was wiped out',
         \}
 " iterfunc :: {fname: { "start": startfunc, "next": nextfunc }}
 " startfunc (always) :: repo, opts, * → d
     let collen=len(lines[-1])
     let a:text.block_r[0][1]+=collen
     let a:text.block_r[1][1]+=collen
+    call s:F.glog.addcols(a:text.special, collen)
     let lines[-1]=lines[-1][:-2].' '.get(a:text.text, 0, '')
     let cchar=a:graph.output_commit_char()
     let bidx=stridx(lines[-1], cchar)
         let literfuncs=s:iterfuncs.hg
     endif
     "▶3 Initialize variables
-    let specials={}
-    let rectangles=[]
-    let csstarts={}
-    let r=[]
-    let a:bvar.rectangles=rectangles
-    let a:bvar.specials=specials
-    let a:bvar.csstarts=csstarts
-    let a:opts.skipchangesets={}
     let haslimit=has_key(a:opts, 'limit')
     if haslimit
         let limit=a:opts.limit
     let foundfirst=0
     let csbuf=[]
     let reqprops=s:F.requiredpropslist(a:opts)
+    "▶3 Initialize variables not required for reading
+    if !a:read
+        let specials={}
+        let rectangles=[]
+        let csstarts={}
+        let r=[]
+        let a:bvar.rectangles=rectangles
+        let a:bvar.specials=specials
+        let a:bvar.csstarts=csstarts
+        let a:opts.skipchangesets={}
+        let didredraw=0
+        let procinput=a:bvar.procinput
+        let lastw0line=-1
+        let buf=bufnr('%')
+        let firstcs=1
+        let lastline=0
+    endif
     "▶3 Initialize iterator functions
     let ld=literfuncs.start(a:repo,a:opts,[a:repo.functions.getworkhex(a:repo)])
     let csd=a:csiterfuncs.start(a:repo, a:opts)
     "▲3
     while 1 && (!haslimit || limit)
         let cs=a:csiterfuncs.next(csd)
-        if cs is 0
+        if cs is 0 "▶3
             return r
-        endif
+        endif "▲3
         let skip=!s:iterfuncs.check.check(checkd, cs)
+        "▶3 Add cs to skipchangesets or get its properties
         if skip
             let a:opts.skipchangesets[cs.hex]=cs
         else
                 let limit-=1
             endif
         endif
+        "▲3
         if foundfirst
             let csbuf+=[cs]
             if !skip
                 for cs in csbuf
                     let [lines, rectangle, special]=literfuncs.proccs(ld, cs)
+                    "▶3 Add various information to bvar
                     if !a:read && rectangle isnot 0
-                        let rectangle[0][0]=len(r)
-                        let rectangle[1][0]=len(r)+len(lines)-1
+                        let rectangle[0][0]=lastline
+                        let lastline+=len(lines)
+                        let rectangle[1][0]=lastline-1
                         let rectangle+=[cs.hex]
                         call add(rectangles, rectangle)
                         let csstarts[cs.hex]=rectangle[0][0]
                             let specials[cs.hex]=special
                         endif
                     endif
-                    let r+=lines
+                    "▲3
+                    "▶3 Add lines to returned list if reading
+                    if a:read
+                        let r+=lines
+                    "▶3 Add lines to buffer if not, process user input
+                    else
+                        "▶4 Add lines to buffer
+                        if firstcs
+                            call setline(1, lines)
+                            let firstcs=0
+                        else
+                            call append('$', lines)
+                        endif
+                        "▶4 Process user input
+                        if didredraw
+                            if procinput && getchar(1)
+                                let input=''
+                                while getchar(1)
+                                    let char=getchar()
+                                    if type(char)==type(0)
+                                        let input.=nr2char(char)
+                                    else
+                                        let input.=char
+                                    endif
+                                endwhile
+                                execute 'normal' input
+                                if bufnr('%')!=buf
+                                    if bufexists(buf)
+                                        execute 'buffer' buf
+                                    else
+                                        call s:_f.warn('ebuf')
+                                        return []
+                                    endif
+                                endif
+                                let lw0=line('w0')
+                                if lw0!=lastw0line
+                                    redraw
+                                    let didredraw=(line('$')>=lw0+winheight(0))
+                                    let lastw0line=lw0
+                                endif
+                            endif
+                        "▶4 Redraw if necessary
+                        elseif line('$')>=line('w0')+winheight(0)
+                            redraw
+                            let didredraw=1
+                            let lastw0line=line('w0')
+                        endif
+                        "▲4
+                    endif
+                    "▲3
                     unlet rectangle special
                 endfor
                 call remove(csbuf, 0, -1)
     let bvar.templatelist=s:F.temp.parse(template)
     let opts.templatefunc=s:F.temp.compile(bvar.templatelist, opts)
     "▲2
-    let text=s:F.glog.graphlog(a:repo, opts, iterfuncs, bvar, a:read)
-    let bvar.cw=s:_f.getoption('closewindow')
     if !a:read
-        setlocal noreadonly modifiable
-    endif
-    call s:_r.setlines(text, a:read)
-    if !a:read
-        setlocal readonly nomodifiable buftype=nofile
+        "▶ Required for setting syntax definitions and also for maps to work
+        " Is normally done by edit.vim, but in our case it is needed earlier
+        let bvar.opts=a:opts
+        let bvar.repo=a:repo
+        let s:_r.bufvars[bufnr('%')]=bvar
+        "▲
+        let bvar.procinput=(has_key(a:opts, 'procinput')?
+                    \           (2*a:opts.procinput):
+                    \           s:_f.getoption('procinput'))
+        if bvar.procinput==1 && getchar(1)
+            let bvar.procinput=0
+        endif
+        setlocal buftype=nofile filetype=aurumlog
         augroup AuLogNoInsert
             autocmd InsertEnter <buffer> :call feedkeys("\e", "n")
         augroup END
     endif
+    let bvar.cw=s:_f.getoption('closewindow')
+    let text=s:F.glog.graphlog(a:repo, opts, iterfuncs, bvar, a:read)
+    if a:read
+        call s:_r.setlines(text, a:read)
+    else
+        setlocal readonly nomodifiable
+    endif
     return bvar
 endfunction
 let s:_augroups+=['AuLogNoInsert']
             \          '  !?showfiles'.
             \          '  !?showrenames'.
             \          '  !?showcopies'.
+            \          '  !?procinput'.
             \          s:_r.repo.diffoptsstr.
             \          '   ?cmd      type ""'.
             \          '}', 'filter']
             \'function': s:F.setup,
             \ 'options': {'list': ['files', 'revrange', 'ignfiles'],
             \             'bool': ['merges', 'patch', 'stat', 'showfiles',
-            \                      'showrenames', 'showcopies'],
+            \                      'showrenames', 'showcopies', 'procinput'],
             \              'num': ['limit']+s:_r.repo.diffoptslst,
             \              'str': ['date', 'search', 'user', 'branch',
             \                      'revision', 'style', 'template',

File test/log-styles.ok

 |  :+    echo 'Abc' > ignoredabc
 |  :+)
 |  :+tar cJf testrepo.tar.xz testrepo
-|  :
+|  :

File test/log-templates.ok

 o  
 |  
 o  
-|  
+|  
 o | | |    Changeset 9:269399222040415b3928a316f5d28792cc0be4dd
 |\ \ \ \   Commited 01 Янв 2001 00:00 by C <c@example.gov>
 | | | | |  @ Merge from C
-| | | | |  
+| | | | |