[PATCH 09 of 18 V2] phases: make _filterunknown a member function of phasecache

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Jan 3 22:57:03 CST 2013


On 4 janv. 2013, at 05:40, Kevin Bullock wrote:

> On 3 Jan 2013, at 10:21 PM, Pierre-Yves David wrote:
> 
>> On 4 janv. 2013, at 05:16, Kevin Bullock wrote:
>> 
>>> On 3 Jan 2013, at 7:04 PM, Pierre-Yves David wrote:
>>> 
>>>> # HG changeset patch
>>>> # User Idan Kamara <idankk86 at gmail.com>
>>>> # Date 1355682488 -7200
>>>> # Node ID 733b35c15776bb62518cf3e544022d41e717b7d7
>>>> # Parent  f33473072cb625b64b9ded2d4eb054f42c735a6c
>>>> phases: make _filterunknown a member function of phasecache
>>>> 
>>>> We'd like the ability to call filterunknown on an existing phasecache
>>>> instance after nodes are destroyed.
>>>> 
>>>> diff --git a/mercurial/phases.py b/mercurial/phases.py
>>>> --- a/mercurial/phases.py
>>>> +++ b/mercurial/phases.py
>>>> [...]
>>>> @@ -154,19 +136,18 @@ def _readroots(repo, phasedefaults=None)
>>>>          raise
>>>>      if phasedefaults:
>>>>          for f in phasedefaults:
>>>>              roots = f(repo, roots)
>>>>      dirty = True
>>>> -    if _filterunknown(repo.ui, repo.changelog, roots):
>>>> -        dirty = True
>>>>  return roots, dirty
>>>> 
>>>> class phasecache(object):
>>>>  def __init__(self, repo, phasedefaults, _load=True):
>>>>      if _load:
>>>>          # Cheap trick to allow shallow-copy without copy module
>>>>          self.phaseroots, self.dirty = _readroots(repo, phasedefaults)
>>>> +            self.filterunknown(repo)
>>>>          self.opener = repo.sopener
>>>>          self._phaserevs = None
>>> Is this line still necessary after we've folded it into filterunknown below?
>> 
>> Very much.
>> (1) The function is moved on the object.
>> (2) the function call is moved from _readroots to the _readroots caller: __init__
> 
> I meant the repeated 'self._phaserevs = None' line.

I would move it before the filterunknown call. I hate object that use attribute not declared in the __init__

-- 
Pierre-Yves


More information about the Mercurial-devel mailing list