##// END OF EJS Templates
commit: add a way to return more information from the chunkselector...
Laurent Charignon -
r27155:8d3c5797 default
parent child Browse files
Show More
@@ -70,11 +70,11 b' def recordfilter(ui, originalhunks, oper'
70 testfile = ui.config('experimental', 'crecordtest', None)
70 testfile = ui.config('experimental', 'crecordtest', None)
71 oldwrite = setupwrapcolorwrite(ui)
71 oldwrite = setupwrapcolorwrite(ui)
72 try:
72 try:
73 newchunks = filterchunks(ui, originalhunks, usecurses, testfile,
73 newchunks, newopts = filterchunks(ui, originalhunks, usecurses,
74 operation)
74 testfile, operation)
75 finally:
75 finally:
76 ui.write = oldwrite
76 ui.write = oldwrite
77 return newchunks
77 return newchunks, newopts
78
78
79 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
79 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
80 filterfn, *pats, **opts):
80 filterfn, *pats, **opts):
@@ -121,9 +121,10 b' def dorecord(ui, repo, commitfunc, cmdsu'
121
121
122 # 1. filter patch, so we have intending-to apply subset of it
122 # 1. filter patch, so we have intending-to apply subset of it
123 try:
123 try:
124 chunks = filterfn(ui, originalchunks)
124 chunks, newopts = filterfn(ui, originalchunks)
125 except patch.PatchError as err:
125 except patch.PatchError as err:
126 raise error.Abort(_('error parsing patch: %s') % err)
126 raise error.Abort(_('error parsing patch: %s') % err)
127 opts.update(newopts)
127
128
128 # We need to keep a backup of files that have been newly added and
129 # We need to keep a backup of files that have been newly added and
129 # modified during the recording process because there is a previous
130 # modified during the recording process because there is a previous
@@ -3201,7 +3202,7 b' def _performrevert(repo, parents, ctx, a'
3201
3202
3202 try:
3203 try:
3203
3204
3204 chunks = recordfilter(repo.ui, originalchunks)
3205 chunks, opts = recordfilter(repo.ui, originalchunks)
3205 if reversehunks:
3206 if reversehunks:
3206 chunks = patch.reversehunks(chunks)
3207 chunks = patch.reversehunks(chunks)
3207
3208
@@ -454,7 +454,7 b' def filterpatch(ui, chunks, chunkselecto'
454 uiheaders = [uiheader(h) for h in headers]
454 uiheaders = [uiheader(h) for h in headers]
455 # let user choose headers/hunks/lines, and mark their applied flags
455 # let user choose headers/hunks/lines, and mark their applied flags
456 # accordingly
456 # accordingly
457 chunkselector(ui, uiheaders)
457 ret = chunkselector(ui, uiheaders)
458 appliedhunklist = []
458 appliedhunklist = []
459 for hdr in uiheaders:
459 for hdr in uiheaders:
460 if (hdr.applied and
460 if (hdr.applied and
@@ -472,7 +472,7 b' def filterpatch(ui, chunks, chunkselecto'
472 else:
472 else:
473 fixoffset += hnk.removed - hnk.added
473 fixoffset += hnk.removed - hnk.added
474
474
475 return appliedhunklist
475 return (appliedhunklist, ret)
476
476
477 def gethw():
477 def gethw():
478 """
478 """
@@ -501,6 +501,7 b' def chunkselector(ui, headerlist):'
501 raise error.Abort(chunkselector.initerr)
501 raise error.Abort(chunkselector.initerr)
502 # ncurses does not restore signal handler for SIGTSTP
502 # ncurses does not restore signal handler for SIGTSTP
503 signal.signal(signal.SIGTSTP, f)
503 signal.signal(signal.SIGTSTP, f)
504 return chunkselector.opts
504
505
505 def testdecorator(testfn, f):
506 def testdecorator(testfn, f):
506 def u(*args, **kwargs):
507 def u(*args, **kwargs):
@@ -521,6 +522,7 b' def testchunkselector(testfn, ui, header'
521 while True:
522 while True:
522 if chunkselector.handlekeypressed(testcommands.pop(0), test=True):
523 if chunkselector.handlekeypressed(testcommands.pop(0), test=True):
523 break
524 break
525 return chunkselector.opts
524
526
525 class curseschunkselector(object):
527 class curseschunkselector(object):
526 def __init__(self, headerlist, ui):
528 def __init__(self, headerlist, ui):
@@ -528,6 +530,7 b' class curseschunkselector(object):'
528 self.headerlist = patch(headerlist)
530 self.headerlist = patch(headerlist)
529
531
530 self.ui = ui
532 self.ui = ui
533 self.opts = {}
531
534
532 self.errorstr = None
535 self.errorstr = None
533 # list of all chunks
536 # list of all chunks
@@ -1106,8 +1106,8 b' the hunk is left unchanged.'
1106 applied[newhunk.filename()].append(newhunk)
1106 applied[newhunk.filename()].append(newhunk)
1107 else:
1107 else:
1108 fixoffset += chunk.removed - chunk.added
1108 fixoffset += chunk.removed - chunk.added
1109 return sum([h for h in applied.itervalues()
1109 return (sum([h for h in applied.itervalues()
1110 if h[0].special() or len(h) > 1], [])
1110 if h[0].special() or len(h) > 1], []), {})
1111 class hunk(object):
1111 class hunk(object):
1112 def __init__(self, desc, num, lr, context):
1112 def __init__(self, desc, num, lr, context):
1113 self.number = num
1113 self.number = num
General Comments 0
You need to be logged in to leave comments. Login now