[PATCH 4 of 5 REVIEW] phases: mark content pushed as public in local repo on push

Matt Mackall mpm at selenic.com
Fri Oct 21 15:39:58 UTC 2011


On Fri, 2011-10-21 at 15:32 +0200, Pierre-Yves David wrote:
> New diff for this files.
> 
> The initial use of a generator was a micro optimisation to avoid computing the
> set if not necessary. I dropped it. future have been renamed to futureheads
> (should have been renamed futurecommonheads but…)
> 
> 
> diff --git a/mercurial/discovery.py b/mercurial/discovery.py
> --- a/mercurial/discovery.py
> +++ b/mercurial/discovery.py
> @@ -64,30 +64,33 @@ def findcommonoutgoing(repo, other, only
>  def prepush(repo, remote, force, revs, newbranch):
>      '''Analyze the local and remote repositories and determine which
>      changesets need to be pushed to the remote. Return value depends
>      on circumstances:
>  
> -    If we are not going to push anything, return a tuple (None,
> -    outgoing) where outgoing is 0 if there are no outgoing
> -    changesets and 1 if there are, but we refuse to push them
> -    (e.g. would create new remote heads).
> +    If we are not going to push anything, return a tuple (None, outgoing,
> +    common) where outgoing is 0 if there are no outgoing changesets and 1 if
> +    there are, but we refuse to push them (e.g. would create new remote heads).
> +    common are the list of heads of the common set between local and remote.
>  
> -    Otherwise, return a tuple (changegroup, remoteheads), where
> -    changegroup is a readable file-like object whose read() returns
> -    successive changegroup chunks ready to be sent over the wire and
> -    remoteheads is the list of remote heads.'''
> +    Otherwise, return a tuple (changegroup, remoteheads, futureheads), where
> +    changegroup is a readable file-like object whose read() returns successive
> +    changegroup chunks ready to be sent over the wire and remoteheads is the
> +    list of remote heads. futureheads heads ot the common set between local and
> +    remote to be after push completion.
> +
> +    '''
>      commoninc = findcommonincoming(repo, remote, force=force)
>      common, revs = findcommonoutgoing(repo, remote, onlyheads=revs,
>                                        commoninc=commoninc, force=force)
>      _common, inc, remoteheads = commoninc
>  
>      cl = repo.changelog
>      outg = cl.findmissing(common, revs)
>  
>      if not outg:
>          repo.ui.status(_("no changes found\n"))
> -        return None, 1
> +        return None, 1, common
>  
>      if not force and remoteheads != [nullid]:
>          if remote.capable('branchmap'):
>              # Check for each named branch if we're creating new remote heads.
>              # To be a remote head after push, node must be either:
> @@ -187,6 +190,13 @@ def prepush(repo, remote, force, revs, n
>      if revs is None:
>          # use the fast path, no race possible on push
>          cg = repo._changegroup(outg, 'push')
>      else:
>          cg = repo.getbundle('push', heads=revs, common=common)
> -    return cg, remoteheads
> +    # no need to compute outg ancestor. All node in outg have either:
> +    # - parents in outg
> +    # - parents in common
> +    # - nullid parent
> +    from itertools import chain

Ugh, no, not itertools. And demandloading means you never do imports
like this.

> +    rset = repo.set('heads(%ln)', chain(common, outg))

I really can't see why this is an improvement on my proposal? What does
this do that

 repo.set('heads(%ln or %ln)', common, outg)

doesn't do except require itertools?

> +    futureheads = [ctx.node() for ctx in rset]
> +    return cg, remoteheads, futureheads
> 
> 


-- 
Mathematics is the supreme nostalgia of our time.





More information about the Mercurial-devel mailing list