Patchwork [3,of,4] record: move ui.write wrapping where it should be

login
register
mail settings
Submitter Laurent Charignon
Date March 18, 2015, 2:17 a.m.
Message ID <86f9b176ee03b719c29f.1426645055@dev919.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8136/
State Accepted
Commit 8d9e9063b0409ab387ac63832772007ab5fa61ad
Headers show

Comments

Laurent Charignon - March 18, 2015, 2:17 a.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1426545420 25200
#      Mon Mar 16 15:37:00 2015 -0700
# Node ID 86f9b176ee03b719c29f260776932b4263691f65
# Parent  69389fa752562fb5888ffa44716d120c242d4f0f
record: move ui.write wrapping where it should be

We have to do that for the coloring to work in interactive revert

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -51,7 +51,11 @@ 
 def recordfilter(ui, originalhunks):
     usecurses =  ui.configbool('experimental', 'crecord', False)
     testfile = ui.config('experimental', 'crecordtest', None)
-    newchunks = filterchunks(ui, originalhunks, usecurses, testfile)
+    oldwrite = setupwrapcolorwrite(ui)
+    try:
+        newchunks = filterchunks(ui, originalhunks, usecurses, testfile)
+    finally:
+        ui.write = oldwrite
     return newchunks
 
 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
@@ -207,12 +211,7 @@ 
             except OSError:
                 pass
 
-    oldwrite = setupwrapcolorwrite(ui)
-    try:
-        return commit(ui, repo, recordfunc, pats, opts)
-    finally:
-        ui.write = oldwrite
-
+    return commit(ui, repo, recordfunc, pats, opts)
 
 def findpossible(cmd, table, strict=False):
     """