Patchwork [1,of,5] phases: change phase command change detection

login
register
mail settings
Submitter Durham Goode
Date Oct. 9, 2014, 7:22 p.m.
Message ID <21386e638281d3fe9413.1412882559@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6168/
State Accepted
Headers show

Comments

Durham Goode - Oct. 9, 2014, 7:22 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1412706697 25200
#      Tue Oct 07 11:31:37 2014 -0700
# Node ID 21386e638281d3fe94138c5fb8ea6f6d7aa3a8cd
# Parent  a1eb21f5caea4366310e32aa85248791d5bbfa0c
phases: change phase command change detection

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.
Durham Goode - Oct. 9, 2014, 7:26 p.m.
On 10/9/14 12:22 PM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1412706697 25200
> #      Tue Oct 07 11:31:37 2014 -0700
> # Node ID 21386e638281d3fe94138c5fb8ea6f6d7aa3a8cd
> # Parent  a1eb21f5caea4366310e32aa85248791d5bbfa0c
> phases: change phase command change detection
>
This is the first of 3 series that will make phase calculations lazy, 
and redo computehidden calculations to have a better big O. The sum 
total of which will shave several hundred milliseconds off of various 
commands when there are hidden commits in large repos.

This first series doesn't introduce any performance wins, but puts bits 
in place for the next series.
Pierre-Yves David - Oct. 10, 2014, 6:14 a.m.
On 10/09/2014 12:26 PM, Durham Goode wrote:
>
> On 10/9/14 12:22 PM, Durham Goode wrote:
>> # HG changeset patch
>> # User Durham Goode <durham@fb.com>
>> # Date 1412706697 25200
>> #      Tue Oct 07 11:31:37 2014 -0700
>> # Node ID 21386e638281d3fe94138c5fb8ea6f6d7aa3a8cd
>> # Parent  a1eb21f5caea4366310e32aa85248791d5bbfa0c
>> phases: change phase command change detection
>>
> This is the first of 3 series that will make phase calculations lazy,
> and redo computehidden calculations to have a better big O. The sum
> total of which will shave several hundred milliseconds off of various
> commands when there are hidden commits in large repos.
>
> This first series doesn't introduce any performance wins, but puts bits
> in place for the next series.

I'm planning to look at this soon™
Pierre-Yves David - Oct. 13, 2014, 6:33 a.m.
On 10/09/2014 12:22 PM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@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]
>

Patch

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]