Show More
@@ -547,30 +547,37 def export(repo, revs, template='hg-%h.p | |||||
547 | prev = (parents and parents[0]) or nullid |
|
547 | prev = (parents and parents[0]) or nullid | |
548 |
|
548 | |||
549 | shouldclose = False |
|
549 | shouldclose = False | |
550 | if not fp: |
|
550 | if not fp and len(template) > 0: | |
551 | desc_lines = ctx.description().rstrip().split('\n') |
|
551 | desc_lines = ctx.description().rstrip().split('\n') | |
552 | desc = desc_lines[0] #Commit always has a first line. |
|
552 | desc = desc_lines[0] #Commit always has a first line. | |
553 | fp = makefileobj(repo, template, node, desc=desc, total=total, |
|
553 | fp = makefileobj(repo, template, node, desc=desc, total=total, | |
554 | seqno=seqno, revwidth=revwidth, mode='ab') |
|
554 | seqno=seqno, revwidth=revwidth, mode='ab') | |
555 | if fp != template: |
|
555 | if fp != template: | |
556 | shouldclose = True |
|
556 | shouldclose = True | |
557 | if fp != sys.stdout and util.safehasattr(fp, 'name'): |
|
557 | if fp and fp != sys.stdout and util.safehasattr(fp, 'name'): | |
558 | repo.ui.note("%s\n" % fp.name) |
|
558 | repo.ui.note("%s\n" % fp.name) | |
559 |
|
559 | |||
560 | fp.write("# HG changeset patch\n") |
|
560 | if not fp: | |
561 | fp.write("# User %s\n" % ctx.user()) |
|
561 | write = repo.ui.write | |
562 | fp.write("# Date %d %d\n" % ctx.date()) |
|
562 | else: | |
|
563 | def write(s, **kw): | |||
|
564 | fp.write(s) | |||
|
565 | ||||
|
566 | ||||
|
567 | write("# HG changeset patch\n") | |||
|
568 | write("# User %s\n" % ctx.user()) | |||
|
569 | write("# Date %d %d\n" % ctx.date()) | |||
563 | if branch and branch != 'default': |
|
570 | if branch and branch != 'default': | |
564 |
|
|
571 | write("# Branch %s\n" % branch) | |
565 |
|
|
572 | write("# Node ID %s\n" % hex(node)) | |
566 |
|
|
573 | write("# Parent %s\n" % hex(prev)) | |
567 | if len(parents) > 1: |
|
574 | if len(parents) > 1: | |
568 |
|
|
575 | write("# Parent %s\n" % hex(parents[1])) | |
569 |
|
|
576 | write(ctx.description().rstrip()) | |
570 |
|
|
577 | write("\n\n") | |
571 |
|
578 | |||
572 | for chunk in patch.diff(repo, prev, node, opts=opts): |
|
579 | for chunk, label in patch.diffui(repo, prev, node, opts=opts): | |
573 |
|
|
580 | write(chunk, label=label) | |
574 |
|
581 | |||
575 | if shouldclose: |
|
582 | if shouldclose: | |
576 | fp.close() |
|
583 | fp.close() |
@@ -144,4 +144,28 Catch exporting unknown revisions (espec | |||||
144 | abort: export requires at least one changeset |
|
144 | abort: export requires at least one changeset | |
145 | [255] |
|
145 | [255] | |
146 |
|
146 | |||
|
147 | Check for color output | |||
|
148 | $ echo "[color]" >> $HGRCPATH | |||
|
149 | $ echo "mode = ansi" >> $HGRCPATH | |||
|
150 | $ echo "[extensions]" >> $HGRCPATH | |||
|
151 | $ echo "color=" >> $HGRCPATH | |||
|
152 | ||||
|
153 | $ hg export --color always --nodates tip | |||
|
154 | # HG changeset patch | |||
|
155 | # User test | |||
|
156 | # Date 0 0 | |||
|
157 | # Node ID * (glob) | |||
|
158 | # Parent * (glob) | |||
|
159 | !"#$%&(,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ | |||
|
160 | ||||
|
161 | \x1b[0;1mdiff -r f3acbafac161 -r 197ecd81a57f foo\x1b[0m (esc) | |||
|
162 | \x1b[0;31;1m--- a/foo\x1b[0m (esc) | |||
|
163 | \x1b[0;32;1m+++ b/foo\x1b[0m (esc) | |||
|
164 | \x1b[0;35m@@ -10,3 +10,4 @@\x1b[0m (esc) | |||
|
165 | foo-9 | |||
|
166 | foo-10 | |||
|
167 | foo-11 | |||
|
168 | \x1b[0;32m+line\x1b[0m (esc) | |||
|
169 | ||||
|
170 | ||||
147 | $ cd .. |
|
171 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now