[PATCH 1 of 6] scmutil: do not return working context if rev is 0

Greg Ward greg-hg at gerg.ca
Mon Sep 12 19:07:24 CDT 2011


On Sun, Sep 11, 2011 at 11:46 AM, Simon Heimberg <simohe at besonet.ch> wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe at besonet.ch>
> # Date 1315412552 -7200
> # Node ID 37e014596b3ac292d90fa2a92faa06ca390c50ad
> # Parent  d361c75c1f4cc8bcbabae440eecfeaac921ba0b2
> scmutil: do not return working context if rev is 0
>
> related to issue2992
>
> diff -r d361c75c1f4c -r 37e014596b3a mercurial/scmutil.py
> --- a/mercurial/scmutil.py      Son Sep 11 14:42:30 2011 +0200
> +++ b/mercurial/scmutil.py      Mit Sep 07 18:22:32 2011 +0200
> @@ -471,7 +471,7 @@
>         return path
>
>  def revsingle(repo, revspec, default='.'):
> -    if not revspec:
> +    if not revspec and revspec != 0:

Wouldn't this:

  if revspec is not None:

be better? That's how I always handle this sort of case. Whenever I
catch myself typing "if not x", I have to stop and think: is this
really a boolean arg? Or is it something that can be None or 0 or 0.0
or ''?  If the latter, I always explicitly compare to None or 0 or 0.0
or ''.

Greg


More information about the Mercurial-devel mailing list