Mercurial > hg
changeset 10191:99d285ac5da4
mq: qdiff with the same diff options than qrefresh (issue1350)
Specifically, if current patch is a git patch and mq.git=keep, diff in git
mode.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 01 Jan 2010 21:49:05 +0100 |
parents | 9c2c94934f0d |
children | 8161127a638f |
files | hgext/mq.py tests/test-mq-qdiff tests/test-mq-qdiff.out |
diffstat | 3 files changed, 35 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Fri Jan 01 21:21:34 2010 +0100 +++ b/hgext/mq.py Fri Jan 01 21:49:05 2010 +0100 @@ -771,11 +771,13 @@ def check_toppatch(self, repo): if len(self.applied) > 0: top = bin(self.applied[-1].rev) + patch = self.applied[-1].name pp = repo.dirstate.parents() if top not in pp: raise util.Abort(_("working directory revision is not qtip")) - return top - return None + return top, patch + return None, None + def check_localchanges(self, repo, force=False, refresh=True): m, a, r, d = repo.status()[:4] if m or a or r or d: @@ -1125,7 +1127,7 @@ end = len(self.applied) rev = bin(self.applied[start].rev) if update: - top = self.check_toppatch(repo) + top = self.check_toppatch(repo)[0] try: heads = repo.changelog.heads(rev) @@ -1174,7 +1176,7 @@ wlock.release() def diff(self, repo, pats, opts): - top = self.check_toppatch(repo) + top, patch = self.check_toppatch(repo) if not top: self.ui.write(_("no patches applied\n")) return @@ -1183,7 +1185,7 @@ node1, node2 = None, qp else: node1, node2 = qp, None - diffopts = self.diffopts(opts) + diffopts = self.diffopts(opts, patch) self.printdiff(repo, diffopts, node1, node2, files=pats, opts=opts) def refresh(self, repo, pats=None, **opts): @@ -2058,7 +2060,7 @@ if not files: raise util.Abort(_('qfold requires at least one patch name')) - if not q.check_toppatch(repo): + if not q.check_toppatch(repo)[0]: raise util.Abort(_('No patches applied')) q.check_localchanges(repo)
--- a/tests/test-mq-qdiff Fri Jan 01 21:21:34 2010 +0100 +++ b/tests/test-mq-qdiff Fri Jan 01 21:49:05 2010 +0100 @@ -2,6 +2,8 @@ echo "[extensions]" >> $HGRCPATH echo "mq=" >> $HGRCPATH +echo "[mq]" >> $HGRCPATH +echo "git=keep" >> $HGRCPATH echo % init hg init a @@ -60,3 +62,9 @@ echo % qdiff --reverse hg qdiff --nodates --reverse + +echo % qdiff preserve existing git flag +hg qrefresh --git +echo a >> lines +hg qdiff +
--- a/tests/test-mq-qdiff.out Fri Jan 01 21:21:34 2010 +0100 +++ b/tests/test-mq-qdiff.out Fri Jan 01 21:49:05 2010 +0100 @@ -103,3 +103,22 @@ 7 8 9 +% qdiff preserve existing git flag +diff --git a/lines b/lines +--- a/lines ++++ b/lines +@@ -1,9 +1,12 @@ ++ ++ + 1 + 2 + 3 + 4 +-hello world +-goodbye world ++hello world ++ goodbye world + 7 + 8 + 9 ++a