Patchwork [3,of,6] dirstate: remove meaningless dirstateguard

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 8, 2015, 6:59 p.m.
Message ID <c86761d89c8b7a032af9.1444330742@feefifofum>
Download mbox | patch
Permalink /patch/10881/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Oct. 8, 2015, 6:59 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1444330426 -32400
#      Fri Oct 09 03:53:46 2015 +0900
# Node ID c86761d89c8b7a032af93b5058163a9f231f0131
# Parent  13931979f80c0e7facc094e5d535126ca8f6d133
dirstate: remove meaningless dirstateguard

Previous patch made dirstate changes in a transaction scope "all or
nothing". Therefore, 'dirstateguard' is meaningless, if its scope is
as same as one of the related transaction.

This patch removes such meaningless 'dirstateguard' usage.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -816,10 +816,9 @@ 
     def apply(self, repo, series, list=False, update_status=True,
               strict=False, patchdir=None, merge=None, all_files=None,
               tobackup=None, keepchanges=False):
-        wlock = dsguard = lock = tr = None
+        wlock = lock = tr = None
         try:
             wlock = repo.wlock()
-            dsguard = cmdutil.dirstateguard(repo, 'mq.apply')
             lock = repo.lock()
             tr = repo.transaction("qpush")
             try:
@@ -828,12 +827,10 @@ 
                                   tobackup=tobackup, keepchanges=keepchanges)
                 tr.close()
                 self.savedirty()
-                dsguard.close()
                 return ret
             except AbortNoCleanup:
                 tr.close()
                 self.savedirty()
-                dsguard.close()
                 raise
             except: # re-raises
                 try:
@@ -843,7 +840,7 @@ 
                     self.invalidate()
                 raise
         finally:
-            release(tr, lock, dsguard, wlock)
+            release(tr, lock, wlock)
             self.removeundo(repo)
 
     def _apply(self, repo, series, list=False, update_status=True,
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -127,10 +127,9 @@ 
         diffopts = patch.difffeatureopts(self.ui, opts)
         diffopts.git = True
 
-        lock = wlock = tr = dsguard = None
+        lock = wlock = tr = None
         try:
             wlock = repo.wlock()
-            dsguard = cmdutil.dirstateguard(repo, 'transplant')
             lock = repo.lock()
             tr = repo.transaction('transplant')
             for rev in revs:
@@ -203,7 +202,6 @@ 
                             # Do not rollback, it is up to the user to
                             # fix the merge or cancel everything
                             tr.close()
-                            dsguard.close()
                             raise
                         if n and domerge:
                             self.ui.status(_('%s merged at %s\n') % (revstr,
@@ -216,7 +214,6 @@ 
                         if patchfile:
                             os.unlink(patchfile)
             tr.close()
-            dsguard.close()
             if pulls:
                 exchange.pull(repo, source.peer(), heads=pulls)
                 merge.update(repo, pulls[-1], False, False, None)
@@ -227,8 +224,6 @@ 
                 tr.release()
             if lock:
                 lock.release()
-            if dsguard:
-                dsguard.release()
             wlock.release()
 
     def filter(self, filter, node, changelog, patchfile):
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2461,10 +2461,9 @@ 
     base = old.p1()
     createmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
 
-    wlock = dsguard = lock = newid = None
+    wlock = lock = newid = None
     try:
         wlock = repo.wlock()
-        dsguard = dirstateguard(repo, 'amend')
         lock = repo.lock()
         tr = repo.transaction('amend')
         try:
@@ -2636,7 +2635,6 @@ 
             tr.close()
         finally:
             tr.release()
-        dsguard.close()
         if not createmarkers and newid != old.node():
             # Strip the intermediate commit (if there was one) and the amended
             # commit
@@ -2645,7 +2643,7 @@ 
             ui.note(_('stripping amended changeset %s\n') % old)
             repair.strip(ui, repo, old.node(), topic='amend-backup')
     finally:
-        lockmod.release(lock, dsguard, wlock)
+        lockmod.release(lock, wlock)
     return newid
 
 def commiteditor(repo, ctx, subs, editform=''):