[PATCH 2 of 5] changeset_printer: change flush() to accept ctx instead of rev

Yuya Nishihara yuya at tcha.org
Thu Jul 9 09:42:50 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1428843122 -32400
#      Sun Apr 12 21:52:02 2015 +0900
# Node ID 574befe4cc3059e156fc459b716c980be5553fcc
# Parent  bbaf3b6b60a3e5215a6964ceb7ee34cdad79490d
changeset_printer: change flush() to accept ctx instead of rev

Because flush() is the function to write data buffered by show(ctx),
flush(ctx) is more consistent than flush(rev). This makes sure that
buffered header and hunk are always keyed by ctx.rev().

This patch will allow us to give an integer to the wdir while keeping
wctx.rev() -> None.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1119,7 +1119,8 @@ class changeset_printer(object):
         self.lastheader = None
         self.footer = None
 
-    def flush(self, rev):
+    def flush(self, ctx):
+        rev = ctx.rev()
         if rev in self.header:
             h = self.header[rev]
             if h != self.lastheader:
@@ -2156,7 +2157,7 @@ def displaygraph(ui, dag, displayer, sho
         lines = displayer.hunk.pop(rev).split('\n')
         if not lines[-1]:
             del lines[-1]
-        displayer.flush(rev)
+        displayer.flush(ctx)
         edges = edgefn(type, char, lines, seen, rev, parents)
         for type, char, lines, coldata in edges:
             graphmod.ascii(ui, state, type, char, lines, coldata)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4626,7 +4626,7 @@ def log(ui, repo, *pats, **opts):
         else:
             revmatchfn = None
         displayer.show(ctx, copies=copies, matchfn=revmatchfn)
-        if displayer.flush(rev):
+        if displayer.flush(ctx):
             count += 1
 
     displayer.close()


More information about the Mercurial-devel mailing list