ZyX_I  committed 51ea9e0

@aurum/log: Made ancestors cs generator sort changesets by revision number
before outputting.
Ref #8 for Mercurial driver is not fixed, but something still has to
be done with git

  • Participants
  • Parent commits da0ddfd

Comments (0)

Files changed (3)

File README.markdown

   - Viewing working directory status ([:AuStatus](
   - Commiting changes ([:AuCommit](, commit messages are remembered in case of 
-    rollback ([g:aurum_remembermsg](
+    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 

File doc/aurum.txt

     other case it will possibly break mappings that do not expect such 
     behavior from |:AuLog|).
     Default value: 1.
+    Note: if you somehow switch buffers while log is being generated then 
+          buffer with generated log will be wiped out, log generation will 
+          stop.
 recheight                                                  *g:aurum_recheight*
     VimL |expression| that evaluates to unsigned integer or unsigned integer. 
     Determines whether |aurum-cs.rev| contains something different from 
     abbreviated hash. If this option is false, then in log produced by 
     |aurum://log| revisions will be ignored.
+    If it is true, then it also assumes that changesets sorted by revision 
+    numbers are sorted in topological order (see |aurum-rf-getchangesets|).
     This key is optional, default value: true.
 functions :: {String : FRef}                            *aurum-repo.functions*
     Dictionary that contains all driver-specific functions. All functions 

File plugin/aurum/log.vim

 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',
+            \  'ebuf': 'Switched to another buffer: exiting',
 " iterfunc :: {fname: { "start": startfunc, "next": nextfunc }}
 " startfunc (always) :: repo, opts, * → d
                                 execute 'normal' input
                                 if bufnr('%')!=buf
                                     if bufexists(buf)
-                                        execute 'buffer' buf
-                                    else
-                                        call s:_f.warn('ebuf')
-                                        return []
+                                        execute 'silent bwipeout!' buf
+                                    call s:_f.warn('ebuf')
+                                    return []
                                 let lw0=line('w0')
                                 if lw0!=lastw0line
 "▶2 ancestors
 let s:iterfuncs.ancestors={}
 function s:iterfuncs.ancestors.start(repo, opts)
-    let hex=a:repo.functions.getrevhex(a:repo, a:opts.revision)
-    return {'addrevs': [hex], 'revisions': {}, 'repo': a:repo}
+    let cs=a:repo.functions.getcs(a:repo,
+                \a:repo.functions.getrevhex(a:repo, a:opts.revision))
+    return {'addrevs': [cs], 'revisions': {}, 'repo': a:repo,
+                \'hasrevisions': get(a:repo, 'hasrevisions', 1)}
+function! s:RevCmp(cs1, cs2)
+    let rev1=a:cs1.rev
+    let rev2=a:cs2.rev
+    return ((rev1==rev2)?(0):((rev1<rev2)?(1):(-1)))
+let s:_functions+=['s:RevCmp']
     if empty(a:d.addrevs)
         return 0
-    let hex=remove(a:d.addrevs, 0)
-    if has_key(a:d.revisions, hex)
+    let cs=remove(a:d.addrevs, 0)
+    if has_key(a:d.revisions, cs.hex)
-    let cs=a:d.repo.functions.getcs(a:d.repo, hex)
-    let a:d.revisions[hex]=cs
-    let a:d.addrevs+=cs.parents
+    let a:d.revisions[cs.hex]=cs
+    let parents=map(copy(cs.parents),'a:d.repo.functions.getcs(a:d.repo,v:val)')
+    call extend(a:d.addrevs, parents)
+    if a:d.hasrevisions
+        call sort(a:d.addrevs, 's:RevCmp')
+    endif
     return cs
 "▶2 revrange