Patchwork [1,of,9,V2] mdiff: remove use of __slots__

login
register
mail settings
Submitter Gregory Szorc
Date June 25, 2016, 9:11 p.m.
Message ID <8f5c54d6463b184fc337.1466889075@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/15615/
State Accepted
Headers show

Comments

Gregory Szorc - June 25, 2016, 9:11 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1466887966 25200
#      Sat Jun 25 13:52:46 2016 -0700
# Node ID 8f5c54d6463b184fc337d524e3ad96cc6eb569d6
# Parent  591a8069b60e16f2331a53e9c608c37e14be6947
mdiff: remove use of __slots__

The use of __slots__ was added way back in 2006 in 4ec58b157265.
__slots__ isn't necessary for this class.
Pierre-Yves David - June 26, 2016, 2:21 a.m.
On 06/25/2016 11:11 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1466887966 25200
> #      Sat Jun 25 13:52:46 2016 -0700
> # Node ID 8f5c54d6463b184fc337d524e3ad96cc6eb569d6
> # Parent  591a8069b60e16f2331a53e9c608c37e14be6947
> mdiff: remove use of __slots__

Pushed patch 1 only as patch two requires some deeper review.
I feel like patch 3-9 could come before patch 2. That would probably
reduce the error churn while still producing valide code. Am I right?

I don't think our important should push the magic too far so not
detecting encode and decode seems the sensible path to take here.
Gregory Szorc - June 26, 2016, 2:48 p.m.
On Sat, Jun 25, 2016 at 7:21 PM, Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> On 06/25/2016 11:11 PM, Gregory Szorc wrote:
> > # HG changeset patch
> > # User Gregory Szorc <gregory.szorc@gmail.com>
> > # Date 1466887966 25200
> > #      Sat Jun 25 13:52:46 2016 -0700
> > # Node ID 8f5c54d6463b184fc337d524e3ad96cc6eb569d6
> > # Parent  591a8069b60e16f2331a53e9c608c37e14be6947
> > mdiff: remove use of __slots__
>
> Pushed patch 1 only as patch two requires some deeper review.
> I feel like patch 3-9 could come before patch 2. That would probably
> reduce the error churn while still producing valide code. Am I right?
>

Yes, many of the subsequent patches could land first. I'm hesitant to
reorder because many of them deal with fallout from the module loader. It
feels like cart before the horse to have them land before. But I may
reorder a few of them so the in-flight series is a bit smaller. Please
don't wait on that to look at patch 2...


> I don't think our important should push the magic too far so not
> detecting encode and decode seems the sensible path to take here.
>
> --
> Pierre-Yves David
>

Patch

diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -53,20 +53,18 @@  class diffopts(object):
         'nobinary': False,
         'noprefix': False,
         'ignorews': False,
         'ignorewsamount': False,
         'ignoreblanklines': False,
         'upgrade': False,
         }
 
-    __slots__ = defaults.keys()
-
     def __init__(self, **opts):
-        for k in self.__slots__:
+        for k in self.defaults.keys():
             v = opts.get(k)
             if v is None:
                 v = self.defaults[k]
             setattr(self, k, v)
 
         try:
             self.context = int(self.context)
         except ValueError: