dirstate: make dirstate.write() callers pass transaction object to it
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sat, 17 Oct 2015 01:15:34 +0900
changeset 26748 5ba0a99ff27f
parent 26747 beff0b2481b3
child 26749 4a82cb5c1dc8
dirstate: make dirstate.write() callers pass transaction object to it Now, 'dirstate.write(tr)' delays writing in-memory changes out, if a transaction is running. This may cause treating this revision as "the first bad one" at bisecting in some cases using external hook process inside transaction scope, because some external hooks and editor process are still invoked without HG_PENDING and pending changes aren't visible to them. 'dirstate.write()' callers below in localrepo.py explicitly use 'None' as 'tr', because they can assume that no transaction is running: - just before starting transaction - at closing transaction, or - at unlocking wlock
contrib/perf.py
hgext/rebase.py
hgext/strip.py
mercurial/context.py
mercurial/localrepo.py
mercurial/merge.py
--- a/contrib/perf.py	Sat Oct 17 01:15:34 2015 +0900
+++ b/contrib/perf.py	Sat Oct 17 01:15:34 2015 +0900
@@ -222,7 +222,7 @@
     "a" in ds
     def d():
         ds._dirty = True
-        ds.write()
+        ds.write(repo.currenttransaction())
     timer(d)
     fm.end()
 
--- a/hgext/rebase.py	Sat Oct 17 01:15:34 2015 +0900
+++ b/hgext/rebase.py	Sat Oct 17 01:15:34 2015 +0900
@@ -628,7 +628,7 @@
         merge.update(repo, p1, False, True, False)
     else:
         repo.ui.debug(" already in target\n")
-    repo.dirstate.write()
+    repo.dirstate.write(repo.currenttransaction())
     repo.ui.debug(" merge against %d:%s\n" % (rev, repo[rev]))
     if base is not None:
         repo.ui.debug("   detach base %d:%s\n" % (base, repo[base]))
--- a/hgext/strip.py	Sat Oct 17 01:15:34 2015 +0900
+++ b/hgext/strip.py	Sat Oct 17 01:15:34 2015 +0900
@@ -58,7 +58,7 @@
                 and p2 in [x.node for x in repo.mq.applied]):
                 urev = p2
             hg.clean(repo, urev)
-            repo.dirstate.write()
+            repo.dirstate.write(repo.currenttransaction())
 
         repair.strip(ui, repo, revs, backup)
 
@@ -205,7 +205,7 @@
             changedfiles.extend(dirchanges)
 
             repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles)
-            repo.dirstate.write()
+            repo.dirstate.write(repo.currenttransaction())
 
             # clear resolve state
             ms = merge.mergestate(repo)
--- a/mercurial/context.py	Sat Oct 17 01:15:34 2015 +0900
+++ b/mercurial/context.py	Sat Oct 17 01:15:34 2015 +0900
@@ -1324,7 +1324,7 @@
         # write changes out explicitly, because nesting wlock at
         # runtime may prevent 'wlock.release()' in 'repo.commit()'
         # from immediately doing so for subsequent changing files
-        self._repo.dirstate.write()
+        self._repo.dirstate.write(self._repo.currenttransaction())
 
 class workingctx(committablectx):
     """A workingctx object makes access to data related to
@@ -1530,7 +1530,7 @@
                     # write changes out explicitly, because nesting
                     # wlock at runtime may prevent 'wlock.release()'
                     # below from doing so for subsequent changing files
-                    self._repo.dirstate.write()
+                    self._repo.dirstate.write(self._repo.currenttransaction())
                 finally:
                     wlock.release()
             except error.LockError:
--- a/mercurial/localrepo.py	Sat Oct 17 01:15:34 2015 +0900
+++ b/mercurial/localrepo.py	Sat Oct 17 01:15:34 2015 +0900
@@ -977,7 +977,7 @@
                 hint=_("run 'hg recover' to clean up transaction"))
 
         # make journal.dirstate contain in-memory changes at this point
-        self.dirstate.write()
+        self.dirstate.write(None)
 
         idbase = "%.40f#%f" % (random.random(), time.time())
         txnid = 'TXN:' + util.sha1(idbase).hexdigest()
@@ -1005,7 +1005,7 @@
                 # transaction, if tr.addfilegenerator (via
                 # dirstate.write or so) isn't invoked while
                 # transaction running
-                repo.dirstate.write()
+                repo.dirstate.write(None)
             else:
                 # prevent in-memory changes from being written out at
                 # the end of outer wlock scope or so
@@ -1319,7 +1319,7 @@
             if self.dirstate.pendingparentchange():
                 self.dirstate.invalidate()
             else:
-                self.dirstate.write()
+                self.dirstate.write(None)
 
             self._filecache['dirstate'].refresh()
 
--- a/mercurial/merge.py	Sat Oct 17 01:15:34 2015 +0900
+++ b/mercurial/merge.py	Sat Oct 17 01:15:34 2015 +0900
@@ -1277,7 +1277,7 @@
     # drop the second merge parent
     repo.dirstate.beginparentchange()
     repo.setparents(repo['.'].node(), nullid)
-    repo.dirstate.write()
+    repo.dirstate.write(repo.currenttransaction())
     # fix up dirstate for copies and renames
     copies.duplicatecopies(repo, ctx.rev(), pctx.rev())
     repo.dirstate.endparentchange()