Patchwork [1,of,2,v4] context: stop setting None for modified or added nodes

login
register
mail settings
Submitter Augie Fackler
Date Dec. 17, 2014, 1:42 a.m.
Message ID <e94a559756f2c4e17e77.1418780546@130.17.16.172.in-addr.arpa>
Download mbox | patch
Permalink /patch/7136/
State Accepted
Headers show

Comments

Augie Fackler - Dec. 17, 2014, 1:42 a.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1418416194 18000
#      Fri Dec 12 15:29:54 2014 -0500
# Node ID e94a559756f2c4e17e778f9be68e33b380140b7e
# Parent  ebfad9c3ad01862219a326a04a062ea2c25e26d3
context: stop setting None for modified or added nodes

Instead use a modified nullid, so that we can identify modified or
added nodes correctly when using manifest.diff().

Thanks to Martin von Zweigbergk for catching that we have to update
_buildstatus as well. That part eluded my debugging for some time.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -17,6 +17,11 @@  import revlog
 
 propertycache = util.propertycache
 
+# Phony node value to stand-in for new files in some uses of
+# manifests. Manifests support 21-byte hashes for nodes which are
+# dirty in the working copy.
+_newnode = '!' * 21
+
 class basectx(object):
     """A basectx object represents the common logic for its children:
     changectx: read-only context that is already present in the repo,
@@ -104,7 +109,7 @@  class basectx(object):
                 if (fn not in deletedset and
                     ((fn in withflags and mf1.flags(fn) != mf2.flags(fn)) or
                      (mf1[fn] != mf2node and
-                      (mf2node or self[fn].cmp(other[fn]))))):
+                      (mf2node != _newnode or self[fn].cmp(other[fn]))))):
                     modified.append(fn)
                 elif listclean:
                     clean.append(fn)
@@ -1387,7 +1392,7 @@  class workingctx(committablectx):
         """
         mf = self._repo['.']._manifestmatches(match, s)
         for f in s.modified + s.added:
-            mf[f] = None
+            mf[f] = _newnode
             mf.setflag(f, self.flags(f))
         for f in s.removed:
             if f in mf: