[PATCH STABLE] qfinish: comply with the phases.new-commit option in secret mode (issue3335)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sat Mar 24 06:37:23 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1332587209 -3600
# Branch stable
# Node ID cf9300f46aec00f9afb9d4425ae0dd228a2ac6f4
# Parent  900eee0778d164292dd0045401e14243464cdf29
qfinish: comply with the phases.new-commit option in secret mode (issue3335)

In secret mode qfinished changeset were move to the draft phase in all case[1]
without regard to phases.new-commit value

This changeset ensure qfinish does not automatically promote a changeset
further than the phases.new-commit value.

Note: This may also result in qfinished changeset made public if
phases.new-commit is set to public.

[1] "In all case" where parent have a compatible phase. Qfinish keep never
    altering phases of changeset not involved in the qfinish.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -843,8 +843,9 @@
         if qfinished and repo.ui.configbool('mq', 'secret', False):
             # only use this logic when the secret option is added
             oldqbase = repo[qfinished[0]]
-            if oldqbase.p1().phase() < phases.secret:
-                phases.advanceboundary(repo, phases.draft, qfinished)
+            tphase = repo.ui.config('phases', 'new-commit', phases.draft)
+            if oldqbase.phase() > tphase and oldqbase.p1().phase() <= tphase:
+                phases.advanceboundary(repo, tphase, qfinished)
 
     def delete(self, repo, patches, opts):
         if not patches and not opts.get('rev'):
diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -1474,6 +1474,22 @@
   1: secret
   2: secret
 
+Test that qfinish respect phases.new-commit setting
+
+  $ echo '[phases]' >> $HGRCPATH
+  $ echo 'new-commit=secret' >> $HGRCPATH
+  $ hg qfinish qbase
+  patch add-file2 finalized without changeset message
+  $ hg phase 'all()'
+  0: draft
+  1: secret
+  2: secret
+
+(restore env for next test)
+
+  $ sed -i.bak -e 's/new-commit=secret//' $HGRCPATH
+  $ hg qimport -r 1 --name  add-file2
+
 Test that qfinish preserve phase when mq.secret=false
 
   $ sed -i.bak -e 's/secret=true/secret=false/' $HGRCPATH


More information about the Mercurial-devel mailing list