[PATCH 1 of 8] crecord: add an "operation" field
Jun Wu
quark at fb.com
Wed Nov 23 23:24:36 UTC 2016
# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1479928956 0
# Wed Nov 23 19:22:36 2016 +0000
# Node ID c1aa248a8bc0fac647a1f849ed25c31291edce64
# Parent 7ef2ebf5cdf91192a66b461ff56f653a65e65dd7
# Available At https://bitbucket.org/quark-zju/hg-draft
# hg pull https://bitbucket.org/quark-zju/hg-draft -r c1aa248a8bc0
crecord: add an "operation" field
The field would provide extra information to help us to make the curses UI
text less confusing.
diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -434,5 +434,5 @@ class uihunk(patchnode):
return '<hunk %r@%d>' % (self.filename(), self.fromline)
-def filterpatch(ui, chunks, chunkselector):
+def filterpatch(ui, chunks, chunkselector, operation=None):
"""interactively filter patch chunks into applied-only chunks"""
chunks = list(chunks)
@@ -447,5 +447,5 @@ def filterpatch(ui, chunks, chunkselecto
# let user choose headers/hunks/lines, and mark their applied flags
# accordingly
- ret = chunkselector(ui, uiheaders)
+ ret = chunkselector(ui, uiheaders, operation=operation)
appliedhunklist = []
for hdr in uiheaders:
@@ -467,5 +467,5 @@ def filterpatch(ui, chunks, chunkselecto
return (appliedhunklist, ret)
-def chunkselector(ui, headerlist):
+def chunkselector(ui, headerlist, operation=None):
"""
curses interface to get selection of chunks, and mark the applied flags
@@ -473,5 +473,5 @@ def chunkselector(ui, headerlist):
"""
ui.write(_('starting interactive selection\n'))
- chunkselector = curseschunkselector(headerlist, ui)
+ chunkselector = curseschunkselector(headerlist, ui, operation)
f = signal.getsignal(signal.SIGTSTP)
curses.wrapper(chunkselector.main)
@@ -487,10 +487,10 @@ def testdecorator(testfn, f):
return u
-def testchunkselector(testfn, ui, headerlist):
+def testchunkselector(testfn, ui, headerlist, operation=None):
"""
test interface to get selection of chunks, and mark the applied flags
of the chosen chunks.
"""
- chunkselector = curseschunkselector(headerlist, ui)
+ chunkselector = curseschunkselector(headerlist, ui, operation)
if testfn and os.path.exists(testfn):
testf = open(testfn)
@@ -503,5 +503,5 @@ def testchunkselector(testfn, ui, header
class curseschunkselector(object):
- def __init__(self, headerlist, ui):
+ def __init__(self, headerlist, ui, operation=None):
# put the headers into a patch object
self.headerlist = patch(headerlist)
@@ -557,4 +557,7 @@ class curseschunkselector(object):
self.waslasttoggleallapplied = True
+ # affects some ui text
+ self.operation = operation
+
def uparrowevent(self):
"""
More information about the Mercurial-devel
mailing list