| 17 | | from trac.versioncontrol import Changeset, Node, Repository, \ |
|---|
| 18 | | IRepositoryConnector, NoSuchChangeset, NoSuchNode |
|---|
| | 17 | from trac.util.datefmt import utc |
|---|
| | 18 | from trac.versioncontrol.api import \ |
|---|
| | 19 | Changeset, Node, Repository, IRepositoryConnector, NoSuchChangeset, NoSuchNode |
|---|
| 25 | | implements(IRepositoryConnector, IWikiSyntaxProvider) |
|---|
| 26 | | |
|---|
| 27 | | ####################### |
|---|
| 28 | | # IWikiSyntaxProvider |
|---|
| 29 | | |
|---|
| 30 | | def get_wiki_syntax(self): |
|---|
| 31 | | yield (r'\b[0-9a-fA-F]{40,40}\b', |
|---|
| 32 | | lambda fmt, sha, match: |
|---|
| 33 | | self._format_sha_link(fmt, 'changeset', sha, sha)) |
|---|
| 34 | | |
|---|
| 35 | | def get_link_resolvers(self): |
|---|
| 36 | | yield ('sha', self._format_sha_link) |
|---|
| | 36 | implements(IRepositoryConnector, IWikiSyntaxProvider, IPropertyRenderer) |
|---|
| 41 | | return html.a(label, class_="changeset", |
|---|
| 42 | | title=shorten_line(changeset.message), |
|---|
| 43 | | href=formatter.href.changeset(sha)) |
|---|
| | 41 | return tag.a(label, class_="changeset", |
|---|
| | 42 | title=shorten_line(changeset.message), |
|---|
| | 43 | href=formatter.href.changeset(sha)) |
|---|
| 45 | | return html.a(label, class_="missing changeset", |
|---|
| 46 | | href=formatter.href.changeset(sha), |
|---|
| 47 | | title=unicode(e), rel="nofollow") |
|---|
| 48 | | |
|---|
| | 45 | return tag.a(label, class_="missing changeset", |
|---|
| | 46 | href=formatter.href.changeset(sha), |
|---|
| | 47 | title=unicode(e), rel="nofollow") |
|---|
| | 48 | |
|---|
| | 49 | ####################### |
|---|
| | 50 | # IPropertyRenderer |
|---|
| | 51 | |
|---|
| | 52 | # relied upon by GitChangeset |
|---|
| | 53 | |
|---|
| | 54 | def match_property(self, name, mode): |
|---|
| | 55 | if (name == 'Parents' and mode == 'revprop'): |
|---|
| | 56 | return 8 # default renderer has priority 1 |
|---|
| | 57 | return 0 |
|---|
| | 58 | |
|---|
| | 59 | def render_property(self, name, mode, context, props): |
|---|
| | 60 | assert name == 'Parents' |
|---|
| | 61 | |
|---|
| | 62 | revs = props[name] |
|---|
| | 63 | |
|---|
| | 64 | def sha_link(sha): |
|---|
| | 65 | return self._format_sha_link(context, 'sha', sha, sha) |
|---|
| | 66 | |
|---|
| | 67 | return tag([tag(sha_link(rev), ', ') for rev in revs[:-1]], |
|---|
| | 68 | sha_link(revs[-1])) |
|---|
| | 69 | |
|---|
| | 70 | |
|---|
| | 71 | ####################### |
|---|
| | 72 | # IWikiSyntaxProvider |
|---|
| | 73 | |
|---|
| | 74 | def get_wiki_syntax(self): |
|---|
| | 75 | yield (r'\b[0-9a-fA-F]{40,40}\b', |
|---|
| | 76 | lambda fmt, sha, match: |
|---|
| | 77 | self._format_sha_link(fmt, 'changeset', sha, sha)) |
|---|
| | 78 | |
|---|
| | 79 | def get_link_resolvers(self): |
|---|
| | 80 | yield ('sha', self._format_sha_link) |
|---|
| 247 | | for k in self.props: |
|---|
| 248 | | v = self.props[k] |
|---|
| 249 | | if k in ['committer', 'author']: |
|---|
| 250 | | yield("git-"+k, ", ".join(v), False, 'author') |
|---|
| 251 | | if k in ['parent']: |
|---|
| 252 | | yield("git-"+k, ", ".join(("[%s]" % c) for c in v), True, 'changeset') |
|---|
| | 287 | properties = {} |
|---|
| | 288 | if 'parent' in self.props: |
|---|
| | 289 | properties['Parents'] = self.props['parent'] |
|---|
| | 290 | if 'committer' in self.props: |
|---|
| | 291 | properties['git-committer'] = "\n".join(self.props['committer']) |
|---|
| | 292 | if 'author' in self.props: |
|---|
| | 293 | git_author = "\n".join(self.props['author']) |
|---|
| | 294 | if not (properties.has_key('git-committer') and |
|---|
| | 295 | properties['git-committer'] == git_author): |
|---|
| | 296 | properties['git-author'] = git_author |
|---|
| | 297 | |
|---|
| | 298 | return properties |
|---|