Mercurial > hg
changeset 12292:7cf258b2d0cc stable
merge with i18n
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 14 Sep 2010 16:20:34 -0500 |
parents | 2ca3a845f640 (current diff) a7d3147bd4b3 (diff) |
children | f2f6d838064a fe20536c09d4 |
files | |
diffstat | 4 files changed, 50 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/color.py Fri Sep 10 21:05:51 2010 -0300 +++ b/hgext/color.py Tue Sep 14 16:20:34 2010 -0500 @@ -221,7 +221,7 @@ # http://msdn.microsoft.com/en-us/library/ms682088%28VS.85%29.aspx w32effects = { - 'none': 0, + 'none': -1, 'black': 0, 'red': FOREGROUND_RED, 'green': FOREGROUND_GREEN, @@ -231,7 +231,7 @@ 'cyan': FOREGROUND_BLUE | FOREGROUND_GREEN, 'white': FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, 'bold': FOREGROUND_INTENSITY, - 'black_background': 0, + 'black_background': 0x100, # unused value > 0x0f 'red_background': BACKGROUND_RED, 'green_background': BACKGROUND_GREEN, 'yellow_background': BACKGROUND_RED | BACKGROUND_GREEN, @@ -244,6 +244,9 @@ 'inverse': COMMON_LVB_REVERSE_VIDEO, # double-byte charsets only } + passthrough = set([FOREGROUND_INTENSITY, BACKGROUND_INTENSITY, + COMMON_LVB_UNDERSCORE, COMMON_LVB_REVERSE_VIDEO]) + stdout = GetStdHandle(STD_OUTPUT_HANDLE) try: origattr = stdout.GetConsoleScreenBufferInfo()['Attributes'] @@ -256,13 +259,23 @@ def win32print(text, orig, **opts): label = opts.get('label', '') - attr = 0 + attr = origattr + + def mapcolor(val, attr): + if val == -1: + return origattr + elif val in passthrough: + return attr | val + elif val > 0x0f: + return (val & 0x70) | (attr & 0x8f) + else: + return (val & 0x07) | (attr & 0xf8) # determine console attributes based on labels for l in label.split(): style = _styles.get(l, '') for effect in style.split(): - attr |= w32effects[effect] + attr = mapcolor(w32effects[effect], attr) # hack to ensure regexp finds data if not text.startswith('\033['): @@ -273,9 +286,8 @@ while m: for sattr in m.group(1).split(';'): if sattr: - val = int(sattr) - attr = val and attr|val or 0 - stdout.SetConsoleTextAttribute(attr or origattr) + attr = mapcolor(int(sattr), attr) + stdout.SetConsoleTextAttribute(attr) orig(m.group(2), **opts) m = re.match(ansire, m.group(3))
--- a/hgext/convert/darcs.py Fri Sep 10 21:05:51 2010 -0300 +++ b/hgext/convert/darcs.py Tue Sep 14 16:20:34 2010 -0500 @@ -83,6 +83,8 @@ shutil.rmtree(self.tmppath, ignore_errors=True) def xml(self, cmd, **kwargs): + # NOTE: darcs is currently encoding agnostic and will print + # patch metadata byte-for-byte, even in the XML changelog. etree = ElementTree() fp = self._run(cmd, **kwargs) etree.parse(fp) @@ -107,8 +109,12 @@ elt = self.changes[rev] date = util.strdate(elt.get('local_date'), '%a %b %d %H:%M:%S %Z %Y') desc = elt.findtext('name') + '\n' + elt.findtext('comment', '') - return commit(author=elt.get('author'), date=util.datestr(date), - desc=desc.strip(), parents=self.parents[rev]) + # etree can return unicode objects for name, comment, and author, + # so recode() is used to ensure str objects are emitted. + return commit(author=self.recode(elt.get('author')), + date=util.datestr(date), + desc=self.recode(desc).strip(), + parents=self.parents[rev]) def pull(self, rev): output, status = self.run('pull', self.path, all=True,
--- a/tests/test-convert-darcs Fri Sep 10 21:05:51 2010 -0300 +++ b/tests/test-convert-darcs Tue Sep 14 16:20:34 2010 -0500 @@ -56,13 +56,18 @@ rm dir/d2 darcs mv dir dir2 darcs record -a -l -m p3 -cd .. + +echo % test utf-8 commit message and author +echo g > g +# darcs is encoding agnostic, so it takes whatever bytes it's given +darcs record -a -l -m 'p4: desc ñ' -A 'author ñ' glog() { - hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@" + HGENCODING=utf-8 hg glog --template '{rev} "{desc|firstline}" ({author}) files: {files}\n' "$@" } +cd .. hg convert darcs-repo darcs-repo-hg # The converter does not currently handle patch conflicts very well. # When they occur, it reverts *all* changes and moves forward,
--- a/tests/test-convert-darcs.out Fri Sep 10 21:05:51 2010 -0300 +++ b/tests/test-convert-darcs.out Tue Sep 14 16:20:34 2010 -0500 @@ -12,26 +12,32 @@ Finished recording patch 'p2' % test file and directory move Finished recording patch 'p3' +% test utf-8 commit message and author +Finished recording patch 'p4: desc ñ' initializing destination darcs-repo-hg repository scanning source... sorting... converting... -4 p0 -3 p1.2 -2 p1.1 -1 p2 -0 p3 -o 4 "p3" files: dir/d dir/d2 dir2/d f ff +5 p0 +4 p1.2 +3 p1.1 +2 p2 +1 p3 +0 p4: desc ? +o 5 "p4: desc ñ" (author ñ) files: g | -o 3 "p2" files: a dir/d dir/d2 f +o 4 "p3" (test@example.org) files: dir/d dir/d2 dir2/d f ff | -o 2 "p1.1" files: +o 3 "p2" (test@example.org) files: a dir/d dir/d2 f | -o 1 "p1.2" files: a b +o 2 "p1.1" (test@example.org) files: | -o 0 "p0" files: a +o 1 "p1.2" (test@example.org) files: a b +| +o 0 "p0" (test@example.org) files: a 7225b30cdf38257d5cc7780772c051b6f33e6d6b 644 a 1e88685f5ddec574a34c70af492f95b6debc8741 644 b 37406831adc447ec2385014019599dfec953c806 644 dir2/d b783a337463792a5c7d548ad85a7d3253c16ba8c 644 ff +0973eb1b2ecc4de7fafe7447ce1b7462108b4848 644 g