Re: Constant naming convention (was: Re: [PATCH 1 of 7 upgraderepo V2] revlog: add clone method)

2016-12-24 Thread Gregory Szorc
On Mon, Dec 12, 2016 at 8:12 AM, Augie Fackler  wrote:

> On Mon, Dec 12, 2016 at 11:04:07AM +0100, Pierre-Yves David wrote:
> >
> >
> > On 11/25/2016 04:28 AM, Gregory Szorc wrote:
> > >diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> > >--- a/mercurial/revlog.py
> > >+++ b/mercurial/revlog.py
> > >@@ -1818,3 +1818,95 @@ class revlog(object):
> > > if not self._inline:
> > > res.append(self.datafile)
> > > return res
> > >+
> > >+DELTAREUSEALWAYS = 'always'
> > >+DELTAREUSESAMEREVS = 'samerevs'
> > >+DELTAREUSENEVER = 'never'
> >
> > We don't use cap in our names, even for constant, these should be lower
> > case.
>
> Can we just align with prevailing Python style here and start using
> all caps for constants? This comes up roughly monthly, and I think
> it'd be a good clarity win.
>

+1

I like trending towards consistency with the majority of the Python
community. That will make Mercurial hacking and contributing more
approachable to newcomers, which is good for The Project.

Our use of casing for constants is inconsistent today. And, there is no
check-code rule enforcing one way or the other. So in my mind that means we
can do whatever we want. One could make the argument that since Python has
no concept of constants, there's no way to tell whether a variable
assignment is a constant or not and that's why there is no check-code rule.
This is true. However, in my mind this is justification for distinguishing
between variables used as constants with a different naming scheme: the
UPPERCASING says "use this variable as a constant" - it gives a meaningful
signal to code authors and reviewers as to how a variable should be used.

FWIW, I also strongly disagree with our style convention that use lowercase
words without underscores for everything. IMO that makes things much harder
to read than they should be (especially to non-English native speakers).
But that rule is encoded in check-style and I'll fight on that hill another
day :)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Constant naming convention (was: Re: [PATCH 1 of 7 upgraderepo V2] revlog: add clone method)

2016-12-13 Thread Yuya Nishihara
On Mon, 12 Dec 2016 10:12:48 -0500, Augie Fackler wrote:
> On Mon, Dec 12, 2016 at 11:04:07AM +0100, Pierre-Yves David wrote:
> >
> >
> > On 11/25/2016 04:28 AM, Gregory Szorc wrote:
> > >diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> > >--- a/mercurial/revlog.py
> > >+++ b/mercurial/revlog.py
> > >@@ -1818,3 +1818,95 @@ class revlog(object):
> > > if not self._inline:
> > > res.append(self.datafile)
> > > return res
> > >+
> > >+DELTAREUSEALWAYS = 'always'
> > >+DELTAREUSESAMEREVS = 'samerevs'
> > >+DELTAREUSENEVER = 'never'
> >
> > We don't use cap in our names, even for constant, these should be lower
> > case.
> 
> Can we just align with prevailing Python style here and start using
> all caps for constants? This comes up roughly monthly, and I think
> it'd be a good clarity win.

I'm fine with ALLCAPS constants.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Constant naming convention (was: Re: [PATCH 1 of 7 upgraderepo V2] revlog: add clone method)

2016-12-12 Thread Augie Fackler
On Mon, Dec 12, 2016 at 11:04:07AM +0100, Pierre-Yves David wrote:
>
>
> On 11/25/2016 04:28 AM, Gregory Szorc wrote:
> >diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> >--- a/mercurial/revlog.py
> >+++ b/mercurial/revlog.py
> >@@ -1818,3 +1818,95 @@ class revlog(object):
> > if not self._inline:
> > res.append(self.datafile)
> > return res
> >+
> >+DELTAREUSEALWAYS = 'always'
> >+DELTAREUSESAMEREVS = 'samerevs'
> >+DELTAREUSENEVER = 'never'
>
> We don't use cap in our names, even for constant, these should be lower
> case.

Can we just align with prevailing Python style here and start using
all caps for constants? This comes up roughly monthly, and I think
it'd be a good clarity win.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel