Show More
@@ -225,7 +225,6 b' class queue(object):' | |||
|
225 | 225 | self.guards_path = "guards" |
|
226 | 226 | self.active_guards = None |
|
227 | 227 | self.guards_dirty = False |
|
228 | self._diffopts = None | |
|
229 | 228 | |
|
230 | 229 | @util.propertycache |
|
231 | 230 | def applied(self): |
@@ -259,10 +258,16 b' class queue(object):' | |||
|
259 | 258 | self.guards_dirty = False |
|
260 | 259 | self.active_guards = None |
|
261 | 260 | |
|
262 | def diffopts(self): | |
|
263 | if self._diffopts is None: | |
|
264 | self._diffopts = patch.diffopts(self.ui) | |
|
265 | return self._diffopts | |
|
261 | def diffopts(self, opts={}, patchfn=None): | |
|
262 | diffopts = patch.diffopts(self.ui, opts) | |
|
263 | if patchfn: | |
|
264 | # if the patch was a git patch, refresh it as a git patch | |
|
265 | patchf = self.opener(patchfn, 'r') | |
|
266 | for line in patchf: | |
|
267 | if line.startswith('diff --git'): | |
|
268 | diffopts.git = True | |
|
269 | break | |
|
270 | return diffopts | |
|
266 | 271 | |
|
267 | 272 | def join(self, *p): |
|
268 | 273 | return os.path.join(self.path, *p) |
@@ -418,24 +423,24 b' class queue(object):' | |||
|
418 | 423 | except OSError, inst: |
|
419 | 424 | self.ui.warn(_('error removing undo: %s\n') % str(inst)) |
|
420 | 425 | |
|
421 | def printdiff(self, repo, node1, node2=None, files=None, | |
|
426 | def printdiff(self, repo, diffopts, node1, node2=None, files=None, | |
|
422 | 427 | fp=None, changes=None, opts={}): |
|
423 | 428 | stat = opts.get('stat') |
|
424 | 429 | if stat: |
|
425 | 430 | opts['unified'] = '0' |
|
426 | 431 | |
|
427 | 432 | m = cmdutil.match(repo, files, opts) |
|
428 |
chunks = patch.diff(repo, node1, node2, m, changes, |
|
|
433 | chunks = patch.diff(repo, node1, node2, m, changes, diffopts) | |
|
429 | 434 | write = fp is None and repo.ui.write or fp.write |
|
430 | 435 | if stat: |
|
431 | 436 | width = self.ui.interactive() and util.termwidth() or 80 |
|
432 | 437 | write(patch.diffstat(util.iterlines(chunks), width=width, |
|
433 |
git= |
|
|
438 | git=diffopts.git)) | |
|
434 | 439 | else: |
|
435 | 440 | for chunk in chunks: |
|
436 | 441 | write(chunk) |
|
437 | 442 | |
|
438 | def mergeone(self, repo, mergeq, head, patch, rev): | |
|
443 | def mergeone(self, repo, mergeq, head, patch, rev, diffopts): | |
|
439 | 444 | # first try just applying the patch |
|
440 | 445 | (err, n) = self.apply(repo, [ patch ], update_status=False, |
|
441 | 446 | strict=True, merge=rev) |
@@ -468,7 +473,7 b' class queue(object):' | |||
|
468 | 473 | comments = str(ph) |
|
469 | 474 | if comments: |
|
470 | 475 | patchf.write(comments) |
|
471 | self.printdiff(repo, head, n, fp=patchf) | |
|
476 | self.printdiff(repo, diffopts, head, n, fp=patchf) | |
|
472 | 477 | patchf.close() |
|
473 | 478 | self.removeundo(repo) |
|
474 | 479 | return (0, n) |
@@ -492,7 +497,7 b' class queue(object):' | |||
|
492 | 497 | return pp[1] |
|
493 | 498 | return pp[0] |
|
494 | 499 | |
|
495 | def mergepatch(self, repo, mergeq, series): | |
|
500 | def mergepatch(self, repo, mergeq, series, diffopts): | |
|
496 | 501 | if len(self.applied) == 0: |
|
497 | 502 | # each of the patches merged in will have two parents. This |
|
498 | 503 | # can confuse the qrefresh, qdiff, and strip code because it |
@@ -522,7 +527,7 b' class queue(object):' | |||
|
522 | 527 | self.ui.warn(_("patch %s is not applied\n") % patch) |
|
523 | 528 | return (1, None) |
|
524 | 529 | rev = bin(info[1]) |
|
525 |
|
|
|
530 | err, head = self.mergeone(repo, mergeq, head, patch, rev, diffopts) | |
|
526 | 531 | if head: |
|
527 | 532 | self.applied.append(statusentry(hex(head), patch)) |
|
528 | 533 | self.applied_dirty = 1 |
@@ -757,6 +762,7 b' class queue(object):' | |||
|
757 | 762 | date = opts.get('date') |
|
758 | 763 | if date: |
|
759 | 764 | date = util.parsedate(date) |
|
765 | diffopts = self.diffopts({'git': opts.get('git')}) | |
|
760 | 766 | self.check_reserved_name(patchfn) |
|
761 | 767 | if os.path.exists(self.join(patchfn)): |
|
762 | 768 | raise util.Abort(_('patch "%s" already exists') % patchfn) |
@@ -806,8 +812,6 b' class queue(object):' | |||
|
806 | 812 | msg = msg + "\n\n" |
|
807 | 813 | p.write(msg) |
|
808 | 814 | if commitfiles: |
|
809 | diffopts = self.diffopts() | |
|
810 | if opts.get('git'): diffopts.git = True | |
|
811 | 815 | parent = self.qparents(repo, n) |
|
812 | 816 | chunks = patch.diff(repo, node1=parent, node2=n, |
|
813 | 817 | match=match, opts=diffopts) |
@@ -932,6 +936,7 b' class queue(object):' | |||
|
932 | 936 | |
|
933 | 937 | def push(self, repo, patch=None, force=False, list=False, |
|
934 | 938 | mergeq=None, all=False): |
|
939 | diffopts = self.diffopts() | |
|
935 | 940 | wlock = repo.wlock() |
|
936 | 941 | try: |
|
937 | 942 | if repo.dirstate.parents()[0] not in repo.heads(): |
@@ -994,7 +999,7 b' class queue(object):' | |||
|
994 | 999 | all_files = {} |
|
995 | 1000 | try: |
|
996 | 1001 | if mergeq: |
|
997 | ret = self.mergepatch(repo, mergeq, s) | |
|
1002 | ret = self.mergepatch(repo, mergeq, s, diffopts) | |
|
998 | 1003 | else: |
|
999 | 1004 | ret = self.apply(repo, s, list, all_files=all_files) |
|
1000 | 1005 | except: |
@@ -1137,8 +1142,8 b' class queue(object):' | |||
|
1137 | 1142 | node1, node2 = None, qp |
|
1138 | 1143 | else: |
|
1139 | 1144 | node1, node2 = qp, None |
|
1140 |
|
|
|
1141 | self.printdiff(repo, node1, node2, files=pats, opts=opts) | |
|
1145 | diffopts = self.diffopts(opts) | |
|
1146 | self.printdiff(repo, diffopts, node1, node2, files=pats, opts=opts) | |
|
1142 | 1147 | |
|
1143 | 1148 | def refresh(self, repo, pats=None, **opts): |
|
1144 | 1149 | if len(self.applied) == 0: |
@@ -1160,14 +1165,7 b' class queue(object):' | |||
|
1160 | 1165 | patchparent = self.qparents(repo, top) |
|
1161 | 1166 | ph = patchheader(self.join(patchfn)) |
|
1162 | 1167 | |
|
1163 | patchf = self.opener(patchfn, 'r') | |
|
1164 | ||
|
1165 | # if the patch was a git patch, refresh it as a git patch | |
|
1166 | for line in patchf: | |
|
1167 | if line.startswith('diff --git'): | |
|
1168 | self.diffopts().git = True | |
|
1169 | break | |
|
1170 | ||
|
1168 | diffopts = self.diffopts({'git': opts.get('git')}, patchfn) | |
|
1171 | 1169 | if msg: |
|
1172 | 1170 | ph.setmessage(msg) |
|
1173 | 1171 | if newuser: |
@@ -1178,15 +1176,10 b' class queue(object):' | |||
|
1178 | 1176 | # only commit new patch when write is complete |
|
1179 | 1177 | patchf = self.opener(patchfn, 'w', atomictemp=True) |
|
1180 | 1178 | |
|
1181 | patchf.seek(0) | |
|
1182 | patchf.truncate() | |
|
1183 | ||
|
1184 | 1179 | comments = str(ph) |
|
1185 | 1180 | if comments: |
|
1186 | 1181 | patchf.write(comments) |
|
1187 | 1182 | |
|
1188 | if opts.get('git'): | |
|
1189 | self.diffopts().git = True | |
|
1190 | 1183 | tip = repo.changelog.tip() |
|
1191 | 1184 | if top == tip: |
|
1192 | 1185 | # if the top of our patch queue is also the tip, there is an |
@@ -1252,12 +1245,12 b' class queue(object):' | |||
|
1252 | 1245 | c = [filter(matchfn, l) for l in (m, a, r)] |
|
1253 | 1246 | match = cmdutil.matchfiles(repo, set(c[0] + c[1] + c[2])) |
|
1254 | 1247 | chunks = patch.diff(repo, patchparent, match=match, |
|
1255 |
changes=c, opts= |
|
|
1248 | changes=c, opts=diffopts) | |
|
1256 | 1249 | for chunk in chunks: |
|
1257 | 1250 | patchf.write(chunk) |
|
1258 | 1251 | |
|
1259 | 1252 | try: |
|
1260 |
if |
|
|
1253 | if diffopts.git: | |
|
1261 | 1254 | copies = {} |
|
1262 | 1255 | for dst in a: |
|
1263 | 1256 | src = repo.dirstate.copied(dst) |
@@ -1336,7 +1329,7 b' class queue(object):' | |||
|
1336 | 1329 | '(revert --all, qpush to recover)\n')) |
|
1337 | 1330 | raise |
|
1338 | 1331 | else: |
|
1339 | self.printdiff(repo, patchparent, fp=patchf) | |
|
1332 | self.printdiff(repo, diffopts, patchparent, fp=patchf) | |
|
1340 | 1333 | patchf.rename() |
|
1341 | 1334 | added = repo.status()[1] |
|
1342 | 1335 | for a in added: |
@@ -1616,9 +1609,7 b' class queue(object):' | |||
|
1616 | 1609 | % rev[0]) |
|
1617 | 1610 | lastparent = None |
|
1618 | 1611 | |
|
1619 | if git: | |
|
1620 | self.diffopts().git = True | |
|
1621 | ||
|
1612 | diffopts = self.diffopts({'git': git}) | |
|
1622 | 1613 | for r in rev: |
|
1623 | 1614 | p1, p2 = repo.changelog.parentrevs(r) |
|
1624 | 1615 | n = repo.changelog.node(r) |
@@ -1637,7 +1628,7 b' class queue(object):' | |||
|
1637 | 1628 | self.full_series.insert(0, patchname) |
|
1638 | 1629 | |
|
1639 | 1630 | patchf = self.opener(patchname, "w") |
|
1640 |
patch.export(repo, [n], fp=patchf, opts= |
|
|
1631 | patch.export(repo, [n], fp=patchf, opts=diffopts) | |
|
1641 | 1632 | patchf.close() |
|
1642 | 1633 | |
|
1643 | 1634 | se = statusentry(hex(n), patchname) |
General Comments 0
You need to be logged in to leave comments.
Login now