Patchwork [7,of,7] checkheads: simplify the code around obsolescence post-processing

login
register
mail settings
Submitter Pierre-Yves David
Date June 3, 2017, 8:06 a.m.
Message ID <54ef0920630de5f0c3c6.1496477190@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21154/
State Accepted
Headers show

Comments

Pierre-Yves David - June 3, 2017, 8:06 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1496028210 -7200
#      Mon May 29 05:23:30 2017 +0200
# Node ID 54ef0920630de5f0c3c666dbb30a73b1adcb91ec
# Parent  e3c199932c9c84037a05ffe817838a5a4bd6f5a8
# EXP-Topic pushrace
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 54ef0920630d
checkheads: simplify the code around obsolescence post-processing

The 'discardedheads' return become unused and the relationship between newheads
and newhs can be clarified. Our next goal here is to be able to extract the
_postprocessobsolete call outside of the loop.

We keep returning the 'discardedheads' because we'll start using it again soon
in this series.
Yuya Nishihara - June 4, 2017, 2:14 p.m.
On Sat, 03 Jun 2017 10:06:30 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1496028210 -7200
> #      Mon May 29 05:23:30 2017 +0200
> # Node ID 54ef0920630de5f0c3c666dbb30a73b1adcb91ec
> # Parent  e3c199932c9c84037a05ffe817838a5a4bd6f5a8
> # EXP-Topic pushrace
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 54ef0920630d
> checkheads: simplify the code around obsolescence post-processing

Looks good to me. Queued these, thanks.

> diff --git a/mercurial/discovery.py b/mercurial/discovery.py
> --- a/mercurial/discovery.py
> +++ b/mercurial/discovery.py
> @@ -347,13 +347,10 @@ def checkheads(pushop):
>              oldhs = set(remoteheads)
>          oldhs.update(unsyncedheads)
>          dhs = None # delta heads, the new heads on branch
> -        if not repo.obsstore:
> -            discardedheads = set()
> -            newhs = set(newheads)
> -        else:
> -            newhs, discardedheads = _postprocessobsolete(pushop,
> -                                                         allfuturecommon,
> -                                                         newheads)
> +        if repo.obsstore:
> +            result = _postprocessobsolete(pushop, allfuturecommon, newheads)
> +            newheads = sorted(result[0])

sorted() result is unused now, but maybe it would be necessary in future patch?
Pierre-Yves David - June 4, 2017, 2:31 p.m.
On 06/04/2017 04:14 PM, Yuya Nishihara wrote:
> On Sat, 03 Jun 2017 10:06:30 +0200, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@octobus.net>
>> # Date 1496028210 -7200
>> #      Mon May 29 05:23:30 2017 +0200
>> # Node ID 54ef0920630de5f0c3c666dbb30a73b1adcb91ec
>> # Parent  e3c199932c9c84037a05ffe817838a5a4bd6f5a8
>> # EXP-Topic pushrace
>> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
>> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 54ef0920630d
>> checkheads: simplify the code around obsolescence post-processing
>
> Looks good to me. Queued these, thanks.
>
>> diff --git a/mercurial/discovery.py b/mercurial/discovery.py
>> --- a/mercurial/discovery.py
>> +++ b/mercurial/discovery.py
>> @@ -347,13 +347,10 @@ def checkheads(pushop):
>>              oldhs = set(remoteheads)
>>          oldhs.update(unsyncedheads)
>>          dhs = None # delta heads, the new heads on branch
>> -        if not repo.obsstore:
>> -            discardedheads = set()
>> -            newhs = set(newheads)
>> -        else:
>> -            newhs, discardedheads = _postprocessobsolete(pushop,
>> -                                                         allfuturecommon,
>> -                                                         newheads)
>> +        if repo.obsstore:
>> +            result = _postprocessobsolete(pushop, allfuturecommon, newheads)
>> +            newheads = sorted(result[0])
>
> sorted() result is unused now, but maybe it would be necessary in future patch?

Yes, it is here for consistency since the initial "newheads" (fed to the 
postprocessing) was sorted too. This will get more relevant when the 
post processsing is moved earlier in the function (in the next batch)

Cheers

Patch

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -347,13 +347,10 @@  def checkheads(pushop):
             oldhs = set(remoteheads)
         oldhs.update(unsyncedheads)
         dhs = None # delta heads, the new heads on branch
-        if not repo.obsstore:
-            discardedheads = set()
-            newhs = set(newheads)
-        else:
-            newhs, discardedheads = _postprocessobsolete(pushop,
-                                                         allfuturecommon,
-                                                         newheads)
+        if repo.obsstore:
+            result = _postprocessobsolete(pushop, allfuturecommon, newheads)
+            newheads = sorted(result[0])
+        newhs = set(newheads)
         newhs.update(unsyncedheads)
         if unsyncedheads:
             if None in unsyncedheads: