[PATCH 2 of 8 phases] mq: have mq create secret changeset only

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Tue Jan 17 17:35:35 UTC 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1326767583 -3600
# Node ID 56ce840b148b8eaef0b8e6a58f26c9e70dff4e13
# Parent  bea078f4023a0d0e2483ed2c6f87b52cb10f4822
mq: have mq create secret changeset only

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -44,11 +44,11 @@ create other, independent patch queues w
 
 from mercurial.i18n import _
 from mercurial.node import bin, hex, short, nullid, nullrev
 from mercurial.lock import release
 from mercurial import commands, cmdutil, hg, scmutil, util, revset
-from mercurial import repair, extensions, url, error
+from mercurial import repair, extensions, url, error, phases
 from mercurial import patch as patchmod
 import os, re, errno, shutil
 
 commands.norepo += " qclone"
 
@@ -551,11 +551,19 @@ class queue(object):
 
         ctx = repo[rev]
         ret = hg.merge(repo, rev)
         if ret:
             raise util.Abort(_("update returned %d") % ret)
-        n = repo.commit(ctx.description(), ctx.user(), force=True)
+
+        bckdata = repo.ui.backupconfig('phases', 'new-commit')
+        try:
+            # ensure we won't create a secret changeset
+            repo.ui.setconfig('phases', 'new-commit', phases.secret)
+            n = repo.commit(ctx.description(), ctx.user(), force=True)
+        finally:
+            repo.ui.restoreconfig(bckdata)
+
         if n is None:
             raise util.Abort(_("repo commit failed"))
         try:
             ph = patchheader(mergeq.join(patch), self.plainmode)
         except:
@@ -721,11 +729,18 @@ class queue(object):
                     repo.dirstate.merge(f)
                 p1, p2 = repo.dirstate.parents()
                 repo.dirstate.setparents(p1, merge)
 
             match = scmutil.matchfiles(repo, files or [])
-            n = repo.commit(message, ph.user, ph.date, match=match, force=True)
+            bckdata = repo.ui.backupconfig('phases', 'new-commit')
+            try:
+                # ensure we won't create a secret changeset
+                repo.ui.setconfig('phases', 'new-commit', phases.secret)
+                n = repo.commit(message, ph.user, ph.date, match=match,
+                                force=True)
+            finally:
+                repo.ui.restoreconfig(bckdata)
 
             if n is None:
                 raise util.Abort(_("repository commit failed"))
 
             if update_status:
@@ -950,11 +965,18 @@ class queue(object):
                     if date:
                         p.write("# Date %s %s\n\n" % date)
                 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)
+                bckdata = repo.ui.backupconfig('phases', 'new-commit')
+                try:
+                    # ensure we won't create a secret changeset
+                    repo.ui.setconfig('phases', 'new-commit', phases.secret)
+                    n = repo.commit(commitmsg, user, date, match=match,
+                                    force=True)
+                finally:
+                    repo.ui.restoreconfig(bckdata)
                 if n is None:
                     raise util.Abort(_("repo commit failed"))
                 try:
                     self.fullseries[insert:insert] = [patchfn]
                     self.applied.append(statusentry(n, patchfn))
@@ -1492,12 +1514,18 @@ class queue(object):
                 repo.dirstate.invalidate()
                 raise
 
             try:
                 # might be nice to attempt to roll back strip after this
-                n = repo.commit(message, user, ph.date, match=match,
-                                force=True)
+                bckdata = repo.ui.backupconfig('phases', 'new-commit')
+                try:
+                    # ensure we won't create a secret changeset
+                    repo.ui.setconfig('phases', 'new-commit', phases.secret)
+                    n = repo.commit(message, user, ph.date, match=match,
+                                    force=True)
+                finally:
+                    repo.ui.restoreconfig(bckdata)
                 # only write patch after a successful commit
                 patchf.close()
                 self.applied.append(statusentry(n, patchfn))
             except:
                 ctx = repo[cparents[0]]
diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -146,12 +146,16 @@ qinit -c should create both files if the
   $ hg init e
   $ cd e
   $ 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
   $ echo status >> .hg/patches/.hgignore
   $ echo bleh >> .hg/patches/.hgignore
@@ -295,10 +299,12 @@ Dump the tag cache to ensure that it has
   1 [\da-f]{40} (re)
   
   $ hg qpush
   applying test.patch
   now at: test.patch
+  $ hg phase -r qbase
+  2: secret
   $ hg tags > /dev/null
 
 .hg/cache/tags (post qpush):
 
   $ cat .hg/cache/tags



More information about the Mercurial-devel mailing list