[PATCH 5 of 6] dirstate: make invalidate aware of pending file

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue May 19 11:42:05 CDT 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1432051569 -32400
#      Wed May 20 01:06:09 2015 +0900
# Node ID 06310e0ab134f1bb45bdebd5d87cfcfca4ca2548
# Parent  32bb772580da70c05822ab830349585f0245ae92
dirstate: make invalidate aware of pending file

When pending file exists, `invalidate()` should remove it, because
part (or all) of changes after last `write()` are still held in it:
remaining it may cause accidental reading it in.

`_removepending()` is defined as a function to reuse it in subsequent
patches.

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -394,6 +394,9 @@
         self._lastnormaltime = 0
         self._dirty = False
         self._parentwriters = 0
+        if self._diverted:
+            # avoid accidental reading '.pending' in
+            self._removepending()
 
     def copy(self, source, dest):
         """Mark dest as a copy of source. Unmark dest if source is None."""
@@ -622,6 +625,14 @@
             return
         self._writedirstate(self._filename)
 
+    def _removepending(self):
+        try:
+            self._opener.unlink(self._pendingfilename)
+        except OSError, e:
+            if e.errno != errno.ENOENT:
+                raise
+        self._diverted = False
+
     def _writepending(self, tr):
         '''Make pending data visible to external processes
 


More information about the Mercurial-devel mailing list