Mercurial > public > mercurial-scm > hg
diff mercurial/templatekw.py @ 21897:764adc332f6e
templatekw: add 'subrepos' keyword to show updated subrepositories
'subrepos' template keyword newly added by this patch shows updated
subrepositories.
For the compatibility with the list of subrepositories shown in the
editor at commit:
- 'subrepos' is empty, at revisions removing '.hgsub' itself
- 'subrepos' is calculated between the revision and the first parent
of it, at merge revisions
To avoid silent regression, this patch also confirms "hg diff" of
".hgsubstate" and parents for each target revisions in the test.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 15 Jul 2014 23:34:13 +0900 |
parents | 2b41ee1b5ea1 |
children | 293930a1fa0a |
line wrap: on
line diff
--- a/mercurial/templatekw.py Tue Jul 15 23:34:13 2014 +0900 +++ b/mercurial/templatekw.py Tue Jul 15 23:34:13 2014 +0900 @@ -356,6 +356,22 @@ """:rev: Integer. The repository-local changeset revision number.""" return ctx.rev() +def showsubrepos(**args): + """:subrepos: List of strings. Updated subrepositories in the changeset.""" + ctx = args['ctx'] + substate = ctx.substate + if not substate: + return showlist('subrepo', [], **args) + psubstate = ctx.parents()[0].substate or {} + subrepos = [] + for sub in substate: + if sub not in psubstate or substate[sub] != psubstate[sub]: + subrepos.append(sub) # modified or newly added in ctx + for sub in psubstate: + if sub not in substate: + subrepos.append(sub) # removed in ctx + return showlist('subrepo', sorted(subrepos), **args) + def showtags(**args): """:tags: List of strings. Any tags associated with the changeset.""" return showlist('tag', args['ctx'].tags(), **args) @@ -397,6 +413,7 @@ 'phase': showphase, 'phaseidx': showphaseidx, 'rev': showrev, + 'subrepos': showsubrepos, 'tags': showtags, }