Patchwork [10,of,36] context: use type(self).__name__ to instead of hardcoding class name

login
register
mail settings
Submitter Sean Farley
Date Aug. 7, 2013, 6:13 p.m.
Message ID <d5f3b9240f8d6596e979.1375899190@laptop.local>
Download mbox | patch
Permalink /patch/2027/
State Changes Requested
Delegated to: Augie Fackler
Headers show

Comments

Sean Farley - Aug. 7, 2013, 6:13 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1375485848 18000
#      Fri Aug 02 18:24:08 2013 -0500
# Node ID d5f3b9240f8d6596e97917a18bf870d60fe7fe88
# Parent  8d5fbb6e08357ca42b140eaea1d3aaa72d10aec5
context: use type(self).__name__ to instead of hardcoding class name
Augie Fackler - Aug. 7, 2013, 6:26 p.m.
On Wed, Aug 07, 2013 at 01:13:10PM -0500, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1375485848 18000
> #      Fri Aug 02 18:24:08 2013 -0500
> # Node ID d5f3b9240f8d6596e97917a18bf870d60fe7fe88
> # Parent  8d5fbb6e08357ca42b140eaea1d3aaa72d10aec5
> context: use type(self).__name__ to instead of hardcoding class name
>
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -40,11 +40,11 @@
>
>      def __int__(self):
>          return self.rev()
>
>      def __repr__(self):
> -        return "<changectx %s>" % str(self)
> +        return "<%s %s>" % (type(self).__name__, str(self))

Hah, or this. I think I'd fold this into the previous patch.

>
>      def rev(self):
>          return self._rev
>      def node(self):
>          return self._node
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Sean Farley - Aug. 7, 2013, 7:24 p.m.
raf@durin42.com writes:

> On Wed, Aug 07, 2013 at 01:13:10PM -0500, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1375485848 18000
>> #      Fri Aug 02 18:24:08 2013 -0500
>> # Node ID d5f3b9240f8d6596e97917a18bf870d60fe7fe88
>> # Parent  8d5fbb6e08357ca42b140eaea1d3aaa72d10aec5
>> context: use type(self).__name__ to instead of hardcoding class name
>>
>> diff --git a/mercurial/context.py b/mercurial/context.py
>> --- a/mercurial/context.py
>> +++ b/mercurial/context.py
>> @@ -40,11 +40,11 @@
>>
>>      def __int__(self):
>>          return self.rev()
>>
>>      def __repr__(self):
>> -        return "<changectx %s>" % str(self)
>> +        return "<%s %s>" % (type(self).__name__, str(self))
>
> Hah, or this. I think I'd fold this into the previous patch.

I was a little afraid of having one patch do two things (move code, then
change return value). If people want me to fold it, then I can do that
too.
Augie Fackler - Aug. 7, 2013, 7:41 p.m.
On Wed, Aug 7, 2013 at 3:24 PM, Sean Farley
<sean.michael.farley@gmail.com> wrote:
>
> raf@durin42.com writes:
>
>> On Wed, Aug 07, 2013 at 01:13:10PM -0500, Sean Farley wrote:
>>> # HG changeset patch
>>> # User Sean Farley <sean.michael.farley@gmail.com>
>>> # Date 1375485848 18000
>>> #      Fri Aug 02 18:24:08 2013 -0500
>>> # Node ID d5f3b9240f8d6596e97917a18bf870d60fe7fe88
>>> # Parent  8d5fbb6e08357ca42b140eaea1d3aaa72d10aec5
>>> context: use type(self).__name__ to instead of hardcoding class name
>>>
>>> diff --git a/mercurial/context.py b/mercurial/context.py
>>> --- a/mercurial/context.py
>>> +++ b/mercurial/context.py
>>> @@ -40,11 +40,11 @@
>>>
>>>      def __int__(self):
>>>          return self.rev()
>>>
>>>      def __repr__(self):
>>> -        return "<changectx %s>" % str(self)
>>> +        return "<%s %s>" % (type(self).__name__, str(self))
>>
>> Hah, or this. I think I'd fold this into the previous patch.
>
> I was a little afraid of having one patch do two things (move code, then
> change return value). If people want me to fold it, then I can do that
> too.


I think in this case it makes sense (esp. since it's such a small
patch) to merge them so the code is correct at every step.
Sean Farley - Aug. 7, 2013, 8:53 p.m.
raf@durin42.com writes:

> On Wed, Aug 7, 2013 at 3:24 PM, Sean Farley
> <sean.michael.farley@gmail.com> wrote:
>>
>> raf@durin42.com writes:
>>
>>> On Wed, Aug 07, 2013 at 01:13:10PM -0500, Sean Farley wrote:
>>>> # HG changeset patch
>>>> # User Sean Farley <sean.michael.farley@gmail.com>
>>>> # Date 1375485848 18000
>>>> #      Fri Aug 02 18:24:08 2013 -0500
>>>> # Node ID d5f3b9240f8d6596e97917a18bf870d60fe7fe88
>>>> # Parent  8d5fbb6e08357ca42b140eaea1d3aaa72d10aec5
>>>> context: use type(self).__name__ to instead of hardcoding class name
>>>>
>>>> diff --git a/mercurial/context.py b/mercurial/context.py
>>>> --- a/mercurial/context.py
>>>> +++ b/mercurial/context.py
>>>> @@ -40,11 +40,11 @@
>>>>
>>>>      def __int__(self):
>>>>          return self.rev()
>>>>
>>>>      def __repr__(self):
>>>> -        return "<changectx %s>" % str(self)
>>>> +        return "<%s %s>" % (type(self).__name__, str(self))
>>>
>>> Hah, or this. I think I'd fold this into the previous patch.
>>
>> I was a little afraid of having one patch do two things (move code, then
>> change return value). If people want me to fold it, then I can do that
>> too.
>
>
> I think in this case it makes sense (esp. since it's such a small
> patch) to merge them so the code is correct at every step.

Fair enough. Just to be pedantic, I'll point out that it's still correct
in the previous patch because only changectx inherits from context and
no other code in mercurial calls on context directly.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -40,11 +40,11 @@ 
 
     def __int__(self):
         return self.rev()
 
     def __repr__(self):
-        return "<changectx %s>" % str(self)
+        return "<%s %s>" % (type(self).__name__, str(self))
 
     def rev(self):
         return self._rev
     def node(self):
         return self._node