ZyX_I avatar ZyX_I committed c7634bf

@aurum/repo: First version that normally sorts. Don’t know why though, it perhaps should not. Should fix ref #8

Comments (0)

Files changed (1)


         let work=[]
-        call map(copy(a:css), 'v:val.indegree==1 && add(work, v:val) is 0')
+        call map(copy(a:css), 'v:val.indegree==1 ? add(work, v:val) : 0')
         call sort(work, 's:DateCmp')
         let r=[]
         while !empty(work)
 function s:iterfuncs.ancestors.start(repo, opts)
     let cs=a:repo.functions.getcs(a:repo,
                 \a:repo.functions.getrevhex(a:repo, a:opts.revision))
+    let indegree={cs.hex : 1}
+    for parenthex in cs.parents
+        let indegree[parenthex]=2
+    endfor
     return {'addrevs': [cs], 'revisions': {}, 'repo': a:repo,
-                \'hasrevisions': get(a:repo, 'hasrevisions', 1)}
+                \'hasrevisions': get(a:repo, 'hasrevisions', 1),
+                \'indegree': indegree}
 function! s:RevCmp(cs1, cs2)
     let rev1=a:cs1.rev
     if empty(a:d.addrevs)
         return 0
-    let cs=remove(a:d.addrevs, 0)
+    " XXX cs variables should be kept after cycle ends
+    let i=-1
+    for cs in a:d.addrevs
+        let i+=1
+        if a:d.indegree[cs.hex]<=1
+            break
+        endif
+    endfor
+    call remove(a:d.addrevs, i)
+    unsilent echom a:d.indegree[cs.hex] cs.hex
     if has_key(a:d.revisions, cs.hex)
         return s:iterfuncs.ancestors.next(a:d)
     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
+    for parenthex in filter(copy(cs.parents), '!has_key(a:d.revisions, v:val)')
+        let parent=a:d.repo.functions.getcs(a:d.repo, parenthex)
+        let a:d.indegree[parenthex]=a:d.indegree[parenthex]-1
+        for pparhex in parent.parents
+            let a:d.indegree[pparhex]=get(a:d.indegree, pparhex, 1)+1
+        endfor
+        let a:d.addrevs+=[parent]
+    endfor
+    " if a:d.hasrevisions
+        " call sort(a:d.addrevs, 's:RevCmp')
+    " endif
     return cs
 "▶2 revrange
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.