Patchwork [Bug,5918] New: context.metadataonlyctx doesn't respect the secret phase of the original ctx

login
register
mail settings
Submitter mercurial-bugs@mercurial-scm.org
Date June 14, 2018, 2:41 p.m.
Message ID <bug-5918-285@https.bz.mercurial-scm.org/>
Download mbox | patch
Permalink /patch/32130/
State Not Applicable
Headers show

Comments

mercurial-bugs@mercurial-scm.org - June 14, 2018, 2:41 p.m.
https://bz.mercurial-scm.org/show_bug.cgi?id=5918

            Bug ID: 5918
           Summary: context.metadataonlyctx doesn't respect the secret
                    phase of the original ctx
           Product: Mercurial
           Version: default branch
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: bug
          Priority: normal
         Component: Mercurial
          Assignee: bugzilla@mercurial-scm.org
          Reporter: matt_harbison@yahoo.com
                CC: mercurial-devel@mercurial-scm.org

This was reported to me by somebody who noticed that the phabricator extension
changed a secret cset to draft when it was posted for review.  It looks like
that extension is the only user in the hg repo.  Maybe the ctx class is the
wrong place to handle this, and it should be handled in scmutil.cleanupnodes()?
 Here's a test (without scmutil.cleanupnodes()):

   RuntimeError: can't reuse the manifest: its p1 doesn't match the new ctx p1

Patch

diff --git a/tests/test-context-metadata.t b/tests/test-context-metadata.t
--- a/tests/test-context-metadata.t
+++ b/tests/test-context-metadata.t
@@ -9,7 +9,7 @@  Tests about metadataonlyctx
   $ echo C > C
   $ echo B2 > B
   $ hg add C -q
-  $ hg commit -m 'Remove A'
+  $ hg commit --secret -m 'Remove A'

   $ cat > metaedit.py <<EOF
   > from __future__ import absolute_import
@@ -28,15 +28,16 @@  Tests about metadataonlyctx
   >                                       **pycompat.strkwargs(kwargs))
   >         new.commit()
   > EOF
+  $ hg log -T '{rev}: ({phase}) {desc}\n'
+  2: (secret) Remove A
+  1: (draft) Add B
+  0: (draft) Add A
   $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit
'text=Changed'
-  $ hg log -r tip
-  changeset:   3:ad83e9e00ec9
-  tag:         tip
-  parent:      1:3afb7afe6632
-  user:        test
-  date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     Changed
-
+  $ hg log -T '{rev}: ({phase}) {desc}\n'
+  3: (draft) Changed
+  2: (secret) Remove A
+  1: (draft) Add B
+  0: (draft) Add A
   $ hg --config extensions.metaedit=$TESTTMP/metaedit.py metaedit 'parents=0'
2>&1 | egrep '^RuntimeError'