Patchwork [01,of,11] subrepo: avoid redundant "util.makedirs" invocation

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Nov. 19, 2014, 9:41 a.m.
Message ID <875adfca30b3cfc89c35.1416390106@juju>
Download mbox | patch
Permalink /patch/6789/
State Accepted
Commit 55525924af43e98521c6f8880a6702963cfb18e6
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 875adfca30b3cfc89c3530ae1c580f3f10bb342c
# Parent  e63941631a3f61b3323dbcc2545689b1eb34e308
subrepo: avoid redundant "util.makedirs" invocation

"util.makedirs" for the (sub-)repository root of "hgsubrepo" is also
executed in the constructor of "localrepository", if "create" is True
and ".hg" of it doesn't exist.

This patch avoids redundant "util.makedirs" invocation in the
constructor of "hgsubrepo".

Patch

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