import: don't ignore `--secret` when `--bypass` is specified stable
authorMatt Harbison <matt_harbison@yahoo.com>
Sun, 16 Feb 2020 17:05:18 -0500
branchstable
changeset 44330 b339faf3f843
parent 44329 d1177d39012e
child 44331 2527c10a2569
import: don't ignore `--secret` when `--bypass` is specified Differential Revision: https://phab.mercurial-scm.org/D8126
mercurial/cmdutil.py
tests/test-import.t
--- a/mercurial/cmdutil.py	Tue Feb 18 13:46:10 2020 -0500
+++ b/mercurial/cmdutil.py	Sun Feb 16 17:05:18 2020 -0500
@@ -1898,7 +1898,12 @@
                 branch=branch,
                 editor=editor,
             )
-            n = memctx.commit()
+
+            overrides = {}
+            if opts.get(b'secret'):
+                overrides[(b'phases', b'new-commit')] = b'secret'
+            with repo.ui.configoverride(overrides, b'import'):
+                n = memctx.commit()
         finally:
             store.close()
     if opts.get(b'exact') and nocommit:
--- a/tests/test-import.t	Tue Feb 18 13:46:10 2020 -0500
+++ b/tests/test-import.t	Sun Feb 16 17:05:18 2020 -0500
@@ -478,6 +478,12 @@
   +line 2
   $ hg --cwd b phase
   1: secret
+  $ hg --cwd b --config extensions.strip= strip 1 --no-backup --quiet
+  $ hg --cwd b import --bypass --secret ../exported-tip.patch
+  applying ../exported-tip.patch
+  $ hg --cwd b phase -r tip
+  1: secret
+  $ hg --cwd b --config extensions.strip= strip 1 --no-backup --quiet
   $ rm -r b