##// END OF EJS Templates
record: change interface of the filtering function...
Laurent Charignon -
r24341:616c01b6 default
parent child Browse files
Show More
@@ -20,8 +20,8 b' import lock as lockmod'
20 20 def parsealiases(cmd):
21 21 return cmd.lstrip("^").split("|")
22 22
23 def recordfilter(ui, fp):
24 return patch.filterpatch(ui, patch.parsepatch(fp))
23 def recordfilter(ui, originalhunks):
24 return patch.filterpatch(ui, originalhunks)
25 25
26 26 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
27 27 filterfn, *pats, **opts):
@@ -59,19 +59,15 b' def dorecord(ui, repo, commitfunc, cmdsu'
59 59 diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True)
60 60 diffopts.nodates = True
61 61 diffopts.git = True
62 originalchunks = patch.diff(repo, changes=status, opts=diffopts)
63 fp = cStringIO.StringIO()
64 fp.write(''.join(originalchunks))
65 fp.seek(0)
62 originaldiff = patch.diff(repo, changes=status, opts=diffopts)
63 originalchunks = patch.parsepatch(originaldiff)
66 64
67 65 # 1. filter patch, so we have intending-to apply subset of it
68 66 try:
69 chunks = filterfn(ui, fp)
67 chunks = filterfn(ui, originalchunks)
70 68 except patch.PatchError, err:
71 69 raise util.Abort(_('error parsing patch: %s') % err)
72 70
73 del fp
74
75 71 contenders = set()
76 72 for h in chunks:
77 73 try:
@@ -15,6 +15,7 b' import email.Parser'
15 15
16 16 from i18n import _
17 17 from node import hex, short
18 import cStringIO
18 19 import base85, mdiff, scmutil, util, diffhelpers, copies, encoding, error
19 20
20 21 gitre = re.compile('diff --git a/(.*) b/(.*)')
@@ -1352,7 +1353,7 b' def parsefilename(str):'
1352 1353 return s
1353 1354 return s[:i]
1354 1355
1355 def parsepatch(fp):
1356 def parsepatch(originalchunks):
1356 1357 """patch -> [] of headers -> [] of hunks """
1357 1358 class parser(object):
1358 1359 """patch parsing state machine"""
@@ -1421,6 +1422,9 b' def parsepatch(fp):'
1421 1422 }
1422 1423
1423 1424 p = parser()
1425 fp = cStringIO.StringIO()
1426 fp.write(''.join(originalchunks))
1427 fp.seek(0)
1424 1428
1425 1429 state = 'context'
1426 1430 for newstate, data in scanpatch(fp):
@@ -1430,6 +1434,7 b' def parsepatch(fp):'
1430 1434 raise PatchError('unhandled transition: %s -> %s' %
1431 1435 (state, newstate))
1432 1436 state = newstate
1437 del fp
1433 1438 return p.finished()
1434 1439
1435 1440 def pathtransform(path, strip, prefix):
General Comments 0
You need to be logged in to leave comments. Login now