[PATCH 2 of 2] style: remove namespace class

Augie Fackler raf at durin42.com
Mon Jun 6 11:19:04 EDT 2016


On Mon, Jun 06, 2016 at 06:44:00AM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at 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 at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list