hgext/color.py
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Mon, 26 Jun 2017 03:38:12 +0900
changeset 33075 7f569ce30216
parent 31633 e86eb75e74ce
child 33521 de1cb83728f8
permissions -rw-r--r--
keyword: restore kwtemplater.restrict at the end of wrapped patch.diff Before this patch, kwdiff doesn't restore kwtemplater.restrict after invocation of wrapped patch.diff(). This suppresses keyword expansion at subsequent filelog.read(). Typical usecase of this issue is "hg cat" after "hg diff" with command server. In this case, kwtemplater.restrict=True is kept in command server process even after "hg diff". To ensure kwtemplater.restrict=True while original patch.diff() running, this patch makes kwdiff() yield values returned by it, because it returns generator object. Strictly speaking, if filelog.read() is invoked before completely evaluating the result of previous patch.diff(), keyword expansion is still suppressed, because kwtemplater.restrict isn't restored yet. But this fixing should be reasonable enough, because patch.diff() is consumed immediately, AFAIK.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22771
d6274291fac1 color: update description of the extension
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 22763
diff changeset
     1
# color.py color output for Mercurial commands
5787
b7b22a2ade2e Add colored output to status and qseries commands
Kevin Christen <kevin.christen@gmail.com>
parents:
diff changeset
     2
#
b7b22a2ade2e Add colored output to status and qseries commands
Kevin Christen <kevin.christen@gmail.com>
parents:
diff changeset
     3
# Copyright (C) 2007 Kevin Christen <kevin.christen@gmail.com>
b7b22a2ade2e Add colored output to status and qseries commands
Kevin Christen <kevin.christen@gmail.com>
parents:
diff changeset
     4
#
15771
425c1309718f color: Use the same GPL boilerplate as most hg files
Augie Fackler <durin42@gmail.com>
parents: 15048
diff changeset
     5
# This software may be used and distributed according to the terms of the
425c1309718f color: Use the same GPL boilerplate as most hg files
Augie Fackler <durin42@gmail.com>
parents: 15048
diff changeset
     6
# GNU General Public License version 2 or any later version.
5787
b7b22a2ade2e Add colored output to status and qseries commands
Kevin Christen <kevin.christen@gmail.com>
parents:
diff changeset
     7
31138
df0a0734304a color: update main documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
     8
'''enable Mercurial color mode (DEPRECATED)
30176
9f41b66cffc0 color: add some documentation for custom terminfo codes
Danek Duvall <danek.duvall@oracle.com>
parents: 30175
diff changeset
     9
31633
e86eb75e74ce color: fix grammar in help text
Matt Harbison <matt_harbison@yahoo.com>
parents: 31138
diff changeset
    10
This extension enables Mercurial color mode. The feature is now directly
31138
df0a0734304a color: update main documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
    11
available in Mercurial core. You can access it using::
7456
79eb16db5e4a color: diff colorization
Brodie Rao <me+hg@dackz.net>
parents: 7455
diff changeset
    12
31138
df0a0734304a color: update main documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
    13
  [ui]
df0a0734304a color: update main documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
    14
  color = auto
14769
9adce4b38ed1 color: for the sake of "less -R", default to ansi in auto mode (issue2792)
Brodie Rao <brodie@bitheap.org>
parents: 14768
diff changeset
    15
31138
df0a0734304a color: update main documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
    16
See :hg:`help color` for details.
5787
b7b22a2ade2e Add colored output to status and qseries commands
Kevin Christen <kevin.christen@gmail.com>
parents:
diff changeset
    17
'''
b7b22a2ade2e Add colored output to status and qseries commands
Kevin Christen <kevin.christen@gmail.com>
parents:
diff changeset
    18
28968
a5d449a7bc8f py3: make color use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 28633
diff changeset
    19
from __future__ import absolute_import
5787
b7b22a2ade2e Add colored output to status and qseries commands
Kevin Christen <kevin.christen@gmail.com>
parents:
diff changeset
    20
31138
df0a0734304a color: update main documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31135
diff changeset
    21
from mercurial import color
5787
b7b22a2ade2e Add colored output to status and qseries commands
Kevin Christen <kevin.christen@gmail.com>
parents:
diff changeset
    22
29852
d5883fd055c6 extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents: 29205
diff changeset
    23
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
25186
80c5b2666a96 extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents: 24848
diff changeset
    24
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
80c5b2666a96 extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents: 24848
diff changeset
    25
# be specifying the version(s) of Mercurial they are tested with, or
80c5b2666a96 extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents: 24848
diff changeset
    26
# leave the attribute unspecified.
29852
d5883fd055c6 extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents: 29205
diff changeset
    27
testedwith = 'ships-with-hg-core'
16743
38caf405d010 hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents: 15771
diff changeset
    28
12693
33f0682ba8b1 color: add global option in extsetup() instead of globally
Brodie Rao <brodie@bitheap.org>
parents: 12278
diff changeset
    29
def extsetup(ui):
31121
8346b2f09e79 color: add the definition of '--color' in core
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31120
diff changeset
    30
    # change default color config
31127
7fec37746417 color: add a 'ui.color' option to control color behavior
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 31122
diff changeset
    31
    color._enabledbydefault = True