ZyX_I avatar ZyX_I committed 44c02f5

@aurum/drivers/mercurial: Removed iterfuncs.changesets and iterfuncs.revrange
as they are very slow (slower then default
implementations)
Made rf-getcs() not call rf-getrevhex() in some cases

Comments (0)

Files changed (2)

plugin/aurum/drivers/mercurial.vim

     endif
     return cslist[(rev1):(rev2)]
 endfunction
+"▶1 getcs :: repo, rev → cs
+if s:usepythondriver "▶2
+function s:F.getcs(repo, rev)
+    let cs={}
+    try
+        execute s:_r.py.cmd 'aurum.get_cs(vim.eval("a:repo.path"), '.
+                    \                    'vim.eval("a:rev"))'
+    endtry
+    return cs
+endfunction
+else "▶2
+function s:F.getcs(repo, rev)
+    let csdata=s:F.hg(a:repo, 'log', [], {'rev': a:rev, 'style': s:stylefile},0,
+                \     'cs', a:rev)
+    let cs=s:F.parsecs(csdata, 0)[0]
+    call map(cs.parents,
+                \'type(v:val)=='.type(0).'? '.
+                \   'a:repo.functions.getrevhex(a:repo, v:val): '.
+                \   'v:val')
+    return cs
+endfunction
+endif
 "▶1 iterfuncs
+"▶2 getfromchangesets
+function s:F.getfromchangesets(repo, hex)
+    return a:repo.changesets[a:hex]
+endfunction
+"▶2 getrev
+function s:F.getrev(repo, rev)
+    let cs=s:F.getcs(a:repo, a:rev)
+    let a:repo.changesets[cs.hex]=cs
+    return cs
+endfunction
+"▶2 getgetcsfunc
+function s:F.getgetcsfunc(repo)
+    if empty(a:repo.cslist)
+        return s:F.getrev
+    else
+        return s:F.getfromchangesets
+    endif
+endfunction
 "▶2 iterfuncs.ancestors
 let s:iterfuncs.ancestors={}
 function s:iterfuncs.ancestors.start(repo, opts)
     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)}
+                \'hasrevisions': get(a:repo, 'hasrevisions', 1),
+                \'getcs': s:F.getgetcsfunc(a:repo)}
 endfunction
 function! s:RevCmp(cs1, cs2)
     let rev1=a:cs1.rev
         return s:iterfuncs.ancestors.next(a:d)
     endif
     let a:d.revisions[cs.hex]=cs
-    let parents=map(copy(cs.parents),'a:d.repo.functions.getcs(a:d.repo,v:val)')
+    let parents=map(copy(cs.parents),'a:d.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
 endfunction
-"▶2 iterfuncs.revrange
-let s:iterfuncs.revrange={}
-function s:iterfuncs.revrange.start(repo, opts)
-    let rev1=a:repo.functions.getcs(a:repo, a:opts.revrange[0]).rev
-    let rev2=a:repo.functions.getcs(a:repo, a:opts.revrange[1]).rev
-    if rev1>rev2
-        let [rev1, rev2]=[rev2, rev1]
-    endif
-    return {'cur': rev2, 'last': rev1, 'repo': a:repo}
-endfunction
-function s:iterfuncs.revrange.next(d)
-    if a:d.cur<a:d.last
-        return 0
-    endif
-    let r=a:d.repo.functions.getcs(a:d.repo, a:d.cur)
-    let a:d.cur-=1
-    return r
-endfunction
-"▶2 iterfuncs.changesets
-let s:iterfuncs.changesets={}
-function s:iterfuncs.changesets.start(repo, opts)
-    return {'cur': a:repo.functions.getcs(a:repo, 'tip').rev, 'last': 0,
-                \'repo': a:repo}
-endfunction
-let s:iterfuncs.changesets.next=s:iterfuncs.revrange.next
 "▶1 hg.getrevhex :: repo, rev → rev(hex)
 if s:usepythondriver "▶2
 function s:hg.getrevhex(repo, rev)
 endfunction
 endif
 "▶1 hg.getcs :: repo, rev → cs
-"▶2 getcs
-if s:usepythondriver "▶3
-function s:F.getcs(repo, rev)
-    let cs={}
-    try
-        execute s:_r.py.cmd 'aurum.get_cs(vim.eval("a:repo.path"), '.
-                    \                    'vim.eval("a:rev"))'
-    endtry
-    return cs
-endfunction
-else "▶3
-function s:F.getcs(repo, rev)
-    let csdata=s:F.hg(a:repo, 'log', [], {'rev': a:rev, 'style': s:stylefile},0,
-                \     'cs', a:rev)
-    let cs=s:F.parsecs(csdata, 0)[0]
-    call map(cs.parents,
-                \'type(v:val)=='.type(0).'? '.
-                \   'a:repo.functions.getrevhex(a:repo, v:val): '.
-                \   'v:val')
-    return cs
-endfunction
-endif
-"▲2
 function s:hg.getcs(repo, rev)
     if !empty(a:repo.cslist)
         if type(a:rev)==type('') && has_key(a:repo.changesets, a:rev)
             return a:repo.cslist[a:rev]
         endif
     endif
-    let hex=a:repo.functions.getrevhex(a:repo, a:rev)
+    if a:rev=~#'\v^[0-9a-f]{40}$'
+        let hex=a:rev
+    else
+        let hex=a:repo.functions.getrevhex(a:repo, a:rev)
+    endif
     if has_key(a:repo.changesets, hex) && !empty(a:repo.cslist)
         return a:repo.changesets[hex]
     else
         let cs=s:F.getcs(a:repo, hex)
-        let a:repo.changesets[hex]=cs
+        let a:repo.changesets[cs.hex]=cs
         return cs
     endif
 endfunction
 |  Commited 02 Янв 1999 05:20 by A <a@example.com>
 |  @ Added «createrepo.zsh»
 |  
-o  Changeset -1:0000000000000000000000000000000000000000
+o  Changeset 27:0000000000000000000000000000000000000000
 /  Commited 01 Янв 1970 00:00 by 
    
 {{{1 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.