Mercurial > hg > trac > jungle > src > mercurial-plugin
changeset 18:985671b91ce4 1.0
Extract transplant property renderer into `render_source_prop`
author | cboos |
---|---|
date | Mon, 17 Sep 2012 21:08:25 +0200 |
parents | 32fd17a943f7 |
children | fd35822c53db |
files | tracext/hg/backend.py |
diffstat | 1 files changed, 15 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/tracext/hg/backend.py Mon Sep 17 20:49:05 2012 +0200 +++ b/tracext/hg/backend.py Mon Sep 17 21:08:25 2012 +0200 @@ -172,6 +172,20 @@ ### Components +def render_source_prop(repos, context, name, value): + try: + ctx = repos.changectx(value) + chgset = MercurialChangeset(repos, ctx) + href = context.href.changeset(ctx.hex(), repos.reponame) + link = tag.a(repos._display(ctx), class_="changeset", + title=shorten_line(chgset.message), href=href) + except NoSuchChangeset: + link = tag.a(hex(value), class_="missing changeset", + title=_("no such changeset"), rel="nofollow") + return RenderedProperty(name=name, content=link, + name_attributes=[("class", "property")]) + + class CsetPropertyRenderer(Component): implements(IPropertyRenderer) @@ -240,18 +254,7 @@ def render_property(self, name, mode, context, props): repos, value = props[name] if name == 'hg-transplant_source': - try: - ctx = repos.changectx(value) - chgset = MercurialChangeset(repos, ctx) - href = context.href.changeset(ctx.hex(), repos.reponame) - link = tag.a(repos._display(ctx), class_="changeset", - title=shorten_line(chgset.message), href=href) - except NoSuchChangeset: - link = tag.a(hex(value), class_="missing changeset", - title=_("no such changeset"), rel="nofollow") - return RenderedProperty(name=_("Transplant:"), content=link, - name_attributes=[("class", "property")]) - + return render_source_prop(repos, context, _("Transplant:"), value) elif name == 'hg-convert_revision': text = repos.to_u(value) if value.startswith('svn:'):