Patchwork copytrace: use ctx.mutable() instead of adhoc constant of non-public phases

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 27, 2017, 12:33 p.m.
Message ID <bf17b694881c47015c02.1506515628@mimosa>
Download mbox | patch
Permalink /patch/24179/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 27, 2017, 12:33 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1506087902 -32400
#      Fri Sep 22 22:45:02 2017 +0900
# Node ID bf17b694881c47015c02f006a788b469c399f3eb
# Parent  1826d695ad58194cdc90876699ed44cbdf792fda
copytrace: use ctx.mutable() instead of adhoc constant of non-public phases
Pulkit Goyal - Sept. 28, 2017, 6:56 a.m.
LGTM. Thanks Yuya for cleaning this up.

On Wed, Sep 27, 2017 at 6:03 PM, Yuya Nishihara <yuya@tcha.org> wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1506087902 -32400
> #      Fri Sep 22 22:45:02 2017 +0900
> # Node ID bf17b694881c47015c02f006a788b469c399f3eb
> # Parent  1826d695ad58194cdc90876699ed44cbdf792fda
> copytrace: use ctx.mutable() instead of adhoc constant of non-public phases
>
> diff --git a/mercurial/copies.py b/mercurial/copies.py
> --- a/mercurial/copies.py
> +++ b/mercurial/copies.py
> @@ -15,7 +15,6 @@ from . import (
>      match as matchmod,
>      node,
>      pathutil,
> -    phases,
>      scmutil,
>      util,
>  )
> @@ -368,9 +367,9 @@ def mergecopies(repo, c1, c2, base):
>      if copytracing == 'off':
>          return {}, {}, {}, {}, {}
>      elif copytracing == 'heuristics':
> -        # Do full copytracing if only drafts are involved as that will be fast
> -        # enough and will also cover the copies which can be missed by
> -        # heuristics
> +        # Do full copytracing if only non-public revisions are involved as
> +        # that will be fast enough and will also cover the copies which could
> +        # be missed by heuristics
>          if _isfullcopytraceable(repo, c1, base):
>              return _fullcopytracing(repo, c1, c2, base)
>          return _heuristicscopytracing(repo, c1, c2, base)
> @@ -378,16 +377,13 @@ def mergecopies(repo, c1, c2, base):
>          return _fullcopytracing(repo, c1, c2, base)
>
>  def _isfullcopytraceable(repo, c1, base):
> -    """ Checks that if base, source and destination are all draft branches, if
> -    yes let's use the full copytrace algorithm for increased capabilities since
> -    it will be fast enough.
> +    """ Checks that if base, source and destination are all no-public branches,
> +    if yes let's use the full copytrace algorithm for increased capabilities
> +    since it will be fast enough.
>      """
>      if c1.rev() is None:
>          c1 = c1.p1()
> -
> -    nonpublicphases = set([phases.draft, phases.secret])
> -
> -    if (c1.phase() in nonpublicphases) and (base.phase() in nonpublicphases):
> +    if c1.mutable() and base.mutable():
>          sourcecommitlimit = repo.ui.configint('experimental',
>                                                'copytrace.sourcecommitlimit')
>          commits = len(repo.revs('%d::%d', base.rev(), c1.rev()))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler - Sept. 30, 2017, 1:51 p.m.
> On Sep 28, 2017, at 07:56, Pulkit Goyal <7895pulkit@gmail.com> wrote:
> 
> LGTM. Thanks Yuya for cleaning this up.

Queued, thanks


> 
> On Wed, Sep 27, 2017 at 6:03 PM, Yuya Nishihara <yuya@tcha.org> wrote:
>> # HG changeset patch
>> # User Yuya Nishihara <yuya@tcha.org>
>> # Date 1506087902 -32400
>> #      Fri Sep 22 22:45:02 2017 +0900
>> # Node ID bf17b694881c47015c02f006a788b469c399f3eb
>> # Parent  1826d695ad58194cdc90876699ed44cbdf792fda
>> copytrace: use ctx.mutable() instead of adhoc constant of non-public phases
>> 
>> diff --git a/mercurial/copies.py b/mercurial/copies.py
>> --- a/mercurial/copies.py
>> +++ b/mercurial/copies.py
>> @@ -15,7 +15,6 @@ from . import (
>>     match as matchmod,
>>     node,
>>     pathutil,
>> -    phases,
>>     scmutil,
>>     util,
>> )
>> @@ -368,9 +367,9 @@ def mergecopies(repo, c1, c2, base):
>>     if copytracing == 'off':
>>         return {}, {}, {}, {}, {}
>>     elif copytracing == 'heuristics':
>> -        # Do full copytracing if only drafts are involved as that will be fast
>> -        # enough and will also cover the copies which can be missed by
>> -        # heuristics
>> +        # Do full copytracing if only non-public revisions are involved as
>> +        # that will be fast enough and will also cover the copies which could
>> +        # be missed by heuristics
>>         if _isfullcopytraceable(repo, c1, base):
>>             return _fullcopytracing(repo, c1, c2, base)
>>         return _heuristicscopytracing(repo, c1, c2, base)
>> @@ -378,16 +377,13 @@ def mergecopies(repo, c1, c2, base):
>>         return _fullcopytracing(repo, c1, c2, base)
>> 
>> def _isfullcopytraceable(repo, c1, base):
>> -    """ Checks that if base, source and destination are all draft branches, if
>> -    yes let's use the full copytrace algorithm for increased capabilities since
>> -    it will be fast enough.
>> +    """ Checks that if base, source and destination are all no-public branches,
>> +    if yes let's use the full copytrace algorithm for increased capabilities
>> +    since it will be fast enough.
>>     """
>>     if c1.rev() is None:
>>         c1 = c1.p1()
>> -
>> -    nonpublicphases = set([phases.draft, phases.secret])
>> -
>> -    if (c1.phase() in nonpublicphases) and (base.phase() in nonpublicphases):
>> +    if c1.mutable() and base.mutable():
>>         sourcecommitlimit = repo.ui.configint('experimental',
>>                                               'copytrace.sourcecommitlimit')
>>         commits = len(repo.revs('%d::%d', base.rev(), c1.rev()))
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -15,7 +15,6 @@  from . import (
     match as matchmod,
     node,
     pathutil,
-    phases,
     scmutil,
     util,
 )
@@ -368,9 +367,9 @@  def mergecopies(repo, c1, c2, base):
     if copytracing == 'off':
         return {}, {}, {}, {}, {}
     elif copytracing == 'heuristics':
-        # Do full copytracing if only drafts are involved as that will be fast
-        # enough and will also cover the copies which can be missed by
-        # heuristics
+        # Do full copytracing if only non-public revisions are involved as
+        # that will be fast enough and will also cover the copies which could
+        # be missed by heuristics
         if _isfullcopytraceable(repo, c1, base):
             return _fullcopytracing(repo, c1, c2, base)
         return _heuristicscopytracing(repo, c1, c2, base)
@@ -378,16 +377,13 @@  def mergecopies(repo, c1, c2, base):
         return _fullcopytracing(repo, c1, c2, base)
 
 def _isfullcopytraceable(repo, c1, base):
-    """ Checks that if base, source and destination are all draft branches, if
-    yes let's use the full copytrace algorithm for increased capabilities since
-    it will be fast enough.
+    """ Checks that if base, source and destination are all no-public branches,
+    if yes let's use the full copytrace algorithm for increased capabilities
+    since it will be fast enough.
     """
     if c1.rev() is None:
         c1 = c1.p1()
-
-    nonpublicphases = set([phases.draft, phases.secret])
-
-    if (c1.phase() in nonpublicphases) and (base.phase() in nonpublicphases):
+    if c1.mutable() and base.mutable():
         sourcecommitlimit = repo.ui.configint('experimental',
                                               'copytrace.sourcecommitlimit')
         commits = len(repo.revs('%d::%d', base.rev(), c1.rev()))