Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 24341:616c01b69898
record: change interface of the filtering function
This way filtering functions accept chunks and return chunks
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Thu, 12 Mar 2015 17:51:37 -0700 |
parents | e02a0a419418 |
children | 69538481ea9f |
comparison
equal
deleted
inserted
replaced
24340:567ae5365754 | 24341:616c01b69898 |
---|---|
18 import lock as lockmod | 18 import lock as lockmod |
19 | 19 |
20 def parsealiases(cmd): | 20 def parsealiases(cmd): |
21 return cmd.lstrip("^").split("|") | 21 return cmd.lstrip("^").split("|") |
22 | 22 |
23 def recordfilter(ui, fp): | 23 def recordfilter(ui, originalhunks): |
24 return patch.filterpatch(ui, patch.parsepatch(fp)) | 24 return patch.filterpatch(ui, originalhunks) |
25 | 25 |
26 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, | 26 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, |
27 filterfn, *pats, **opts): | 27 filterfn, *pats, **opts): |
28 import merge as mergemod | 28 import merge as mergemod |
29 if not ui.interactive(): | 29 if not ui.interactive(): |
57 | 57 |
58 status = repo.status(match=match) | 58 status = repo.status(match=match) |
59 diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True) | 59 diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True) |
60 diffopts.nodates = True | 60 diffopts.nodates = True |
61 diffopts.git = True | 61 diffopts.git = True |
62 originalchunks = patch.diff(repo, changes=status, opts=diffopts) | 62 originaldiff = patch.diff(repo, changes=status, opts=diffopts) |
63 fp = cStringIO.StringIO() | 63 originalchunks = patch.parsepatch(originaldiff) |
64 fp.write(''.join(originalchunks)) | |
65 fp.seek(0) | |
66 | 64 |
67 # 1. filter patch, so we have intending-to apply subset of it | 65 # 1. filter patch, so we have intending-to apply subset of it |
68 try: | 66 try: |
69 chunks = filterfn(ui, fp) | 67 chunks = filterfn(ui, originalchunks) |
70 except patch.PatchError, err: | 68 except patch.PatchError, err: |
71 raise util.Abort(_('error parsing patch: %s') % err) | 69 raise util.Abort(_('error parsing patch: %s') % err) |
72 | |
73 del fp | |
74 | 70 |
75 contenders = set() | 71 contenders = set() |
76 for h in chunks: | 72 for h in chunks: |
77 try: | 73 try: |
78 contenders.update(set(h.files())) | 74 contenders.update(set(h.files())) |