Patchwork [02,of,11] subrepo: replace "os.path.exists" by "exists" via wvfs of the parent

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Nov. 19, 2014, 9:41 a.m.
Message ID <a19ee70858778a179d46.1416390107@juju>
Download mbox | patch
Permalink /patch/6788/
State Accepted
Commit 83736508e98adf276ab7285ab4b022f5818eefa0
Headers show

Comments

Katsunori FUJIWARA - Nov. 19, 2014, 9:41 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1416389714 -32400
#      Wed Nov 19 18:35:14 2014 +0900
# Node ID a19ee70858778a179d46d1985e7260d3f1b9deed
# Parent  875adfca30b3cfc89c3530ae1c580f3f10bb342c
subrepo: replace "os.path.exists" by "exists" via wvfs of the parent

Existance of specified "path" should be examined by "exists" via wvfs
of the parent repository, because the working directory of the parent
repository may be in UTF-8 mode. Wide API should be used via wvfs in
such case.

In this patch, "/" is used as the path separator, even though "path"
uses platform specific path separator (e.g. "\\" on Windows). But it
is reasonable enough, because "store" and other management file
handling already include such implementation, and they work well.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -522,7 +522,7 @@  class hgsubrepo(abstractsubrepo):
         self._state = state
         r = ctx._repo
         root = r.wjoin(path)
-        create = not os.path.exists(os.path.join(root, '.hg'))
+        create = not r.wvfs.exists('%s/.hg' % path)
         self._repo = hg.repository(r.baseui, root, create=create)
         for s, k in [('ui', 'commitsubrepos')]:
             v = r.ui.config(s, k)