Patchwork [2,of,2] debugcommands: issue warning when repo has secret changesets (issue5589)

login
register
mail settings
Submitter Gregory Szorc
Date June 9, 2017, 5:49 p.m.
Message ID <58addecd0d1a750ebcbc.1497030572@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/21290/
State Accepted
Headers show

Comments

Gregory Szorc - June 9, 2017, 5:49 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1497030139 25200
#      Fri Jun 09 10:42:19 2017 -0700
# Node ID 58addecd0d1a750ebcbc176317d56fec4bb79d04
# Parent  9e4e3022c76912d5d0efd8b93b90854d0abbfbbf
debugcommands: issue warning when repo has secret changesets (issue5589)

This seems like a prudent thing to do. As the inline comment says,
we may want to make this abort once the functionality is stabilized
as part of `hg bundle`. Let's save that debate for another day.
Augie Fackler - June 9, 2017, 6:11 p.m.
On Fri, Jun 09, 2017 at 10:49:32AM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1497030139 25200
> #      Fri Jun 09 10:42:19 2017 -0700
> # Node ID 58addecd0d1a750ebcbc176317d56fec4bb79d04
> # Parent  9e4e3022c76912d5d0efd8b93b90854d0abbfbbf
> debugcommands: issue warning when repo has secret changesets (issue5589)

queued, thanks

Patch

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -47,6 +47,7 @@  from . import (
     lock as lockmod,
     merge as mergemod,
     obsolete,
+    phases,
     policy,
     pvec,
     pycompat,
@@ -421,6 +422,12 @@  def debugcreatestreamclonebundle(ui, rep
     Stream bundles are special bundles that are essentially archives of
     revlog files. They are commonly used for cloning very quickly.
     """
+    # TODO we may want to turn this into an abort when this functionality
+    # is moved into `hg bundle`.
+    if phases.hassecret(repo):
+        ui.warn(_('(warning: stream clone bundle will contain secret '
+                  'revisions)\n'))
+
     requirements, gen = streamclone.generatebundlev1(repo)
     changegroup.writechunks(ui, gen, fname)
 
diff --git a/tests/test-bundle.t b/tests/test-bundle.t
--- a/tests/test-bundle.t
+++ b/tests/test-bundle.t
@@ -302,6 +302,20 @@  generaldelta requirement is not listed i
   $ hg debugbundle --spec packednongd.hg
   none-packed1;requirements%3Drevlogv1
 
+Warning emitted when packed bundles contain secret changesets
+
+  $ hg init testsecret
+  $ cd testsecret
+  $ touch foo
+  $ hg -q commit -A -m initial
+  $ hg phase --force --secret -r .
+  $ cd ..
+
+  $ hg -R testsecret debugcreatestreamclonebundle packedsecret.hg
+  (warning: stream clone bundle will contain secret revisions)
+  writing 301 bytes for 3 files
+  bundle requirements: generaldelta, revlogv1
+
 Unpacking packed1 bundles with "hg unbundle" isn't allowed
 
   $ hg init packed