Patchwork [3,of,9] repair: make paths in "_bundle()" relative to ".hg"

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 8, 2014, 4:07 p.m.
Message ID <8143677ddaf90d349886.1394294828@juju>
Download mbox | patch
Permalink /patch/3891/
State Accepted
Commit a57dcd11be3407518cccc24d0f3a0d2b4c5301cd
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 8143677ddaf90d3498861ab4030f7cddc88623a3
# Parent  84dd852c71cae8f871996179ba6ee1e487ab9f6b
repair: make paths in "_bundle()" relative to ".hg"

This patch makes paths below in "_bundle()" relative to ".hg":

  - backup directory ("strip-backup"), and
  - bundle file under backup directory

"vfs" is passed to "changegroup.writebundle()" to use relative path
directly.

This patch applies "vfs.join()" on the value returned by "_bundle()",
because the caller expect it to return absolute path.

This will be changed by succeeding patch changing the caller side.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -15,15 +15,16 @@ 
 def _bundle(repo, bases, heads, 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)
-    name = os.path.join(backupdir, "%s-%s.hg" % (short(node), suffix))
+    backupdir = "strip-backup"
+    vfs = repo.vfs
+    if not vfs.isdir(backupdir):
+        vfs.mkdir(backupdir)
+    name = "%s/%s-%s.hg" % (backupdir, short(node), suffix)
     if compress:
         bundletype = "HG10BZ"
     else:
         bundletype = "HG10UN"
-    return changegroup.writebundle(cg, name, bundletype)
+    return vfs.join(changegroup.writebundle(cg, name, bundletype, vfs))
 
 def _collectfiles(repo, striprev):
     """find out the filelogs affected by the strip"""