Patchwork [2,of,2] commands: exit from the log loop at the right time

login
register
mail settings
Submitter Bryan O'Sullivan
Date Feb. 19, 2013, 11:47 p.m.
Message ID <4dfcc703b38581beafbf.1361317627@australite.thefacebook.com>
Download mbox | patch
Permalink /patch/1037/
State Accepted
Commit 6b786dc88612ca6922ce504159b9d3f48ab6816e
Headers show

Comments

Bryan O'Sullivan - Feb. 19, 2013, 11:47 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1361317587 28800
# Node ID 4dfcc703b38581beafbf85ba5ae971943ecb70d5
# Parent  77b02f572b752fcbec87f576564880ec1dc9023b
commands: exit from the log loop at the right time

Previously, we'd run the iterator one more time than necessary,
potentially doing a lot of extra work in the process.
Augie Fackler - Feb. 20, 2013, 2:01 a.m.
Both of these LGTM

On Feb 19, 2013, at 6:47 PM, Bryan O'Sullivan <bos@serpentine.com> wrote:

> # HG changeset patch
> # User Bryan O'Sullivan <bryano@fb.com>
> # Date 1361317587 28800
> # Node ID 4dfcc703b38581beafbf85ba5ae971943ecb70d5
> # Parent  77b02f572b752fcbec87f576564880ec1dc9023b
> commands: exit from the log loop at the right time
> 
> Previously, we'd run the iterator one more time than necessary,
> potentially doing a lot of extra work in the process.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4215,10 +4215,10 @@ def log(ui, repo, *pats, **opts):
>         displayer.show(ctx, copies=copies, matchfn=revmatchfn)
> 
>     for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
> +        if displayer.flush(ctx.rev()):
> +            count += 1
>         if count == limit:
>             break
> -        if displayer.flush(ctx.rev()):
> -            count += 1
>     displayer.close()
> 
> @command('manifest',
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
tonfa - Feb. 20, 2013, 7:48 a.m.
On Wed, Feb 20, 2013 at 3:01 AM, Augie Fackler <raf@durin42.com> wrote:

> Both of these LGTM
>

+1 (started reviewing before seeing the LGTM).

Thanks,

Benoit

>
> On Feb 19, 2013, at 6:47 PM, Bryan O'Sullivan <bos@serpentine.com> wrote:
>
> > # HG changeset patch
> > # User Bryan O'Sullivan <bryano@fb.com>
> > # Date 1361317587 28800
> > # Node ID 4dfcc703b38581beafbf85ba5ae971943ecb70d5
> > # Parent  77b02f572b752fcbec87f576564880ec1dc9023b
> > commands: exit from the log loop at the right time
> >
> > Previously, we'd run the iterator one more time than necessary,
> > potentially doing a lot of extra work in the process.
> >
> > diff --git a/mercurial/commands.py b/mercurial/commands.py
> > --- a/mercurial/commands.py
> > +++ b/mercurial/commands.py
> > @@ -4215,10 +4215,10 @@ def log(ui, repo, *pats, **opts):
> >         displayer.show(ctx, copies=copies, matchfn=revmatchfn)
> >
> >     for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
> > +        if displayer.flush(ctx.rev()):
> > +            count += 1
> >         if count == limit:
> >             break
> > -        if displayer.flush(ctx.rev()):
> > -            count += 1
> >     displayer.close()
> >
> > @command('manifest',
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel@selenic.com
> > http://selenic.com/mailman/listinfo/mercurial-devel
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4215,10 +4215,10 @@  def log(ui, repo, *pats, **opts):
         displayer.show(ctx, copies=copies, matchfn=revmatchfn)
 
     for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
+        if displayer.flush(ctx.rev()):
+            count += 1
         if count == limit:
             break
-        if displayer.flush(ctx.rev()):
-            count += 1
     displayer.close()
 
 @command('manifest',