[PATCH 1 of 5] phases: change phase command change detection

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Oct 13 01:33:54 CDT 2014



On 10/09/2014 12:22 PM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1412706697 25200
> #      Tue Oct 07 11:31:37 2014 -0700
> # Node ID 21386e638281d3fe94138c5fb8ea6f6d7aa3a8cd
> # Parent  a1eb21f5caea4366310e32aa85248791d5bbfa0c
> phases: change phase command change detection

I queued that one after moving the comment explaining why we need an 
unfiltered repository next to the first usage of unfiltered repository.

>
> A future patch is going to make phase computation lazy, so the phase command can
> no longer read and diff the entire phase list directly. This changes the phase
> command to build it's own list for diff purposes.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4854,7 +4854,9 @@ def phase(ui, repo, *revs, **opts):
>               if not revs:
>                   raise util.Abort(_('empty revision set'))
>               nodes = [repo[r].node() for r in revs]
> -            olddata = repo._phasecache.getphaserevs(repo)[:]
> +            unfi = repo.unfiltered()
> +            getphase = unfi._phasecache.phase
> +            olddata = [getphase(unfi, r) for r in unfi]
>               phases.advanceboundary(repo, tr, targetphase, nodes)
>               if opts['force']:
>                   phases.retractboundary(repo, tr, targetphase, nodes)
> @@ -4865,9 +4867,9 @@ def phase(ui, repo, *revs, **opts):
>               lock.release()
>           # moving revision from public to draft may hide them
>           # We have to check result on an unfiltered repository
> -        unfi = repo.unfiltered()
> -        newdata = repo._phasecache.getphaserevs(unfi)
> -        changes = sum(o != newdata[i] for i, o in enumerate(olddata))
> +        getphase = unfi._phasecache.phase
> +        newdata = [getphase(unfi, r) for r in unfi]
> +        changes = sum(newdata[r] != olddata[r] for r in unfi)
>           cl = unfi.changelog
>           rejected = [n for n in nodes
>                       if newdata[cl.rev(n)] < targetphase]
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list