Patchwork [7,of,7,VFS] subrepo: use vfs.removedirs instead of os.removedirs

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 10, 2015, 3:54 p.m.
Message ID <731246645142b169152c.1428681269@juju>
Download mbox | patch
Permalink /patch/8597/
State Accepted
Commit f282db2834f9f67f71e708b982b774c7672a7eea
Headers show

Comments

Katsunori FUJIWARA - April 10, 2015, 3:54 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1428680829 -32400
#      Sat Apr 11 00:47:09 2015 +0900
# Node ID 731246645142b169152cba8ef6b6d235a53bdf28
# Parent  2316afa88e37a93d3455d30d38dbe4fe994034cd
subrepo: use vfs.removedirs instead of os.removedirs

This patch also removes useless composing absolute path by "repo.wjoin()".
Matt Mackall - April 10, 2015, 9:01 p.m.
On Sat, 2015-04-11 at 00:54 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1428680829 -32400
> #      Sat Apr 11 00:47:09 2015 +0900
> # Node ID 731246645142b169152cba8ef6b6d235a53bdf28
> # Parent  2316afa88e37a93d3455d30d38dbe4fe994034cd
> subrepo: use vfs.removedirs instead of os.removedirs

These are queued for default, thanks.

> +            self._ctx.repo().wvfs.removedirs(os.path.dirname(self._path))

Looks like we'll need dirname/basename methods in addition to vfs.split.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1115,10 +1115,9 @@  class svnsubrepo(abstractsubrepo):
             return
         self.ui.note(_('removing subrepo %s\n') % self._path)
 
-        path = self._ctx.repo().wjoin(self._path)
         self.wvfs.rmtree(forcibly=True)
         try:
-            os.removedirs(os.path.dirname(path))
+            self._ctx.repo().wvfs.removedirs(os.path.dirname(self._path))
         except OSError:
             pass