--- a/hgext/mq.py Wed Feb 08 16:56:00 2012 +0000
+++ b/hgext/mq.py Tue Feb 07 18:47:13 2012 +0100
@@ -257,21 +257,23 @@
ci += 1
del self.comments[ci]
-def secretcommit(repo, *args, **kwargs):
+def secretcommit(repo, phase, *args, **kwargs):
"""helper dedicated to ensure a commit are secret
It should be used instead of repo.commit inside the mq source
"""
- if not repo.ui.configbool('mq', 'secret', False):
- return repo.commit(*args, **kwargs)
-
- backup = repo.ui.backupconfig('phases', 'new-commit')
+ if phase is None:
+ if repo.ui.configbool('mq', 'secret', False):
+ phase = phases.secret
+ if phase is not None:
+ backup = repo.ui.backupconfig('phases', 'new-commit')
try:
- # ensure we create a secret changeset
- repo.ui.setconfig('phases', 'new-commit', phases.secret)
+ if phase is not None:
+ repo.ui.setconfig('phases', 'new-commit', phase)
return repo.commit(*args, **kwargs)
finally:
- repo.ui.restoreconfig(backup)
+ if phase is not None:
+ repo.ui.restoreconfig(backup)
class queue(object):
def __init__(self, ui, path, patchdir=None):
@@ -575,7 +577,7 @@
ret = hg.merge(repo, rev)
if ret:
raise util.Abort(_("update returned %d") % ret)
- n = secretcommit(repo, ctx.description(), ctx.user(), force=True)
+ n = secretcommit(repo, None, ctx.description(), ctx.user(), force=True)
if n is None:
raise util.Abort(_("repo commit failed"))
try:
@@ -615,7 +617,7 @@
# the first patch in the queue is never a merge patch
#
pname = ".hg.patches.merge.marker"
- n = repo.commit('[mq]: merge marker', force=True)
+ n = secretcommit(repo, None, '[mq]: merge marker', force=True)
self.removeundo(repo)
self.applied.append(statusentry(n, pname))
self.applieddirty = True
@@ -746,7 +748,7 @@
match = scmutil.matchfiles(repo, files or [])
oldtip = repo['tip']
- n = secretcommit(repo, message, ph.user, ph.date, match=match,
+ n = secretcommit(repo, None, message, ph.user, ph.date, match=match,
force=True)
if repo['tip'] == oldtip:
raise util.Abort(_("qpush exactly duplicates child changeset"))
@@ -987,7 +989,7 @@
if util.safehasattr(msg, '__call__'):
msg = msg()
commitmsg = msg and msg or ("[mq]: %s" % patchfn)
- n = secretcommit(repo, commitmsg, user, date, match=match,
+ n = secretcommit(repo, None, commitmsg, user, date, match=match,
force=True)
if n is None:
raise util.Abort(_("repo commit failed"))
@@ -1539,15 +1541,11 @@
try:
# might be nice to attempt to roll back strip after this
- backup = repo.ui.backupconfig('phases', 'new-commit')
- try:
- # Ensure we create a new changeset in the same phase than
- # the old one.
- repo.ui.setconfig('phases', 'new-commit', oldphase)
- n = repo.commit(message, user, ph.date, match=match,
- force=True)
- finally:
- repo.ui.restoreconfig(backup)
+
+ # Ensure we create a new changeset in the same phase than
+ # the old one.
+ n = secretcommit(repo, oldphase, message, user, ph.date,
+ match=match, force=True)
# only write patch after a successful commit
patchf.close()
self.applied.append(statusentry(n, patchfn))