Commits

ZyX_I committed 75c791b

Greatly improved new_repo function perfomance

Comments (0)

Files changed (2)

     let repo={}
     let s:repos[a:path]=repo
     execute s:_r.py.cmd 'aurum.new_repo(vim.eval("a:path"))'
-    for cs in values(repo.changesets)
+    call map(copy(repo.cslist), 'extend(repo.changesets, {v:val.hex : v:val})')
+    for cs in repo.cslist
         let cs.parents=map(copy(cs.parents_hex), 'repo.changesets[v:val]')
         let cs.children=map(copy(cs.children_hex), 'repo.changesets[v:val]')
     endfor
 
 from mercurial import hg, ui
 import vim
+import json
 
 ui=ui.ui()
 repositories={}
 
-def vim_escape(string):
-    # XXX works only in eval: NLs!
-    return "'"+str(string).replace("'", "''")+"'"
-
 def get_repo(path):
     if(path not in repositories):
         repositories[path]=hg.repository(ui, path)
 
 def new_repo(path):
     repo=get_repo(path)
+    repo_vim={}
     cscount=repo['tip'].rev()+1
-    vim.command('let repo.cscount='+str(cscount))
-    vim.command('let repo.changesets={}')
-    vim.command('let repo.cslist=[]')
-    vim.command('let repo.work_hex="'+repo['.'].hex()+'"')
+    repo_vim['cscount']=cscount
+    repo_vim['changesets']={}
+    repo_vim['cslist']=[{'rev': i,
+                 'parents_hex': [],
+                'children_hex': [],
+                       'files': [],} for i in range(0, cscount+1)]
+    repo_vim['work_hex']=repo['.'].hex()
     curcsnum=0
     while curcsnum<=cscount:
         cs=repo[curcsnum]
-        vim.command('let cs={}')
-        vim.command('let cs.rev='+str(curcsnum))
-        vim.command('let cs.hex="'+cs.hex()+'"')
-        vim.command('let repo.changesets[cs.hex]=cs')
-        vim.eval('add(repo.cslist, cs)')
-        vim.command('let cs.parents_hex=[]')
+        cs_vim=repo_vim['cslist'][curcsnum]
+        cs_vim.__setitem__('hex', cs.hex())
         for parent in cs.parents():
-            vim.eval('add(cs.parents_hex, "'+parent.hex()+'")')
-        vim.command('let cs.children_hex=[]')
-        for child in cs.children():
-            vim.eval('add(cs.children_hex, "'+child.hex()+'")')
-        vim.command('let cs.files=[]')
-        for file in cs:
-            vim.eval('add(cs.files, '+vim_escape(file)+')')
+            cs_vim['parents_hex'].append(parent.hex())
+            repo_vim['cslist'][parent.rev()]['children_hex'].append(cs_vim['hex'])
+        for file in cs.files():
+            cs_vim['files'].append(file)
         curcsnum+=1
+    vim.eval('extend(repo, '+json.dumps(repo_vim)+')')
 
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.