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

Bryan O'Sullivan bos at serpentine.com
Tue Feb 19 17:47:07 CST 2013


# HG changeset patch
# User Bryan O'Sullivan <bryano at 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',


More information about the Mercurial-devel mailing list