Patchwork [2,of,2] style: remove namespace class

login
register
mail settings
Submitter Pierre-Yves David
Date June 6, 2016, 4:44 a.m.
Message ID <e3920e6d5c0c74b26dbe.1465188240@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/15418/
State Accepted
Headers show

Comments

Pierre-Yves David - June 6, 2016, 4:44 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1460847684 25200
#      Sat Apr 16 16:01:24 2016 -0700
# Node ID e3920e6d5c0c74b26dbe2f288023a88a51cee5c5
# Parent  44c4dca6edbece04ec77f7010157f5bbd50b6a63
# EXP-Topic style
style: remove namespace class

For better or worse, our coding do not use use class for pure namespacing. We
remove the class introduced in a5009789960c.
Augie Fackler - June 6, 2016, 3:19 p.m.
On Mon, Jun 06, 2016 at 06:44:00AM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1460847684 25200
> #      Sat Apr 16 16:01:24 2016 -0700
> # Node ID e3920e6d5c0c74b26dbe2f288023a88a51cee5c5
> # Parent  44c4dca6edbece04ec77f7010157f5bbd50b6a63
> # EXP-Topic style
> style: remove namespace class

Queued these, though at some point I'd like to open a style discussion
about constants not being visibly identifiable as constants in our
codebase.

>
> For better or worse, our coding do not use use class for pure namespacing. We
> remove the class introduced in a5009789960c.
>
> diff -r 44c4dca6edbe -r e3920e6d5c0c mercurial/transaction.py
> --- a/mercurial/transaction.py	Sat Apr 16 15:59:30 2016 -0700
> +++ b/mercurial/transaction.py	Sat Apr 16 16:01:24 2016 -0700
> @@ -31,10 +31,9 @@ postfinalizegenerators = set([
>      'dirstate'
>  ])
>
> -class GenerationGroup(object):
> -    all='all'
> -    prefinalize='prefinalize'
> -    postfinalize='postfinalize'
> +gengroupall='all'
> +gengroupprefinalize='prefinalize'
> +gengrouppostfinalize='postfinalize'
>
>  def active(func):
>      def _active(self, *args, **kwds):
> @@ -289,7 +288,7 @@ class transaction(object):
>          # but for bookmarks that are handled outside this mechanism.
>          self._filegenerators[genid] = (order, filenames, genfunc, location)
>
> -    def _generatefiles(self, suffix='', group=GenerationGroup.all):
> +    def _generatefiles(self, suffix='', group=gengroupall):
>          # write files registered for generation
>          any = False
>          for id, entry in sorted(self._filegenerators.iteritems()):
> @@ -297,8 +296,8 @@ class transaction(object):
>              order, filenames, genfunc, location = entry
>
>              # for generation at closing, check if it's before or after finalize
> -            postfinalize = group == GenerationGroup.postfinalize
> -            if (group != GenerationGroup.all and
> +            postfinalize = group == gengrouppostfinalize
> +            if (group != gengroupall and
>                  (id in postfinalizegenerators) != (postfinalize)):
>                  continue
>
> @@ -427,13 +426,13 @@ class transaction(object):
>          '''commit the transaction'''
>          if self.count == 1:
>              self.validator(self)  # will raise exception if needed
> -            self._generatefiles(group=GenerationGroup.prefinalize)
> +            self._generatefiles(group=gengroupprefinalize)
>              categories = sorted(self._finalizecallback)
>              for cat in categories:
>                  self._finalizecallback[cat](self)
>              # Prevent double usage and help clear cycles.
>              self._finalizecallback = None
> -            self._generatefiles(group=GenerationGroup.postfinalize)
> +            self._generatefiles(group=gengrouppostfinalize)
>
>          self.count -= 1
>          if self.count != 0:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Pierre-Yves David - June 9, 2016, 3:55 p.m.
On 06/06/2016 05:19 PM, Augie Fackler wrote:
> On Mon, Jun 06, 2016 at 06:44:00AM +0200, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
>> # Date 1460847684 25200
>> #      Sat Apr 16 16:01:24 2016 -0700
>> # Node ID e3920e6d5c0c74b26dbe2f288023a88a51cee5c5
>> # Parent  44c4dca6edbece04ec77f7010157f5bbd50b6a63
>> # EXP-Topic style
>> style: remove namespace class
> 
> Queued these, though at some point I'd like to open a style discussion
> about constants not being visibly identifiable as constants in our
> codebase.

Yeah, I'm not a huge fan of some of our style, but I'm enforcing it to
keep the code base consistent.  Give how much code we have, I'm not sure
we can change thing now, but that seems like a discussion worth to have,
probably during a sprint.

Patch

diff -r 44c4dca6edbe -r e3920e6d5c0c mercurial/transaction.py
--- a/mercurial/transaction.py	Sat Apr 16 15:59:30 2016 -0700
+++ b/mercurial/transaction.py	Sat Apr 16 16:01:24 2016 -0700
@@ -31,10 +31,9 @@  postfinalizegenerators = set([
     'dirstate'
 ])
 
-class GenerationGroup(object):
-    all='all'
-    prefinalize='prefinalize'
-    postfinalize='postfinalize'
+gengroupall='all'
+gengroupprefinalize='prefinalize'
+gengrouppostfinalize='postfinalize'
 
 def active(func):
     def _active(self, *args, **kwds):
@@ -289,7 +288,7 @@  class transaction(object):
         # but for bookmarks that are handled outside this mechanism.
         self._filegenerators[genid] = (order, filenames, genfunc, location)
 
-    def _generatefiles(self, suffix='', group=GenerationGroup.all):
+    def _generatefiles(self, suffix='', group=gengroupall):
         # write files registered for generation
         any = False
         for id, entry in sorted(self._filegenerators.iteritems()):
@@ -297,8 +296,8 @@  class transaction(object):
             order, filenames, genfunc, location = entry
 
             # for generation at closing, check if it's before or after finalize
-            postfinalize = group == GenerationGroup.postfinalize
-            if (group != GenerationGroup.all and
+            postfinalize = group == gengrouppostfinalize
+            if (group != gengroupall and
                 (id in postfinalizegenerators) != (postfinalize)):
                 continue
 
@@ -427,13 +426,13 @@  class transaction(object):
         '''commit the transaction'''
         if self.count == 1:
             self.validator(self)  # will raise exception if needed
-            self._generatefiles(group=GenerationGroup.prefinalize)
+            self._generatefiles(group=gengroupprefinalize)
             categories = sorted(self._finalizecallback)
             for cat in categories:
                 self._finalizecallback[cat](self)
             # Prevent double usage and help clear cycles.
             self._finalizecallback = None
-            self._generatefiles(group=GenerationGroup.postfinalize)
+            self._generatefiles(group=gengrouppostfinalize)
 
         self.count -= 1
         if self.count != 0: