Patchwork [5,of,9] repair: make "strip()" treat bundle files via vfs

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 8, 2014, 4:07 p.m.
Message ID <dea46560b9fb70b49611.1394294830@juju>
Download mbox | patch
Permalink /patch/3896/
State Accepted
Commit ad5b61370514e8a72423463a3c21d5691716cabf
Headers show

Comments

Katsunori FUJIWARA - March 8, 2014, 4:07 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1394294608 -32400
#      Sun Mar 09 01:03:28 2014 +0900
# Node ID dea46560b9fb70b49611ed868528deb35457de88
# Parent  d83efbf778355d4a3e1275b3572654ad7db15bd2
repair: make "strip()" treat bundle files via vfs

This patch makes "repair.strip()" treat bundle files via vfs.

This patch also avoids applying "vfs.join()" on the value returned by
"changegroup.writebundle()", to get relative path from "_bundle()".

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -9,7 +9,6 @@ 
 from mercurial import changegroup
 from mercurial.node import short
 from mercurial.i18n import _
-import os
 import errno
 
 def _bundle(repo, bases, heads, node, suffix, compress=True):
@@ -24,7 +23,7 @@ 
         bundletype = "HG10BZ"
     else:
         bundletype = "HG10UN"
-    return vfs.join(changegroup.writebundle(cg, name, bundletype, vfs))
+    return changegroup.writebundle(cg, name, bundletype, vfs)
 
 def _collectfiles(repo, striprev):
     """find out the filelogs affected by the strip"""
@@ -109,10 +108,13 @@ 
 
     # create a changegroup for all the branches we need to keep
     backupfile = None
+    vfs = repo.vfs
     if backup == "all":
         backupfile = _bundle(repo, stripbases, cl.heads(), node, topic)
-        repo.ui.status(_("saved backup bundle to %s\n") % backupfile)
-        repo.ui.log("backupbundle", "saved backup bundle to %s\n", backupfile)
+        repo.ui.status(_("saved backup bundle to %s\n") %
+                       vfs.join(backupfile))
+        repo.ui.log("backupbundle", "saved backup bundle to %s\n",
+                    vfs.join(backupfile))
     if saveheads or savebases:
         # do not compress partial bundle if we remove it from disk later
         chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp',
@@ -142,17 +144,18 @@ 
 
         if saveheads or savebases:
             ui.note(_("adding branch\n"))
-            f = open(chgrpfile, "rb")
-            gen = changegroup.readbundle(f, chgrpfile)
+            f = vfs.open(chgrpfile, "rb")
+            gen = changegroup.readbundle(f, chgrpfile, vfs)
             if not repo.ui.verbose:
                 # silence internal shuffling chatter
                 repo.ui.pushbuffer()
-            repo.addchangegroup(gen, 'strip', 'bundle:' + chgrpfile, True)
+            repo.addchangegroup(gen, 'strip',
+                                'bundle:' + vfs.join(chgrpfile), True)
             if not repo.ui.verbose:
                 repo.ui.popbuffer()
             f.close()
             if not keeppartialbundle:
-                os.unlink(chgrpfile)
+                vfs.unlink(chgrpfile)
 
         # remove undo files
         for undovfs, undofile in repo.undofiles():
@@ -169,10 +172,10 @@ 
     except: # re-raises
         if backupfile:
             ui.warn(_("strip failed, full bundle stored in '%s'\n")
-                    % backupfile)
+                    % vfs.join(backupfile))
         elif saveheads:
             ui.warn(_("strip failed, partial bundle stored in '%s'\n")
-                    % chgrpfile)
+                    % vfs.join(chgrpfile))
         raise
 
     repo.destroyed()