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

login
register
mail settings
Submitter Augie Fackler
Date Dec. 15, 2014, 3:22 p.m.
Message ID <58e93de9c73de47de64c.1418656964@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/7115/
State Superseded
Headers show

Comments

Augie Fackler - Dec. 15, 2014, 3:22 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1418416194 18000
#      Fri Dec 12 15:29:54 2014 -0500
# Node ID 58e93de9c73de47de64c45a1eb18d60de9604198
# Parent  c03a59470e54c421af683b1fda35852dab6d3014
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,8 @@  import revlog
 
 propertycache = util.propertycache
 
+_newnode = nullid + '!'
+
 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 +106,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 is not _newnode or self[fn].cmp(other[fn]))))):
                     modified.append(fn)
                 elif listclean:
                     clean.append(fn)
@@ -1387,7 +1389,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: