[PATCH 3 of 5] outgoing: add a 'missingroots' argument

Yuya Nishihara yuya at tcha.org
Sun Aug 14 05:18:34 EDT 2016


On Thu, 11 Aug 2016 22:06:53 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1470774698 -7200
> #      Tue Aug 09 22:31:38 2016 +0200
> # Node ID 8c4fcb1244bdf79caadadc73fc1e489a160a07ec
> # Parent  9ff7059253fd00094799f592462590cd837fb457
> # EXP-Topic outgoing
> outgoing: add a 'missingroots' argument
> 
> This argument can be used instead of 'commonheads' to determine the 'outgoing'
> set. We remove the outgoingbetween function as its role can now be handled by
> 'outgoing' itself.
> 
> I've thought of using an external function instead of making the constructor
> more complicated. However, there is low hanging fruit to improve the current
> code flow by storing some side products of the processing of 'missingroots'. So
> in my opinion it make senses to add all this to the class.

> --- a/mercurial/discovery.py	Tue Aug 09 15:55:44 2016 +0200
> +++ b/mercurial/discovery.py	Tue Aug 09 22:31:38 2016 +0200
> @@ -76,11 +76,25 @@ class outgoing(object):
>      The sets are computed on demand from the heads, unless provided upfront
>      by discovery.'''
>  
> -    def __init__(self, repo, commonheads=None, missingheads=None):
> +    def __init__(self, repo, commonheads=None, missingheads=None,
> +                 missingroots=None):
> +        # at least one of them must not be set
> +        assert None in (commonheads, missingroots)
>          cl = repo.changelog
>          if not missingheads:
>              missingheads = cl.heads()
> -        if not commonheads:
> +        if missingroots:
> +            discbases = []
> +            for n in missingroots:
> +                discbases.extend([p for p in cl.parents(n) if p != nullid])
> +            # TODO remove call to nodesbetween.
> +            # TODO populate attributes on outgoing instance instead of setting
> +            # discbases.
> +            csets, roots, heads = cl.nodesbetween(missingroots, missingheads)
> +            included = set(csets)
> +            missingheads = heads
> +            commonheads = [n for n in discbases if n not in included]
> +        elif not commonheads:
>              commonheads = [nullid]
>          self.commonheads = commonheads
>          self.missingheads = missingheads
> @@ -106,27 +120,6 @@ class outgoing(object):
>              self._computecommonmissing()
>          return self._missing
>  
> -def outgoingbetween(repo, roots, heads):
> -    """create an ``outgoing`` consisting of nodes between roots and heads
> -
> -    The ``missing`` nodes will be descendants of any of the ``roots`` and
> -    ancestors of any of the ``heads``, both are which are defined as a list
> -    of binary nodes.
> -    """

I can't tell if this is an improvement or not, but the overall changes look
good to me. I'll let Greg or Augie take 2nd pass.


More information about the Mercurial-devel mailing list