Commits

ZyX_I committed 8ee05f2

@aurum/log: Finally made logger function that should make adding incremental updates easy.
Still something has to be done with skipping changesets: graphers can’t see which parents are to be skipped

Comments (0)

Files changed (2)

plugin/aurum/log.vim

 endfunction
 let s:_functions+=['s:DateCmp']
 "▶2 glog.graphlog
-function s:F.glog.graphlog(repo, opts, css)
+function s:F.glog.graphlog(repo, opts, csiterfuncs, bvar, read)
+    "▶3 Get grapher
     if get(a:repo, 'has_octopus_merges', 1)
-        let iterfuncs=s:iterfuncs.git
+        let literfuncs=s:iterfuncs.git
     else
-        let iterfuncs=s:iterfuncs.hg
+        let literfuncs=s:iterfuncs.hg
     endif
+    "▶3 Initialize variables
     let specials={}
     let rectangles=[]
     let csstarts={}
-    let text=[]
-    let d=iterfuncs.start(a:repo, a:opts, [a:repo.functions.getworkhex(a:repo)])
-    for cs in a:css
-        let [lines, rectangle, special]=iterfuncs.proccs(d, cs)
-        if rectangle isnot 0
-            let rectangle[0][0]=len(text)
-            let rectangle[1][0]=len(text)+len(lines)-1
-            let rectangle+=[cs.hex]
-            call add(rectangles, rectangle)
-            let csstarts[cs.hex]=rectangle[0][0]
-            if special isnot 0
-                let specials[cs.hex]=special
+    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
+    endif
+    let foundfirst=0
+    let csbuf=[]
+    let reqprops=s:F.requiredpropslist(a:opts)
+    "▶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)
+    let checkd=s:iterfuncs.check.start(a:repo, a:opts)
+    "▲3
+    while 1 && (!haslimit || limit)
+        let cs=a:csiterfuncs.next(csd)
+        if cs is 0
+            return r
+        endif
+        let skip=!s:iterfuncs.check.check(checkd, cs)
+        if skip
+            let a:opts.skipchangesets[cs.hex]=cs
+        else
+            call map(copy(reqprops),
+                        \'a:repo.functions.getcsprop(a:repo, cs, v:val)')
+            let foundfirst=1
+            if haslimit
+                let limit-=1
             endif
         endif
-        let text+=lines
-        unlet rectangle special
-    endfor
-    return    {'rectangles': rectangles,
-                \'specials': specials,
-                \'csstarts': csstarts,
-                \    'text': text,}
+        if foundfirst
+            let csbuf+=[cs]
+            if !skip
+                for cs in csbuf
+                    let [lines, rectangle, special]=literfuncs.proccs(ld, cs)
+                    if !a:read && rectangle isnot 0
+                        let rectangle[0][0]=len(r)
+                        let rectangle[1][0]=len(r)+len(lines)-1
+                        let rectangle+=[cs.hex]
+                        call add(rectangles, rectangle)
+                        let csstarts[cs.hex]=rectangle[0][0]
+                        if special isnot 0
+                            let specials[cs.hex]=special
+                        endif
+                    endif
+                    let r+=lines
+                    unlet rectangle special
+                endfor
+                call remove(csbuf, 0, -1)
+            endif
+        endif
+        unlet cs
+    endwhile
+    return r
 endfunction
 "▶1 iterfuncs: loggers
 "▶2 iterfuncs.git
 "▶2 iterfuncs.check.start
 "▶3 addcentury
 function s:F.addcentury(year)
-    if type(a:year)==type(0) && len(a:year)==2
-        let y=a:year
-        let cy=str2nr(strftime('%y'))
-        let c=str2nr(strftime('%Y')[:-3])
-        if y<=cy
-            let r=((c*100)+y)
+    if type(a:year)==type(0) && a:year<100
+        let curyear=str2nr(strftime('%y'))
+        let century=str2nr(strftime('%Y')[:-3])
+        if a:year<=curyear
+            let r=((century*100)+a:year)
         else
-            let r=(((c-1)*100)+y)
+            let r=(((century-1)*100)+a:year)
         endif
         return r
     endif
     "▲3
     return 1
 endfunction
-"▶1 genlist :: iterfuncs, repo, opts → [cs]
-function s:F.genlist(iterfuncs, repo, opts)
-    let d=a:iterfuncs.start(a:repo, a:opts)
-    let checkd=s:iterfuncs.check.start(a:repo, a:opts)
-    let reqprops=s:F.requiredpropslist(a:opts)
-    let r=[]
-    let a:opts.skipchangesets={}
-    let haslimit=has_key(a:opts, 'limit')
-    if haslimit
-        let limit=a:opts.limit
-    endif
-    let firstidx=-1
-    let lastidx=-1
-    while 1 && (!haslimit || limit)
-        let cs=a:iterfuncs.next(d)
-        if cs is 0
-            break
-        endif
-        if s:iterfuncs.check.check(checkd, cs)
-            call map(copy(reqprops),
-                        \'a:repo.functions.getcsprop(a:repo, cs, v:val)')
-            if haslimit
-                let limit-=1
-            endif
-            if firstidx==-1
-                let firstidx=len(r)
-            endif
-            let lastidx=len(r)
-        else
-            let a:opts.skipchangesets[cs.hex]=cs
-        endif
-        let r+=[cs]
-        unlet cs
-    endwhile
-    if !get(a:repo, 'requires_sort', 1)
-        if lastidx!=-1 && lastidx<len(r)-1
-            call remove(r, lastidx+1, -1)
-        endif
-        if firstidx>0
-            call remove(r, 0, firstidx-1)
-        endif
-    endif
-    return r
-endfunction
 "▶1 setup
 "▶2 getkwreg
 function s:F.getkwreg(kw, nextlit)
     call map(copy(ignorefiles), 'extend(opts.ignorefiles, {v:val : 1})')
     unlet ignorefiles
     "▶2 Get cslist
-    let opts.iterfuncs=s:iterfuncs[((has_key(opts, 'revision'))?
-                \                     ('ancestors'):
-                \                  ((has_key(opts, 'revrange'))?
-                \                     ('revrange')
-                \                  :
-                \                     ('changesets')))]
+    let iterfuncs=s:iterfuncs[((has_key(opts, 'revision'))?
+                \                ('ancestors'):
+                \             ((has_key(opts, 'revrange'))?
+                \                ('revrange')
+                \             :
+                \                ('changesets')))]
     "▶2 Get template
     if has_key(opts, 'template')
         let template=eval(opts.template)
     let bvar.templatelist=s:F.temp.parse(template)
     let opts.templatefunc=s:F.temp.compile(bvar.templatelist, opts)
     "▲2
-    let css=s:F.genlist(opts.iterfuncs, a:repo, opts)
-    let text=s:F.glog.graphlog(a:repo, opts, css)
-    let bvar.specials=text.specials
-    let bvar.rectangles=text.rectangles
-    let bvar.csstarts=text.csstarts
+    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.text, a:read)
+    call s:_r.setlines(text, a:read)
     if !a:read
         setlocal readonly nomodifiable buftype=nofile
         augroup AuLogNoInsert
 |  @ Added «createrepo.zsh»
 |  
 {{{3 02
-|\ 
-|/ 
-|\ 
-|\ \ 
-| | |\ 
-| | |\ \ 
-| | | | |/ 
-| +-----+ 
-| +-----+ 
-|\ \ \ \ 
-| |/ / / 
-| +---+ 
-|  / / 
-| |/ 
-|/ 
+@  Changeset 26:504f74154456dbb0e9441326514e42ce66279e62
+|  Commited 11 Фев 2002 05:43 by A <a@example.com>
+|  Tags: tip
+|  @ Added .hgignore
+|  @ Added directory/file
+|  
+o    Changeset 25:d8140c0b7b0b670bafe0891bcf0c4582092de884
+|\   Commited 11 Фев 2002 05:00 by C <c@example.gov>
+| |  @ Merge
+| |  
+o |  Changeset 24:e021c634413b240b8c834a85200acc28d645f1f1
+| |  Commited 11 Фев 2002 04:15 by A <a@example.com>
+| |  @ Added elines.lst with eplines
+| |  @ Added flines.lst with frlines
+| |  @ Added glines.lst with grlines
+| |  
+| o  Changeset 23:e1eaeea486e48634588c778fd36a81ac5c8869a6
+|/   Commited 11 Фев 2002 04:15 by A <a@example.com>
+|    @ Added elines.lst, flines.lst and glines.lst
+|    
+o  Changeset 22:5afd628b0861f6447ed813895d5ced58a1c42a72
+|  Commited 11 Фев 2002 03:16 by A <a@example.com>
+|  @ Added tag oldtag for changeset 023aa55bd806
+|  
+o  Changeset 21:e85aa09aab1621b59b8be37f723410b219c8599c
+|  Commited 11 Фев 2002 03:15 by A <a@example.com>
+|  @ Added ignored10.lst
+|  
+o  Changeset 20:67cf252de26b12da6769114cc89b793357f5a46a
+|  Commited 10 Фев 2002 16:01 by B <b@example.org>
+|  @ Added nohglinesrev.lst
+|  
+o  Changeset 19:456e0b05b81af4f332405336f11df4769ec9f250
+|  Commited 10 Фев 2002 15:33 by B <b@example.org>
+|  @ Added nohglines.lst
+|  
+o  Changeset 18:f44a21859e57e4abc6155da804d08dd5069e798e
+|  Commited 10 Фев 2002 05:00 by A <a@example.com>
+|  @ Copied “hglines.lst” to “hglines2.lst”
+|  
+o    Changeset 17:e5648a3eea574f3fc03709b4fdd799a38f649edd
+|\   Commited 01 Янв 2002 00:00 by C <c@example.gov>
+| |  @ Merge from A
+| |  
+o |    Changeset 16:462a1e95be86f96aaf6d7360f6f770826c3eb641
+|\ \   Commited 01 Янв 2002 00:00 by C <c@example.gov>
+| | |  @ Merge from C:1
+| | |  
+| | o    Changeset 15:be92227e3e43f4e7402408afe110098d209d2568 (branch A)
+| | |\   Commited 01 Янв 2002 00:00 by C <c@example.gov>
+| | | |  @ Merge from C:2
+| | | |  
+| | o |    Changeset 14:5e2f73d0c01dfb8ee0d3577e03d016a5f6df58b1 (branch A)
+| | |\ \   Commited 01 Янв 2002 00:00 by C <c@example.gov>
+| | | | |  @ Merge from B
+| | | | |  
 {{{3 2001
 o  Changeset 13:14b19ea42f824c8597f8358149c5ba994299a410 (branch C)
 |  Commited 01 Фев 2001 14:56 by B <b@example.org>