changeset 24671:98ab035e9332

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".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 10 Apr 2015 00:36:42 +0900
parents dfb86af18a35
children dd0b86f740ef
files mercurial/subrepo.py
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Tue Apr 07 15:18:52 2015 -0700
+++ b/mercurial/subrepo.py	Fri Apr 10 00:36:42 2015 +0900
@@ -378,8 +378,18 @@
 
 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 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 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 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()