diff hgext/transplant.py @ 15204:3ce9b1a7538b

transplant: wrap a transaction around the whole command
author Greg Ward <greg@gerg.ca>
date Tue, 04 Oct 2011 19:43:45 -0400
parents 39235b398248
children f7db54b832af
line wrap: on
line diff
--- a/hgext/transplant.py	Fri Oct 07 17:08:24 2011 -0500
+++ b/hgext/transplant.py	Tue Oct 04 19:43:45 2011 -0400
@@ -105,10 +105,11 @@
         diffopts = patch.diffopts(self.ui, opts)
         diffopts.git = True
 
-        lock = wlock = None
+        lock = wlock = tr = None
         try:
             wlock = repo.wlock()
             lock = repo.lock()
+            tr = repo.transaction('transplant')
             for rev in revs:
                 node = revmap[rev]
                 revstr = '%s:%s' % (rev, short(node))
@@ -172,12 +173,15 @@
                     finally:
                         if patchfile:
                             os.unlink(patchfile)
+            tr.close()
             if pulls:
                 repo.pull(source, heads=pulls)
                 merge.update(repo, pulls[-1], False, False, None)
         finally:
             self.saveseries(revmap, merges)
             self.transplants.write()
+            if tr:
+                tr.release()
             lock.release()
             wlock.release()