Patchwork [1,of,9] localrepo: make "undofiles()" return list of tuples "(vfs, relative filename)"

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 8, 2014, 4:07 p.m.
Message ID <d7aaef55c418c693aa67.1394294826@juju>
Download mbox | patch
Permalink /patch/3894/
State Accepted
Commit 37cdf1fca1b27ae970c7d5ea9a6abf5f39d95c6f
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 d7aaef55c418c693aa67dc7f105b673535c370b3
# Parent  19e9478c1a2245b6b5b4b2882efee5261d7df963
localrepo: make "undofiles()" return list of tuples "(vfs, relative filename)"

Before this patch, "localrepository.undofiles()" returns list of
absolute filename of undo files.

This patch makes it return list of tuples "(vfs, relative filename)"
to access undo files via vfs.

This patch also changes "repair.strip()", which is the only user of
"localrepository.undofiles()".

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -842,7 +842,7 @@ 
                 (self.svfs, 'journal.phaseroots'))
 
     def undofiles(self):
-        return [vfs.join(undoname(x)) for vfs, x in self._journalfiles()]
+        return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
 
     def _writejournal(self, desc):
         self.opener.write("journal.dirstate",
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -154,12 +154,13 @@ 
                 os.unlink(chgrpfile)
 
         # remove undo files
-        for undofile in repo.undofiles():
+        for undovfs, undofile in repo.undofiles():
             try:
-                os.unlink(undofile)
+                undovfs.unlink(undofile)
             except OSError, e:
                 if e.errno != errno.ENOENT:
-                    ui.warn(_('error removing %s: %s\n') % (undofile, str(e)))
+                    ui.warn(_('error removing %s: %s\n') %
+                            (undovfs.join(undofile), str(e)))
 
         for m in updatebm:
             bm[m] = repo[newbmtarget].node()