Patchwork [17,of,19] basectx: add _matchstatus method for factoring out last of parentworking logic

login
register
mail settings
Submitter Sean Farley
Date May 15, 2014, 9:16 p.m.
Message ID <0770226fad0f8961a755.1400188595@laptop.local>
Download mbox | patch
Permalink /patch/4776/
State Accepted
Commit 2f1567ef70ba258f416d167f0dc48d0de737dd21
Headers show

Comments

Sean Farley - May 15, 2014, 9:16 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1398285570 18000
#      Wed Apr 23 15:39:30 2014 -0500
# Node ID 0770226fad0f8961a755cb516c9e0604c7a4209a
# Parent  5e4e31f7dca07c7883f01e339e1365c882e5d213
basectx: add _matchstatus method for factoring out last of parentworking logic
Pierre-Yves David - May 16, 2014, 12:22 a.m.
On 05/15/2014 02:16 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1398285570 18000
> #      Wed Apr 23 15:39:30 2014 -0500
> # Node ID 0770226fad0f8961a755cb516c9e0604c7a4209a
> # Parent  5e4e31f7dca07c7883f01e339e1365c882e5d213
> basectx: add _matchstatus method for factoring out last of parentworking logic
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -70,10 +70,15 @@ class basectx(object):
>           for fn in mf.keys():
>               if not match(fn):
>                   del mf[fn]
>           return mf
>
> +    def _matchstatus(self, other, s, match, listignored, listclean,
> +                     listunknown):
> +        """return match.always if match is none -- internal use only"""

should be:

   """return match.always if match is none

   internal use only"""

Also the doc-string is completely opaque to me right now.
Sean Farley - May 16, 2014, 1:12 a.m.
Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:

> On 05/15/2014 02:16 PM, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1398285570 18000
>> #      Wed Apr 23 15:39:30 2014 -0500
>> # Node ID 0770226fad0f8961a755cb516c9e0604c7a4209a
>> # Parent  5e4e31f7dca07c7883f01e339e1365c882e5d213
>> basectx: add _matchstatus method for factoring out last of parentworking logic
>>
>> diff --git a/mercurial/context.py b/mercurial/context.py
>> --- a/mercurial/context.py
>> +++ b/mercurial/context.py
>> @@ -70,10 +70,15 @@ class basectx(object):
>>           for fn in mf.keys():
>>               if not match(fn):
>>                   del mf[fn]
>>           return mf
>>
>> +    def _matchstatus(self, other, s, match, listignored, listclean,
>> +                     listunknown):
>> +        """return match.always if match is none -- internal use only"""
>
> should be:
>
>    """return match.always if match is none
>
>    internal use only"""
>
> Also the doc-string is completely opaque to me right now.

This is only to help get rid of the tiny method in localrepo.statu:

def mfmatches(ctx):
    mf = ctx.manifest().copy()
    if match.always():
        return mf
    for fn in mf.keys():
        if not match(fn):
            del mf[fn]
    return mf

Do you have a better suggestion?
Pierre-Yves David - May 16, 2014, 4:08 a.m.
On 05/15/2014 06:12 PM, Sean Farley wrote:
>
> Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:
>
>> On 05/15/2014 02:16 PM, Sean Farley wrote:
>>> # HG changeset patch
>>> # User Sean Farley <sean.michael.farley@gmail.com>
>>> # Date 1398285570 18000
>>> #      Wed Apr 23 15:39:30 2014 -0500
>>> # Node ID 0770226fad0f8961a755cb516c9e0604c7a4209a
>>> # Parent  5e4e31f7dca07c7883f01e339e1365c882e5d213
>>> basectx: add _matchstatus method for factoring out last of parentworking logic
>>>
>>> diff --git a/mercurial/context.py b/mercurial/context.py
>>> --- a/mercurial/context.py
>>> +++ b/mercurial/context.py
>>> @@ -70,10 +70,15 @@ class basectx(object):
>>>            for fn in mf.keys():
>>>                if not match(fn):
>>>                    del mf[fn]
>>>            return mf
>>>
>>> +    def _matchstatus(self, other, s, match, listignored, listclean,
>>> +                     listunknown):
>>> +        """return match.always if match is none -- internal use only"""
>>
>> should be:
>>
>>     """return match.always if match is none
>>
>>     internal use only"""
>>
>> Also the doc-string is completely opaque to me right now.
>
> This is only to help get rid of the tiny method in localrepo.statu:
>
> def mfmatches(ctx):
>      mf = ctx.manifest().copy()
>      if match.always():
>          return mf
>      for fn in mf.keys():
>          if not match(fn):
>              del mf[fn]
>      return mf
>
> Do you have a better suggestion?

Confusion is getting thicker, how is this function related to the other? 
What is the great purpose of the first one?

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -70,10 +70,15 @@  class basectx(object):
         for fn in mf.keys():
             if not match(fn):
                 del mf[fn]
         return mf
 
+    def _matchstatus(self, other, s, match, listignored, listclean,
+                     listunknown):
+        """return match.always if match is none -- internal use only"""
+        return match or matchmod.always(self._repo.root, self._repo.getcwd())
+
     def _prestatus(self, other, s, match, listignored, listclean, listunknown):
         return s
 
     def _poststatus(self, other, s, match, listignored, listclean, listunknown):
         return s