Patchwork [4,of,8,V3] subrepo: store the ui object in the base class

login
register
mail settings
Submitter Matt Harbison
Date Dec. 12, 2014, 3:35 a.m.
Message ID <71bacffdfe45b9b262e8.1418355316@Envy>
Download mbox | patch
Permalink /patch/7058/
State Accepted
Commit fcbc66b5da6ad820ca980737025bfeb35a479fc8
Headers show

Comments

Matt Harbison - Dec. 12, 2014, 3:35 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1417036418 18000
#      Wed Nov 26 16:13:38 2014 -0500
# Node ID 71bacffdfe45b9b262e8a3c7260375e1b0f0b29c
# Parent  da5bde55b5296f0cce6dd7582c0c5d1edb323ec8
subrepo: store the ui object in the base class

This will be used in the next patch to print a warning from the base class.  It
seems better than having to explicitly pass it to a new method, since a lot of
existing methods also require it.
Martin von Zweigbergk - Dec. 12, 2014, 5:59 p.m.
On Thu Dec 11 2014 at 7:36:10 PM Matt Harbison <mharbison72@gmail.com>
wrote:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1417036418 18000
> #      Wed Nov 26 16:13:38 2014 -0500
> # Node ID 71bacffdfe45b9b262e8a3c7260375e1b0f0b29c
> # Parent  da5bde55b5296f0cce6dd7582c0c5d1edb323ec8
> subrepo: store the ui object in the base class
>
> This will be used in the next patch to print a warning from the base
> class.  It
> seems better than having to explicitly pass it to a new method, since a
> lot of
> existing methods also require it.
>

Is it worth updating those existing methods?
Matt Harbison - Dec. 13, 2014, 1:48 a.m.
On Fri, 12 Dec 2014 12:59:21 -0500, Martin von Zweigbergk  
<martinvonz@google.com> wrote:

> On Thu Dec 11 2014 at 7:36:10 PM Matt Harbison <mharbison72@gmail.com>
> wrote:
>
>> # HG changeset patch
>> # User Matt Harbison <matt_harbison@yahoo.com>
>> # Date 1417036418 18000
>> #      Wed Nov 26 16:13:38 2014 -0500
>> # Node ID 71bacffdfe45b9b262e8a3c7260375e1b0f0b29c
>> # Parent  da5bde55b5296f0cce6dd7582c0c5d1edb323ec8
>> subrepo: store the ui object in the base class
>>
>> This will be used in the next patch to print a warning from the base
>> class.  It
>> seems better than having to explicitly pass it to a new method, since a
>> lot of
>> existing methods also require it.
>>
>
> Is it worth updating those existing methods?

I think it is, but I assume it would have been rejected if I changed the  
other methods in this patch, and didn't want to divert this series into  
something else.  I'll take a look at it this weekend if I have time.

--Matt

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -372,6 +372,9 @@ 
 
 class abstractsubrepo(object):
 
+    def __init__(self, ui):
+        self._ui = ui
+
     def storeclean(self, path):
         """
         returns true if the repository has not changed since it was last
@@ -508,6 +511,7 @@ 
 
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
+        super(hgsubrepo, self).__init__(ctx._repo.ui)
         self._path = path
         self._state = state
         r = ctx._repo
@@ -878,6 +882,7 @@ 
 
 class svnsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
+        super(svnsubrepo, self).__init__(ctx._repo.ui)
         self._path = path
         self._state = state
         self._ctx = ctx
@@ -1108,6 +1113,7 @@ 
 
 class gitsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):
+        super(gitsubrepo, self).__init__(ctx._repo.ui)
         self._state = state
         self._ctx = ctx
         self._path = path