Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 24345:01b39149ebb3
record: minor refactoring of dorecord
It prepares the way for introducing the flag to reverse hunk selection
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Thu, 12 Mar 2015 17:50:23 -0700 |
parents | 69538481ea9f |
children | a38f384f2a57 |
comparison
equal
deleted
inserted
replaced
24344:6b43baac6dfb | 24345:01b39149ebb3 |
---|---|
37 return patch.filterpatch(ui, originalhunks) | 37 return patch.filterpatch(ui, originalhunks) |
38 | 38 |
39 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, | 39 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, |
40 filterfn, *pats, **opts): | 40 filterfn, *pats, **opts): |
41 import merge as mergemod | 41 import merge as mergemod |
42 hunkclasses = (crecordmod.uihunk, patch.recordhunk) | |
43 ishunk = lambda x: isinstance(x, hunkclasses) | |
44 | |
42 if not ui.interactive(): | 45 if not ui.interactive(): |
43 raise util.Abort(_('running non-interactively, use %s instead') % | 46 raise util.Abort(_('running non-interactively, use %s instead') % |
44 cmdsuggest) | 47 cmdsuggest) |
45 | 48 |
46 # make sure username is set before going interactive | 49 # make sure username is set before going interactive |
94 ui.status(_('no changes to record\n')) | 97 ui.status(_('no changes to record\n')) |
95 return 0 | 98 return 0 |
96 | 99 |
97 newandmodifiedfiles = set() | 100 newandmodifiedfiles = set() |
98 for h in chunks: | 101 for h in chunks: |
99 iscrecordhunk = isinstance(h, crecordmod.uihunk) | |
100 ishunk = isinstance(h, patch.recordhunk) | |
101 isnew = h.filename() in status.added | 102 isnew = h.filename() in status.added |
102 if (ishunk or iscrecordhunk) and isnew and not h in originalchunks: | 103 if ishunk(h) and isnew and not h in originalchunks: |
103 newandmodifiedfiles.add(h.filename()) | 104 newandmodifiedfiles.add(h.filename()) |
104 | 105 |
105 modified = set(status.modified) | 106 modified = set(status.modified) |
106 | 107 |
107 # 2. backup changed files, so we can restore them in the end | 108 # 2. backup changed files, so we can restore them in the end |