diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -251,6 +251,19 @@ class patchheader(object): ci += 1 del self.comments[ci] +def secretcommit(repo, *args, **kwargs): + """helper dedicated to ensure a commit are secret + + It should be used instead of repo.commit inside the mq source + """ + backup = repo.ui.backupconfig('phases', 'new-commit') + try: + # ensure we create a secret changeset + repo.ui.setconfig('phases', 'new-commit', phases.secret) + return repo.commit(*args, **kwargs) + finally: + repo.ui.restoreconfig(backup) + class queue(object): def __init__(self, ui, path, patchdir=None): self.basepath = path @@ -553,7 +566,7 @@ class queue(object): ret = hg.merge(repo, rev) if ret: raise util.Abort(_("update returned %d") % ret) - n = repo.commit(ctx.description(), ctx.user(), force=True) + n = secretcommit(repo, ctx.description(), ctx.user(), force=True) if n is None: raise util.Abort(_("repo commit failed")) try: @@ -723,8 +736,8 @@ class queue(object): repo.dirstate.setparents(p1, merge) match = scmutil.matchfiles(repo, files or []) - n = repo.commit(message, ph.user, ph.date, match=match, force=True) - + n = secretcommit(repo, message, ph.user, ph.date, match=match, + force=True) if n is None: raise util.Abort(_("repository commit failed")) @@ -958,7 +971,8 @@ class queue(object): if util.safehasattr(msg, '__call__'): msg = msg() commitmsg = msg and msg or ("[mq]: %s" % patchfn) - n = repo.commit(commitmsg, user, date, match=match, force=True) + n = secretcommit(repo, commitmsg, user, date, match=match, + force=True) if n is None: raise util.Abort(_("repo commit failed")) try: @@ -1500,8 +1514,8 @@ class queue(object): try: # might be nice to attempt to roll back strip after this - n = repo.commit(message, user, ph.date, match=match, - force=True) + n = secretcommit(repo, message, user, ph.date, match=match, + force=True) # only write patch after a successful commit patchf.close() self.applied.append(statusentry(n, patchfn)) diff --git a/tests/test-mq-qclone-http.t b/tests/test-mq-qclone-http.t --- a/tests/test-mq-qclone-http.t +++ b/tests/test-mq-qclone-http.t @@ -43,7 +43,7 @@ test with recursive collection adding changesets adding manifests adding file changes - added 2 changesets with 2 changes to 2 files + added 1 changesets with 1 changes to 1 files requesting all changes adding changesets adding manifests @@ -82,7 +82,7 @@ test with normal collection adding changesets adding manifests adding file changes - added 2 changesets with 2 changes to 2 files + added 1 changesets with 1 changes to 1 files requesting all changes adding changesets adding manifests @@ -121,7 +121,7 @@ test with old-style collection adding changesets adding manifests adding file changes - added 2 changesets with 2 changes to 2 files + added 1 changesets with 1 changes to 1 files requesting all changes adding changesets adding manifests 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 @@ -171,6 +171,11 @@ Pushing applied patch with --force $ hg push --force -r default ../forcepush2 pushing to ../forcepush2 searching for changes + no changes found + $ hg phase -d 'mq()' + $ hg push --force -r default ../forcepush2 + pushing to ../forcepush2 + searching for changes adding changesets adding manifests adding file changes diff --git a/tests/test-mq.t b/tests/test-mq.t --- a/tests/test-mq.t +++ b/tests/test-mq.t @@ -148,8 +148,12 @@ qinit -c should create both files if the $ hg qnew A $ checkundo qnew $ echo foo > foo + $ hg phase -r qbase + 0: secret $ hg add foo $ hg qrefresh + $ hg phase -r qbase + 0: secret $ hg qnew B $ echo >> foo $ hg qrefresh @@ -297,6 +301,8 @@ Dump the tag cache to ensure that it has $ hg qpush applying test.patch now at: test.patch + $ hg phase -r qbase + 2: secret $ hg tags > /dev/null .hg/cache/tags (post qpush): @@ -1207,6 +1213,11 @@ repo with unversioned patch dir repo with patches applied $ hg qclone qclonesource qclonedest + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files updating to branch default 3 files updated, 0 files merged, 0 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved