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

Matt Mackall mpm at selenic.com
Wed Oct 19 17:31:44 CDT 2011


On Wed, 2011-10-19 at 12:27 +0200, pierre-yves.david at logilab.fr wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1319019902 -7200
> # Node ID 1628f433553660bf9e4d01ed4adb6dd5d31dfb30
> # Parent  678353d217a1b96d3771cac1c6e81ca831d6546b
> phases: mark content pushed as public in local repo on push.
> 
> 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,
> +    future) 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).
>  
> -    Otherwise, return a tuple (changegroup, remoteheads), where
> +    Otherwise, return a tuple (changegroup, remoteheads, future), 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.'''
> +    remoteheads is the list of remote heads.
> +    
> +    In both case, future are the heads of the common set between local and
> +    remote after the operation.
> +    '''
>      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,10 @@ 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 set ancestor are all outg have parent in common or outg

Missing comma?

> +    future = map(repo.changelog.rev, common)
> +    future.extend(map(repo.changelog.rev, outg))
> +    future = (ctx.node()  for ctx in  repo.set('heads((%ld))', future))

(double spaces?)
formatspec already supplies extra parens here. Do you really mean to use
a generator expression here?

Is there a reason not to just do:

future = [ctx.node() for ctx in 
          repo.set("heads(%ln or %ln)", common, outg)]

?

For that matter, we could simply do:

future = repo.set("heads(%ln or %ln)", common, outg)

..and let moveboundary deal in contexts instead.

Also, I'm not sure what 'future' is supposed to be telling me here.

> +    return cg, remoteheads, future
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1532,12 +1532,12 @@ class localrepository(repo.repository):
>          lock = None
>          unbundle = remote.capable('unbundle')
>          if not unbundle:
>              lock = remote.lock()
>          try:
> -            cg, remote_heads = discovery.prepush(self, remote, force, revs,
> -                                                 newbranch)
> +            cg, remote_heads, fut = discovery.prepush(self, remote, force,
> +                                                       revs, newbranch)
>              ret = remote_heads
>              if cg is not None:
>                  if unbundle:
>                      # local repo finds heads on server, finds out what
>                      # revs it must push. once revs transferred, if server
> @@ -1550,10 +1550,13 @@ class localrepository(repo.repository):
>                      ret = remote.unbundle(cg, remote_heads, 'push')
>                  else:
>                      # we return an integer indicating remote head count change
>                      ret = remote.addchangegroup(cg, 'push', self.url(),
>                                                  lock=lock)
> +            # if we don't push, the common data is already useful
> +            # everything exchange is public for now
> +            phases.moveboundary(self, 0, fut)
>          finally:
>              if lock is not None:
>                  lock.release()
>  
>          self.ui.debug("checking for updated bookmarks\n")
> diff --git a/tests/test-phases-exchange.t b/tests/test-phases-exchange.t
> --- a/tests/test-phases-exchange.t
> +++ b/tests/test-phases-exchange.t
> @@ -28,10 +28,16 @@
>    searching for changes
>    adding changesets
>    adding manifests
>    adding file changes
>    added 2 changesets with 2 changes to 2 files
> +  $ hgph
> +  3 1 a-D
> +  2 1 a-C
> +  1 0 a-B
> +  0 0 a-A
> +
>    $ cd ../beta
>    $ hgph
>    1 0 a-B
>    0 0 a-A
>    $ hg up -q
> @@ -53,6 +59,24 @@
>    3 0 a-C
>    2 1 b-A
>    1 0 a-B
>    0 0 a-A
>  
> +pull did not updated ../alpha state.
> +push from alpha to beta should update phase even if nothing is transfered
>  
> +  $ cd ../alpha
> +  $ hgph # not updated by remote pull
> +  3 1 a-D
> +  2 1 a-C
> +  1 0 a-B
> +  0 0 a-A
> +  $ hg push ../beta
> +  pushing to ../beta
> +  searching for changes
> +  no changes found
> +  $ hgph
> +  3 0 a-D
> +  2 0 a-C
> +  1 0 a-B
> +  0 0 a-A
> +


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list