Patchwork [STABLE] repair._bundle: fix traceback for bad config value

login
register
mail settings
Submitter Eric Sumner
Date Jan. 21, 2015, 11:59 p.m.
Message ID <8a7fac960d9efa3aa8e5.1421884756@dev911.prn1.facebook.com>
Download mbox | patch
Permalink /patch/7533/
State Accepted
Commit 33d1b81c6ef029651954589584dd67d1aebbc110
Headers show

Comments

Eric Sumner - Jan. 21, 2015, 11:59 p.m.
# HG changeset patch
# User Eric Sumner <ericsumner@fb.com>
# Date 1421884492 28800
#      Wed Jan 21 15:54:52 2015 -0800
# Branch stable
# Node ID 8a7fac960d9efa3aa8e52fe7923e58300d504ce0
# Parent  a43fdf33a6beb697945a3dbb7253f0436ea278a6
repair._bundle: fix traceback for bad config value

On IRC, rom1dep reported a traceback[1] from setting
experimental.strip-bundle2-version to True.  This diff catches unexpected values
and falls back to the non-experimental bundle1 implementation after issuing a
warning.

[1] http://gist.tamytro.org/_admin/gists/qXcdQLwtApgy6e3NwWgl
Matt Mackall - Jan. 22, 2015, 9:38 p.m.
On Wed, 2015-01-21 at 15:59 -0800, Eric Sumner wrote:
> # HG changeset patch
> # User Eric Sumner <ericsumner@fb.com>
> # Date 1421884492 28800
> #      Wed Jan 21 15:54:52 2015 -0800
> # Branch stable
> # Node ID 8a7fac960d9efa3aa8e52fe7923e58300d504ce0
> # Parent  a43fdf33a6beb697945a3dbb7253f0436ea278a6
> repair._bundle: fix traceback for bad config value

Queued for stable, thanks.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -17,6 +17,12 @@ 
                   repo.ui.config('experimental', 'strip-bundle2-version'))
     if usebundle2:
         cgversion = repo.ui.config('experimental', 'strip-bundle2-version')
+        if cgversion not in changegroup.packermap:
+            repo.ui.warn(_('unknown strip-bundle2-version value %r; ' +
+                            'should be one of %r\n') %
+                         (cgversion, sorted(changegroup.packermap.keys()),))
+            cgversion = '01'
+            usebundle2 = False
     else:
         cgversion = '01'
 
diff --git a/tests/test-strip.t b/tests/test-strip.t
--- a/tests/test-strip.t
+++ b/tests/test-strip.t
@@ -197,6 +197,16 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     c
   
+  $ hg --config experimental.bundle2-exp=True --config experimental.strip-bundle2-version=INVALID strip 4
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  unknown strip-bundle2-version value 'INVALID'; should be one of ['01', '02']
+  saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob)
+  $ hg debugbundle .hg/strip-backup/*
+  264128213d290d868c54642d13aeaa3675551a78
+  $ restore
+
+  $ hg up -C 4
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg --config experimental.bundle2-exp=True --config experimental.strip-bundle2-version=02 --traceback strip 4
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob)