changeset 23939:33d1b81c6ef0 stable

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
author Eric Sumner <ericsumner@fb.com>
date Wed, 21 Jan 2015 15:54:52 -0800
parents de519517f597
children d0ef40776999
files mercurial/repair.py tests/test-strip.t
diffstat 2 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/repair.py	Wed Jan 21 21:47:27 2015 +0100
+++ b/mercurial/repair.py	Wed Jan 21 15:54:52 2015 -0800
@@ -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'
 
--- a/tests/test-strip.t	Wed Jan 21 21:47:27 2015 +0100
+++ b/tests/test-strip.t	Wed Jan 21 15:54:52 2015 -0800
@@ -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)