Patchwork [2,of,2] localrepo: move filtername to __init__

login
register
mail settings
Submitter Gregory Szorc
Date June 9, 2017, 6:26 a.m.
Message ID <e1a094a7815f3d906374.1496989561@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/21271/
State Accepted
Headers show

Comments

Gregory Szorc - June 9, 2017, 6:26 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1496989417 25200
#      Thu Jun 08 23:23:37 2017 -0700
# Node ID e1a094a7815f3d906374ff2fe06296cbeaf89fcb
# Parent  4867bfadaa177b5e43108f2683e64898204827b7
localrepo: move filtername to __init__

This is obviously an instance attribute, not a type attribute. The
modern Python style is to use __init__ for defining these.

This exposes statichttprepo as inheriting from localrepository
without calling its __init__. As a result, its __init__ defines
a lot of variables that methods on localrepository's methods need.
But factoring the common bits into a separate class is for another
day.
Pierre-Yves David - June 9, 2017, 9:39 a.m.
On 06/09/2017 07:26 AM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1496989417 25200
> #      Thu Jun 08 23:23:37 2017 -0700
> # Node ID e1a094a7815f3d906374ff2fe06296cbeaf89fcb
> # Parent  4867bfadaa177b5e43108f2683e64898204827b7
> localrepo: move filtername to __init__
>
> This is obviously an instance attribute, not a type attribute. The
> modern Python style is to use __init__ for defining these.
>
> This exposes statichttprepo as inheriting from localrepository
> without calling its __init__. As a result, its __init__ defines
> a lot of variables that methods on localrepository's methods need.
> But factoring the common bits into a separate class is for another
> day.

+1 for this series.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -270,7 +270,6 @@  class localrepository(object):
         'treemanifest',
         'manifestv2',
     }
-    filtername = None
 
     # a list of (ui, featureset) functions.
     # only functions defined in module of enabled extensions are invoked
@@ -278,6 +277,7 @@  class localrepository(object):
 
     def __init__(self, baseui, path, create=False):
         self.requirements = set()
+        self.filtername = None
         # wvfs: rooted at the repository root, used to access the working copy
         self.wvfs = vfsmod.vfs(path, expandpath=True, realpath=True)
         # vfs: rooted at .hg, used to access repo files outside of .hg/store
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -127,6 +127,7 @@  class statichttprepository(localrepo.loc
         self._phasedefaults = []
 
         self.names = namespaces.namespaces()
+        self.filtername = None
 
         try:
             requirements = scmutil.readrequires(self.vfs, self.supported)