subrepo: change arguments of abstractsubrepo.__init__ (API)
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 10 Apr 2015 00:36:42 +0900
changeset 24671 98ab035e9332
parent 24670 dfb86af18a35
child 24672 dd0b86f740ef
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".
mercurial/subrepo.py
--- 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()