Patchwork D8126: import: don't ignore `--secret` when `--bypass` is specified

login
register
mail settings
Submitter phabricator
Date Feb. 21, 2020, 9:56 a.m.
Message ID <e41ce310623f61f1f45a377ac8699312@localhost.localdomain>
Download mbox | patch
Permalink /patch/45286/
State Not Applicable
Headers show

Comments

phabricator - Feb. 21, 2020, 9:56 a.m.
Closed by commit rHGb339faf3f843: import: don&#039;t ignore `--secret` when `--bypass` is specified (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8126?vs=20250&id=20267

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8126/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8126

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-import.t

CHANGE DETAILS




To: mharbison72, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/tests/test-import.t b/tests/test-import.t
--- a/tests/test-import.t
+++ b/tests/test-import.t
@@ -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
 
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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: