##// END OF EJS Templates
color: enabled color support for export command (issue1507)...
Ankur Dahiya -
r17460:a306837f default
parent child Browse files
Show More
@@ -547,30 +547,37 b" def export(repo, revs, template='hg-%h.p"
547 547 prev = (parents and parents[0]) or nullid
548 548
549 549 shouldclose = False
550 if not fp:
550 if not fp and len(template) > 0:
551 551 desc_lines = ctx.description().rstrip().split('\n')
552 552 desc = desc_lines[0] #Commit always has a first line.
553 553 fp = makefileobj(repo, template, node, desc=desc, total=total,
554 554 seqno=seqno, revwidth=revwidth, mode='ab')
555 555 if fp != template:
556 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 558 repo.ui.note("%s\n" % fp.name)
559 559
560 fp.write("# HG changeset patch\n")
561 fp.write("# User %s\n" % ctx.user())
562 fp.write("# Date %d %d\n" % ctx.date())
560 if not fp:
561 write = repo.ui.write
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 570 if branch and branch != 'default':
564 fp.write("# Branch %s\n" % branch)
565 fp.write("# Node ID %s\n" % hex(node))
566 fp.write("# Parent %s\n" % hex(prev))
571 write("# Branch %s\n" % branch)
572 write("# Node ID %s\n" % hex(node))
573 write("# Parent %s\n" % hex(prev))
567 574 if len(parents) > 1:
568 fp.write("# Parent %s\n" % hex(parents[1]))
569 fp.write(ctx.description().rstrip())
570 fp.write("\n\n")
575 write("# Parent %s\n" % hex(parents[1]))
576 write(ctx.description().rstrip())
577 write("\n\n")
571 578
572 for chunk in patch.diff(repo, prev, node, opts=opts):
573 fp.write(chunk)
579 for chunk, label in patch.diffui(repo, prev, node, opts=opts):
580 write(chunk, label=label)
574 581
575 582 if shouldclose:
576 583 fp.close()
@@ -144,4 +144,28 b' Catch exporting unknown revisions (espec'
144 144 abort: export requires at least one changeset
145 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 171 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now