debugbuilddag: lock repo before starting transaction
authorMads Kiilerich <mads@kiilerich.com>
Fri, 13 Jan 2012 01:19:07 +0100
changeset 15875 7eca9db689d6
parent 15874 2305baff673f
child 15876 2de1244361aa
debugbuilddag: lock repo before starting transaction
mercurial/commands.py
--- a/mercurial/commands.py	Fri Jan 13 01:19:07 2012 +0100
+++ b/mercurial/commands.py	Fri Jan 13 01:19:07 2012 +0100
@@ -1368,8 +1368,10 @@
 
     tags = []
 
-    tr = repo.transaction("builddag")
+    lock = tr = None
     try:
+        lock = repo.lock()
+        tr = repo.transaction("builddag")
 
         at = -1
         atbranch = 'default'
@@ -1445,12 +1447,12 @@
                 atbranch = data
             ui.progress(_('building'), id, unit=_('revisions'), total=total)
         tr.close()
+
+        if tags:
+            repo.opener.write("localtags", "".join(tags))
     finally:
         ui.progress(_('building'), None)
-        tr.release()
-
-    if tags:
-        repo.opener.write("localtags", "".join(tags))
+        release(tr, lock)
 
 @command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE'))
 def debugbundle(ui, bundlepath, all=None, **opts):