repair: use cg3 for treemanifests stable
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 19 Jan 2016 15:38:24 -0800
branchstable
changeset 29879 7cbb3a01fa38190d986741117a867a2e8586c668
parent 29878 3b2ac2115464477040b21efd10c7ce69c8ba513f
child 29880 1289a122cf3f55ed8c37be11157fe8acf06abfe5
push id175
push usergszorc@mozilla.com
push dateWed, 10 Feb 2016 01:24:28 +0000
repair: use cg3 for treemanifests The newly created helper changegroup.safeversion() knows to pick version 03 if the repo uses treemanifests, so just using that means we pick the right changegroup version.
mercurial/repair.py
tests/test-treemanifest.t
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -17,19 +17,17 @@ from . import (
     changegroup,
     error,
     exchange,
     util,
 )
 
 def _bundle(repo, bases, heads, node, suffix, compress=True):
     """create a bundle with the specified revisions as a backup"""
-    cgversion = '01'
-    if 'generaldelta' in repo.requirements:
-        cgversion = '02'
+    cgversion = changegroup.safeversion(repo)
 
     cg = changegroup.changegroupsubset(repo, bases, heads, 'strip',
                                        version=cgversion)
     backupdir = "strip-backup"
     vfs = repo.vfs
     if not vfs.isdir(backupdir):
         vfs.mkdir(backupdir)
 
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -280,16 +280,27 @@ Turning off treemanifest config has no e
   $ echo 2 > dir1/a
   $ hg --config experimental.treemanifest=False ci -qm 'modify dir1/a'
   $ hg debugindex .hg/store/meta/dir1/00manifest.i
      rev    offset  length  delta linkrev nodeid       p1           p2
        0         0     127     -1       4 064927a0648a 000000000000 000000000000
        1       127     111      0       5 25ecb8cb8618 000000000000 000000000000
        2       238      55      1       6 5b16163a30c6 25ecb8cb8618 000000000000
 
+Stripping and recovering changes should work
+
+  $ hg st --change tip
+  M dir1/a
+  $ hg --config extensions.strip= strip tip
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  saved backup bundle to $TESTTMP/repo-mixed/.hg/strip-backup/51cfd7b1e13b-78a2f3ed-backup.hg (glob)
+  $ hg unbundle -q .hg/strip-backup/*
+  $ hg st --change tip
+  M dir1/a
+
 Create deeper repo with tree manifests.
 
   $ cd ..
   $ hg --config experimental.treemanifest=True init deeprepo
   $ cd deeprepo
 
   $ mkdir a
   $ mkdir b