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

login
register
mail settings
Submitter Augie Fackler
Date Dec. 15, 2014, 5:59 p.m.
Message ID <85f3187042f6fe3db123.1418666397@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/7116/
State Superseded
Headers show

Comments

Augie Fackler - Dec. 15, 2014, 5:59 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1418416194 18000
#      Fri Dec 12 15:29:54 2014 -0500
# Node ID 85f3187042f6fe3db123b17b87f4f0b290a47c02
# Parent  65c854f92d6ba8861414ff3191182fba28777a82
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.
Pierre-Yves David - Dec. 15, 2014, 6:45 p.m.
On 12/15/2014 09:59 AM, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1418416194 18000
> #      Fri Dec 12 15:29:54 2014 -0500
> # Node ID 85f3187042f6fe3db123b17b87f4f0b290a47c02
> # Parent  65c854f92d6ba8861414ff3191182fba28777a82
> context: stop setting None for modified or added nodes

IS this related to the recent change from IOError to None for deleted 
file that mads did or is this a distinct logic?


>
> 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.
>
> 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:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
Augie Fackler - Dec. 15, 2014, 6:48 p.m.
On Dec 15, 2014, at 1:45 PM, Pierre-Yves David <pierre-yves.david@ens-lyon.org> wrote:

> 
> 
> On 12/15/2014 09:59 AM, Augie Fackler wrote:
>> # HG changeset patch
>> # User Augie Fackler <augie@google.com>
>> # Date 1418416194 18000
>> #      Fri Dec 12 15:29:54 2014 -0500
>> # Node ID 85f3187042f6fe3db123b17b87f4f0b290a47c02
>> # Parent  65c854f92d6ba8861414ff3191182fba28777a82
>> context: stop setting None for modified or added nodes
> 
> IS this related to the recent change from IOError to None for deleted file that mads did or is this a distinct logic?

As far as I can tell this is completely unrelated.

> 
> 
>> 
>> 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.
>> 
>> 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:
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>> 
> 
> -- 
> Pierre-Yves David

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: