Patchwork [01,of,10] subrepo: use filesystem APIs via temporary vfs in "hgsubrepo" constrcutor

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 28, 2014, 3 p.m.
Message ID <25cb27f9fa274069475f.1401289213@juju>
Download mbox | patch
Permalink /patch/4884/
State Changes Requested
Headers show

Comments

Katsunori FUJIWARA - May 28, 2014, 3 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1401288802 -32400
#      Wed May 28 23:53:22 2014 +0900
# Node ID 25cb27f9fa274069475fc8d1a129a272d9d7e147
# Parent  652e07debf10193f4973a48ead96a95e81d0a55b
subrepo: use filesystem APIs via temporary vfs in "hgsubrepo" constrcutor
Pierre-Yves David - June 6, 2014, 12:18 a.m.
On 05/28/2014 08:00 AM, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1401288802 -32400
> #      Wed May 28 23:53:22 2014 +0900
> # Node ID 25cb27f9fa274069475fc8d1a129a272d9d7e147
> # Parent  652e07debf10193f4973a48ead96a95e81d0a55b
> subrepo: use filesystem APIs via temporary vfs in "hgsubrepo" constrcutor

Typo in "constrcutor"

My knowledge of subrepo is minimal and my knownledge of vfs is shallow. 
Can you elaborate on why this change is (1) needed (2) safe (3) correct?
Katsunori FUJIWARA - June 6, 2014, 1:24 p.m.
At Thu, 05 Jun 2014 17:18:27 -0700,
Pierre-Yves David wrote:
> 
> On 05/28/2014 08:00 AM, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > # Date 1401288802 -32400
> > #      Wed May 28 23:53:22 2014 +0900
> > # Node ID 25cb27f9fa274069475fc8d1a129a272d9d7e147
> > # Parent  652e07debf10193f4973a48ead96a95e81d0a55b
> > subrepo: use filesystem APIs via temporary vfs in "hgsubrepo" constrcutor
> 
> Typo in "constrcutor"

I'll fix it.

> My knowledge of subrepo is minimal and my knownledge of vfs is shallow. 
> Can you elaborate on why this change is (1) needed (2) safe (3) correct?

(1) Yes, using file API via "vfs" is needed, because specified subrepo
path may have to be used in UTF-8 mode, but (2)/(3) I should use not
newly created vfs but "ctx._repo.wvfs".

I'll fix this problem and write more detailed description.

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -11,7 +11,7 @@  import stat, subprocess, tarfile
 from i18n import _
 import config, util, node, error, cmdutil, bookmarks, match as matchmod
 import phases
-import pathutil
+import pathutil, scmutil
 hg = None
 propertycache = util.propertycache
 
@@ -511,12 +511,12 @@  class hgsubrepo(abstractsubrepo):
         self._path = path
         self._state = state
         r = ctx._repo
-        root = r.wjoin(path)
+        vfs = scmutil.vfs(r.wjoin(path))
         create = False
-        if not os.path.exists(os.path.join(root, '.hg')):
+        if not vfs.exists('.hg'):
             create = True
-            util.makedirs(root)
-        self._repo = hg.repository(r.baseui, root, create=create)
+            vfs.makedirs()
+        self._repo = hg.repository(r.baseui, vfs.base, create=create)
         for s, k in [('ui', 'commitsubrepos')]:
             v = r.ui.config(s, k)
             if v: