[PATCH 3 of 4] patch: reverse: remove useless computations

Benoit Boissinot benoit.boissinot at ens-lyon.org
Sun Aug 23 08:05:36 CDT 2009


On Sat, Aug 22, 2009 at 08:39:44PM +0200, Nicolas Dumazet wrote:
> # HG changeset patch
> # User Nicolas Dumazet <nicdumz.commits at gmail.com>
> # Date 1250961446 -7200
> # Node ID a9449df9eef46f7f534fb4dd1eb573721962fa75
> # Parent  51f0751ed3681aee75842e2351445ff30054062b
> patch: reverse: remove useless computations
> 
> "n" was never used. Introduce "first" for o[0]

Can you not make it depend on patch 2 ?
(and maybe use first = o[:1])
> 
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -613,14 +613,12 @@
>          # self.hunk[0] is the @@ description
>          for x in xrange(1, len(self.hunk)):
>              o = self.hunk[x]
> -            if o[0] == '-':
> -                n = '+' + o[1:]
> +            first = o[0]
> +            if first == '-':
>                  self.b.append(o[1:])
> -            elif o[0] == '+':
> -                n = '-' + o[1:]
> -                self.a.append(n)
> +            elif first == '+':
> +                self.a.append('-' + o[1:])
>              else:
> -                n = o
>                  self.b.append(o[1:])
>                  self.a.append(o)
>              self.hunk[x] = o
The line above seems useless too, or maybe it should be:
self.hunk[x] = n ?

But then the hunk[0] wasn't fixed (the description wasn't changed).
So I don't know what to correct thing is.

Cheers,

Benoit

-- 
:wq


More information about the Mercurial-devel mailing list