[PATCH 9 of 9 phases] push: add switch to push of secret changeset
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Jan 17 23:37:50 UTC 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1326843379 -3600
# Node ID b925bc13c8573b1c917837a134769b141194fc01
# Parent e9a4231e8343298eca129dd00b4c3e8652b6ae2d
push: add switch to push of secret changeset
Implement the ability to include secret changeset in discovery and a switch
to turn this on during push.
diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -401,7 +401,8 @@
finally:
wlock.release()
- def push(self, remote, force=False, revs=None, newbranch=False):
+ def push(self, remote, force=False, revs=None, newbranch=False,
+ includesecret=False):
o = lfutil.findoutgoing(repo, remote, force)
if o:
toupload = set()
@@ -432,7 +433,7 @@
if lfutil.isstandin(f) and f in ctx]))
lfcommands.uploadlfiles(ui, self, remote, toupload)
return super(lfiles_repo, self).push(remote, force, revs,
- newbranch)
+ newbranch, includesecret)
repo.__class__ = lfiles_repo
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -3160,8 +3160,8 @@
return super(mqrepo, self).commit(text, user, date, match, force,
editor, extra)
- def checkpush(self, force, revs):
- if self.mq.applied and not force:
+ def checkpush(self, force, revs, includesecret=False):
+ if self.mq.applied and not includesecret:
haspatches = True
if revs:
# Assume applied patches have no non-patch descendants
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4372,6 +4372,7 @@
('b', 'branch', [],
_('a specific branch you would like to push'), _('BRANCH')),
('', 'new-branch', False, _('allow pushing a new branch')),
+ ('', 'secret', False, _('also push secret changeset')),
] + remoteopts,
_('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
def push(ui, repo, dest=None, **opts):
@@ -4433,7 +4434,8 @@
finally:
del repo._subtoppath
result = repo.push(other, opts.get('force'), revs=revs,
- newbranch=opts.get('new_branch'))
+ newbranch=opts.get('new_branch'),
+ includesecret=opts.get('secret'))
result = (result == 0)
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -86,7 +86,8 @@
self._computecommonmissing()
return self._missing
-def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None):
+def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None,
+ includesecret=False):
'''Return an outgoing instance to identify the nodes present in repo but
not in other.
@@ -105,7 +106,7 @@
og.commonheads, _any, _hds = commoninc
# compute outgoing
- if not repo._phaseroots[phases.secret]:
+ if includesecret or not repo._phaseroots[phases.secret]:
og.missingheads = onlyheads or repo.heads()
elif onlyheads is None:
# use visible heads as it should be cached
@@ -132,7 +133,7 @@
return og
-def prepush(repo, remote, force, revs, newbranch):
+def prepush(repo, remote, force, revs, newbranch, includesecret):
'''Analyze the local and remote repositories and determine which
changesets need to be pushed to the remote. Return value depends
on circumstances:
@@ -150,7 +151,8 @@
'''
commoninc = findcommonincoming(repo, remote, force=force)
outgoing = findcommonoutgoing(repo, remote, onlyheads=revs,
- commoninc=commoninc, force=force)
+ commoninc=commoninc, force=force,
+ includesecret=includesecret)
_common, inc, remoteheads = commoninc
cl = repo.changelog
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1572,14 +1572,15 @@
return result
- def checkpush(self, force, revs):
+ def checkpush(self, force, revs, includesecret=False):
"""Extensions can override this function if additional checks have
to be performed before pushing, or call it if they override push
command.
"""
pass
- def push(self, remote, force=False, revs=None, newbranch=False):
+ def push(self, remote, force=False, revs=None, newbranch=False,
+ includesecret=False):
'''Push outgoing changesets (limited by revs) from the current
repository to remote. Return an integer:
- 0 means HTTP error *or* nothing to push
@@ -1595,7 +1596,7 @@
# unbundle assumes local user cannot lock remote repo (new ssh
# servers, http servers).
- self.checkpush(force, revs)
+ self.checkpush(force, revs, includesecret=includesecret)
lock = None
unbundle = remote.capable('unbundle')
if not unbundle:
@@ -1604,8 +1605,9 @@
# get local lock as we might write phase data
locallock = self.lock()
try:
- cg, remote_heads, fut = discovery.prepush(self, remote, force,
- revs, newbranch)
+ dr = discovery.prepush(self, remote, force, revs, newbranch,
+ includesecret)
+ cg, remote_heads, fut = dr
ret = remote_heads
# create a callback for addchangegroup.
# If will be used branch of the conditionnal too.
diff --git a/tests/test-check-code-hg.t b/tests/test-check-code-hg.t
--- a/tests/test-check-code-hg.t
+++ b/tests/test-check-code-hg.t
@@ -443,9 +443,6 @@
mercurial/discovery.py:0:
> If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive)
warning: line over 80 characters
- mercurial/discovery.py:0:
- > def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None):
- warning: line over 80 characters
mercurial/dispatch.py:0:
> " (.hg not found)") % os.getcwd())
warning: line over 80 characters
diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t
+++ b/tests/test-debugcomplete.t
@@ -201,7 +201,7 @@
merge: force, rev, preview, tool
phase: public, draft, secret, force, rev
pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
- push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
+ push: force, rev, bookmark, branch, new-branch, secret, ssh, remotecmd, insecure
remove: after, force, include, exclude
serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos
diff --git a/tests/test-mq-safety.t b/tests/test-mq-safety.t
--- a/tests/test-mq-safety.t
+++ b/tests/test-mq-safety.t
@@ -166,9 +166,9 @@
adding file changes
added 1 changesets with 1 changes to 1 files
-Pushing applied patch with --force
+Pushing applied patch with --secret
- $ hg push --force -r default ../forcepush2
+ $ hg push --secret -r default ../forcepush2
pushing to ../forcepush2
searching for changes
adding changesets
More information about the Mercurial-devel
mailing list