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