[PATCH] color: enabled color support for export command (issue1507)
Matt Mackall
mpm at selenic.com
Thu Aug 30 16:25:15 CDT 2012
On Thu, 2012-08-30 at 03:57 -0700, Ankur Dahiya wrote:
> # HG changeset patch
> # User Ankur Dahiya <ankurd at fb.com>
> # Date 1346085469 25200
> # Node ID decb610de84f84e9de32ba3a8073eeb2235496a6
> # Parent 99a2a4ae35e2180b7f825ef2677c36d538eac4ba
> color: enabled color support for export command (issue1507)
>
> The export command didn't output the diffs in color, even when color support
> was enabled. This patch fixes that by making the export command use the default
> ui.write method, instead of directly manipulating the ui.fout file object.
> Also added a test case to verify color output to test-export.t.
I guess this is ok. Historically, 'hg export' exists to work with
'patch' or 'hg import', being pretty is not a goal. But I guess I
occasionally use 'hg export' to look at patches rather than 'hg log
-vpr'.
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -547,30 +547,37 @@
> prev = (parents and parents[0]) or nullid
>
> shouldclose = False
> - if not fp:
> + if not fp and len(template) > 0:
I can't tell if this change has a purpose, as it isn't mentioned in
$DESC.
> desc_lines = ctx.description().rstrip().split('\n')
> desc = desc_lines[0] #Commit always has a first line.
> fp = makefileobj(repo, template, node, desc=desc, total=total,
> seqno=seqno, revwidth=revwidth, mode='ab')
> if fp != template:
> shouldclose = True
> - if fp != sys.stdout and util.safehasattr(fp, 'name'):
> + if fp and fp != sys.stdout and util.safehasattr(fp, 'name'):
Same here.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list