changeset 15068:73307643a09f

repair: switch from changegroupsubset to getbundle This is in preparation of deprecating changegroupsubset.
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Thu, 01 Sep 2011 12:29:24 +0200
parents cc16323e748d
children 650d81a313cb
files mercurial/repair.py
diffstat 1 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/repair.py	Tue Aug 30 15:22:10 2011 +0200
+++ b/mercurial/repair.py	Thu Sep 01 12:29:24 2011 +0200
@@ -11,9 +11,8 @@
 from mercurial.i18n import _
 import os
 
-def _bundle(repo, bases, heads, node, suffix, compress=True):
+def _bundle(repo, cg, node, suffix, compress=True):
     """create a bundle with the specified revisions as a backup"""
-    cg = repo.changegroupsubset(bases, heads, 'strip')
     backupdir = repo.join("strip-backup")
     if not os.path.isdir(backupdir):
         os.mkdir(backupdir)
@@ -83,11 +82,9 @@
             saveheads.add(r)
     saveheads = [cl.node(r) for r in saveheads]
 
-    # compute base nodes
-    if saverevs:
-        descendants = set(cl.descendants(*saverevs))
-        saverevs.difference_update(descendants)
-    savebases = [cl.node(r) for r in saverevs]
+    # compute common nodes
+    savecommon = set(cl.node(p) for r in saverevs for p in cl.parentrevs(r)
+                     if p not in saverevs and p not in tostrip)
 
     bm = repo._bookmarks
     updatebm = []
@@ -99,12 +96,14 @@
     # create a changegroup for all the branches we need to keep
     backupfile = None
     if backup == "all":
-        backupfile = _bundle(repo, [node], cl.heads(), node, 'backup')
+        allnodes=[cl.node(r) for r in xrange(striprev, len(cl))]
+        cg = repo._changegroup(allnodes, 'strip')
+        backupfile = _bundle(repo, cg, node, 'backup')
         repo.ui.status(_("saved backup bundle to %s\n") % backupfile)
-    if saveheads or savebases:
+    if saveheads or savecommon:
         # do not compress partial bundle if we remove it from disk later
-        chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp',
-                            compress=keeppartialbundle)
+        cg = repo.getbundle('strip', common=savecommon, heads=saveheads)
+        chgrpfile = _bundle(repo, cg, node, 'temp', compress=keeppartialbundle)
 
     mfst = repo.manifest
 
@@ -128,7 +127,7 @@
             tr.abort()
             raise
 
-        if saveheads or savebases:
+        if saveheads or savecommon:
             ui.note(_("adding branch\n"))
             f = open(chgrpfile, "rb")
             gen = changegroup.readbundle(f, chgrpfile)