Mercurial > hg-stable
changeset 16366:913d1fa61398
mq: use list of already known target files instead of matching object for diff
'hg qnew' passes matching object to 'patch.diff()' to specify target
filenames, and it causes 'dirstate.walk()' via 'repo.status()' in
'patch.diff()'.
but target files are already known before 'patch.diff()' invocation.
to avoid useless 'dirstate.walk()' invocation, this patch uses
'changes' argument to pass already known target files to
'patch.diff()' instead of 'match' argument.
'changes' argument of 'patch.diff()' should have lists for modified,
added and removed files separately, so this patch saves status of
'.hgsubstate' before commit, and put it into appropriate list in
'changes'.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Thu, 05 Apr 2012 23:52:55 +0900 |
parents | 5d61e007d957 |
children | 28bb4daf070c |
files | hgext/mq.py |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Thu Apr 05 23:52:06 2012 +0900 +++ b/hgext/mq.py Thu Apr 05 23:52:55 2012 +0900 @@ -950,6 +950,7 @@ inclsubs = self.checksubstate(repo) if inclsubs: inclsubs.append('.hgsubstate') + substatestate = repo.dirstate['.hgsubstate'] if opts.get('include') or opts.get('exclude') or pats: if inclsubs: pats = list(pats or []) + inclsubs @@ -959,9 +960,11 @@ if f != '.hgsubstate': # .hgsubstate is auto-created raise util.Abort('%s: %s' % (f, msg)) match.bad = badfn - m, a, r, d = repo.status(match=match)[:4] + changes = repo.status(match=match) + m, a, r, d = changes[:4] else: - m, a, r, d = self.checklocalchanges(repo, force=True) + changes = self.checklocalchanges(repo, force=True) + m, a, r, d = changes match = scmutil.matchfiles(repo, m + a + r + inclsubs) if len(repo[None].parents()) > 1: raise util.Abort(_('cannot manage merge changesets')) @@ -1010,8 +1013,15 @@ p.write(msg) if commitfiles: parent = self.qparents(repo, n) + if inclsubs: + if substatestate in 'a?': + changes[1].append('.hgsubstate') + elif substatestate in 'r': + changes[2].append('.hgsubstate') + else: # modified + changes[0].append('.hgsubstate') chunks = patchmod.diff(repo, node1=parent, node2=n, - match=match, opts=diffopts) + changes=changes, opts=diffopts) for chunk in chunks: p.write(chunk) p.close()