[PATCH 14 of 18] phases: ensure secret commit are not exchanged
pierre-yves.david at logilab.fr
pierre-yves.david at logilab.fr
Mon Oct 10 07:28:10 CDT 2011
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1318240443 -7200
# Node ID 245c4b96f7fba86ac5f916d321a1c504b7cb7312
# Parent eb0f9eeafc6f620a749de135c53c89f4cf239e5b
phases: ensure secret commit are not exchanged
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -82,16 +82,32 @@ def prepush(repo, remote, force, revs, n
common, revs = findcommonoutgoing(repo, remote, onlyheads=revs,
commoninc=commoninc, force=force)
_common, inc, remoteheads = commoninc
cl = repo.changelog
- outg = cl.findmissing(common, revs)
+ alloutg = cl.findmissing(common, revs)
+ outg = []
+ secret = []
+ for o in alloutg:
+ if repo.nodephase(o) >= 2:
+ secret.append(o)
+ else:
+ outg.append(o)
if not outg:
- repo.ui.status(_("no changes found\n"))
+ if secret:
+ repo.ui.status(_("no changes to push but %i secret changesets\n")
+ % len(secret))
+ else:
+ repo.ui.status(_("no changes found\n"))
return None, 1, common
+ if secret:
+ # recompute target revs
+ revs = [ctx.node() for ctx in repo.set('heads(::(%ld))',
+ map(repo.changelog.rev, outg))]
+
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:
# - unknown locally
diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -97,11 +97,11 @@ def findcommonheads(ui, local, remote,
roundtrips += 1
ownheads = dag.heads()
sample = ownheads
if remote.local():
# stopgap until we have a proper localpeer that supports batch()
- srvheadhashes = remote.heads()
+ srvheadhashes = list(remote._phasesheads[1])
yesno = remote.known(dag.externalizeall(sample))
elif remote.capable('batch'):
batch = remote.batch()
srvheadhashesref = batch.heads()
yesnoref = batch.known(dag.externalizeall(sample))
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -445,11 +445,11 @@ def getbundle(repo, proto, others):
opts[k] = decodelist(v)
cg = repo.getbundle('serve', **opts)
return streamres(proto.groupchunks(cg))
def heads(repo, proto):
- h = repo.heads()
+ h = repo._phasesheads[1]
return encodelist(h) + "\n"
def hello(repo, proto):
'''the hello command returns a set of lines describing various
interesting things about the server, in an RFC822-like format.
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -108,9 +108,39 @@ XXX do it on merge too
3 0 D
2 0 C
1 0 B
0 0 A
+check secret changeset are not pushed
+ $ hg init ../other
+ $ hg push ../other
+ pushing to ../other
+ searching for changes
+ adding changesets
+ adding manifests
+ adding file changes
+ added 7 changesets with 7 changes to 7 files
+ $ hg push ../other
+ pushing to ../other
+ searching for changes
+ no changes to push but 2 secret changesets
+check secret changeset are not pulled
+# XXX check over the wire
+
+ $ cd ../other
+ $ hg id -n -r tip
+ 6
+ $ hg pull ../initialrepo
+ pulling from ../initialrepo
+ searching for changes
+ no changes found
+
+
+
+
+
+
+
More information about the Mercurial-devel
mailing list