Patchwork [1,of,5,VFS] subrepo: change arguments of abstractsubrepo.__init__ (API)

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 9, 2015, 3:51 p.m.
Message ID <cf6135c3e2c7d3695e33.1428594674@juju>
Download mbox | patch
Permalink /patch/8576/
State Accepted
Commit 98ab035e9332c3a805e3c8fca3b061de185b3725
Headers show

Comments

Katsunori FUJIWARA - April 9, 2015, 3:51 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1428593802 -32400
#      Fri Apr 10 00:36:42 2015 +0900
# Node ID cf6135c3e2c7d3695e33e853d82d48aa53c0a041
# Parent  19c5b091396036e2ee63555b39a5852652b49d18
subrepo: change arguments of abstractsubrepo.__init__ (API)

This patch passes "ctx" and "path" instead of "ui" to
"abstractsubrepo.__init__()" and stores them as "_ctx" and "_path" to
use them in subsequent patches.

This also removes redundant field initializations in the constructor
of classes derived from "abstractsubrepo".

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -378,8 +378,18 @@  def newcommitphase(ui, ctx):
 
 class abstractsubrepo(object):
 
-    def __init__(self, ui):
-        self.ui = ui
+    def __init__(self, ctx, path):
+        """Initialize abstractsubrepo part
+
+        ``ctx`` is the context referring this subrepository in the
+        parent repository.
+
+        ``path`` is the path to this subrepositiry as seen from
+        innermost repository.
+        """
+        self.ui = ctx.repo().ui
+        self._ctx = ctx
+        self._path = path
 
     def storeclean(self, path):
         """
@@ -544,10 +554,8 @@  class abstractsubrepo(object):
 
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
-        super(hgsubrepo, self).__init__(ctx.repo().ui)
-        self._path = path
+        super(hgsubrepo, self).__init__(ctx, path)
         self._state = state
-        self._ctx = ctx
         r = ctx.repo()
         root = r.wjoin(path)
         create = not r.wvfs.exists('%s/.hg' % path)
@@ -938,10 +946,8 @@  class hgsubrepo(abstractsubrepo):
 
 class svnsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
-        super(svnsubrepo, self).__init__(ctx.repo().ui)
-        self._path = path
+        super(svnsubrepo, self).__init__(ctx, path)
         self._state = state
-        self._ctx = ctx
         self._exe = util.findexe('svn')
         if not self._exe:
             raise util.Abort(_("'svn' executable not found for subrepo '%s'")
@@ -1168,10 +1174,8 @@  class svnsubrepo(abstractsubrepo):
 
 class gitsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
-        super(gitsubrepo, self).__init__(ctx.repo().ui)
+        super(gitsubrepo, self).__init__(ctx, path)
         self._state = state
-        self._ctx = ctx
-        self._path = path
         self._relpath = os.path.join(reporelpath(ctx.repo()), path)
         self._abspath = ctx.repo().wjoin(path)
         self._subparent = ctx.repo()