Mercurial > hg
changeset 10046:0c23b0b3516b
color: Add support for bookmarks
author | David Soria Parra <dsp@php.net> |
---|---|
date | Fri, 11 Dec 2009 11:04:31 +0100 |
parents | d1f9640e9a67 |
children | 5b9709f81986 |
files | hgext/color.py |
diffstat | 1 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/color.py Fri Dec 11 11:04:31 2009 +0100 +++ b/hgext/color.py Fri Dec 11 11:04:31 2009 +0100 @@ -56,6 +56,8 @@ diff.inserted = green diff.changed = white diff.trailingwhitespace = bold red_background + + bookmarks.current = green ''' import os, sys @@ -138,6 +140,21 @@ 'clean': ['none'], 'copied': ['none'], } +_bookmark_effects = { 'current': ['green'] } + +def colorbookmarks(orig, ui, repo, *pats, **opts): + def colorize(orig, s): + lines = s.split('\n') + for i, line in enumerate(lines): + if line.startswith(" *"): + lines[i] = render_effects(line, _bookmark_effects['current']) + orig('\n'.join(lines)) + oldwrite = extensions.wrapfunction(ui, 'write', colorize) + try: + orig(ui, repo, *pats, **opts) + finally: + ui.write = oldwrite + def colorqseries(orig, ui, repo, *dummy, **opts): '''run the qseries command with colored output''' ui.pushbuffer() @@ -275,6 +292,14 @@ except KeyError: churn = None + try: + bookmarks = extensions.find('bookmarks') + _setupcmd(ui, 'bookmarks', bookmarks.cmdtable, colorbookmarks, + _bookmark_effects) + except KeyError: + # The bookmarks extension is not enabled + pass + def _setupcmd(ui, cmd, table, func, effectsmap): '''patch in command to command table and load effect map''' def nocolor(orig, *args, **opts):