diff svncommand.py @ 33:a9c15cae50e5

Faster append-only revmap implementation.
author Andreas Hartmetz <ahartmetz@gmail.com>
date Wed, 15 Oct 2008 21:47:48 -0400
parents 9c481cae0428
children 50d55c3e0d85
line wrap: on
line diff
--- a/svncommand.py
+++ b/svncommand.py
@@ -64,6 +64,19 @@ def generate_hg_tags(ui, hg_repo_path, *
         source_ha = hg_editor.get_parent_revision(source[1]+1, source[0])
         f.write('%s tag/%s\n' % (node.hex(source_ha), tag))
 
+def parse_revmap(revmap_filename):
+    revmap = {}
+    f = open(revmap_filename)
+    for l in f:
+        revnum, node_hash, branch = l.split(' ', 2)
+        if branch == '\n':
+            branch = None
+        else:
+            branch = branch[:-1]
+        revmap[int(revnum), branch] = node.bin(node_hash)
+    f.close()
+    return revmap
+
 @register_subcommand('up')
 def update(ui, args, repo, clean=False, **opts):
     """Update to a specified Subversion revision number.
@@ -72,7 +85,7 @@ def update(ui, args, repo, clean=False, 
     rev = int(args[0])
     path = os.path.join(repo.path, 'svn', 'rev_map')
     answers = []
-    for k,v in pickle.load(open(path)).iteritems():
+    for k,v in parse_revmap(path).iteritems():
         if k[0] == rev:
             answers.append((v, k[1]))
     if len(answers) == 1:
@@ -139,8 +152,7 @@ def verify_all_revisions(ui, args, repo,
     args = list(args)
     if args:
         start_rev = int(args.pop(0))
-    revmap_f = open(os.path.join(repo.path, 'svn', 'rev_map'))
-    revmap = pickle.load(revmap_f)
+    revmap = parse_revmap(os.path.join(repo.path, 'svn', 'rev_map'))
     revs = sorted(revmap.keys())
     for revnum, br in revs:
         if revnum < start_rev: