commands: lock() the repo while unbundling (issue1004)
authorPatrick Mezard <pmezard@gmail.com>
Thu, 28 Feb 2008 00:07:38 +0100
changeset 6180 d98ef03893e6
parent 6179 36ab165abbe2
child 6181 d500aeb8092e
commands: lock() the repo while unbundling (issue1004)
mercurial/commands.py
--- a/mercurial/commands.py	Thu Feb 28 00:07:37 2008 +0100
+++ b/mercurial/commands.py	Thu Feb 28 00:07:38 2008 +0100
@@ -2649,13 +2649,19 @@
     bundle command.
     """
     fnames = (fname1,) + fnames
-    for fname in fnames:
-        if os.path.exists(fname):
-            f = open(fname, "rb")
-        else:
-            f = urllib.urlopen(fname)
-        gen = changegroup.readbundle(f, fname)
-        modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
+
+    lock = None
+    try:
+        lock = repo.lock()
+        for fname in fnames:
+            if os.path.exists(fname):
+                f = open(fname, "rb")
+            else:
+                f = urllib.urlopen(fname)
+            gen = changegroup.readbundle(f, fname)
+            modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
+    finally:
+        del lock
 
     return postincoming(ui, repo, modheads, opts['update'], None)