[PATCH 05 of 12] phases: make _filterunknown a member function of phasecache

Kevin Bullock kbullock+mercurial at ringworld.org
Mon Dec 17 11:12:46 CST 2012


On Dec 17, 2012, at 9:35 AM, Idan Kamara wrote:

> # HG changeset patch
> # User Idan Kamara <idankk86 at gmail.com>
> # Date 1355682488 -7200
> # Branch stable
> # Node ID ded30a7d2cc2d32e20bf6a14b9579e10210a0673
> # Parent  aa6a85e47fb4edc705959da93fb024aef56dafd4
> 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
> @@ -110,24 +110,6 @@
> trackedphases = allphases[1:]
> phasenames = ['public', 'draft', 'secret']
> 
> -def _filterunknown(ui, changelog, phaseroots):
> -    """remove unknown nodes from the phase boundary
> -
> -    Nothing is lost as unknown nodes only hold data for their descendants.
> -    """
> -    updated = False
> -    nodemap = changelog.nodemap # to filter unknown nodes
> -    for phase, nodes in enumerate(phaseroots):
> -        missing = [node for node in nodes if node not in nodemap]
> -        if missing:
> -            for mnode in missing:
> -                ui.debug(
> -                    'removing unknown node %s from %i-phase boundary\n'
> -                    % (short(mnode), phase))
> -            nodes.symmetric_difference_update(missing)
> -            updated = True
> -    return updated
> -
> def _readroots(repo, phasedefaults=None):
>     """Read phase roots from disk
> 
> @@ -156,8 +138,6 @@
>             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):
> @@ -165,6 +145,7 @@
>         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
> 
> @@ -264,6 +245,26 @@
>             self._updateroots(targetphase, currentroots)
>         obsolete.clearobscaches(repo)
> 
> +    def filterunknown(self, repo):

This adds yet another method to the phasecache that takes a 'repo' argument. Would it be appropriate to make the constructor keep a handle on the repo?

pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
Kevin R. Bullock



More information about the Mercurial-devel mailing list