From patchwork Wed May 7 22:54:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,4] subrepo: add revdetails() method From: Angel Ezquerra X-Patchwork-Id: 4658 Message-Id: <874013facd42bd2a8bbd.1399503297@Angel-PC.localdomain> To: mercurial-devel@selenic.com Date: Thu, 08 May 2014 00:54:57 +0200 # HG changeset patch # User Angel Ezquerra # Date 1399414642 -7200 # Wed May 07 00:17:22 2014 +0200 # Node ID 874013facd42bd2a8bbd07634cad02448709c5ac # Parent c1035596456a23347b3cfb510bf7c62a68166b90 subrepo: add revdetails() method This method is able to show the "revision details" for a given revision. Currently for mercurial subrepos it returns a string which resembles a lot what the default template writes to the console when doing hg log. For all other types of subrepos we just return the revision id as a string. We could not use the templater to get this info because the templater writes to the console (i.e. it does not return a string that we can use). This method will be used on the next revision. diff -r c1035596456a -r 874013facd42 mercurial/subrepo.py --- a/mercurial/subrepo.py Wed May 07 00:13:22 2014 +0200 +++ b/mercurial/subrepo.py Wed May 07 00:17:22 2014 +0200 @@ -505,6 +505,9 @@ def shortid(self, revid): return revid + def revdetails(self, revid): + return 'changeset: %s\n' % str(revid) + class hgsubrepo(abstractsubrepo): def __init__(self, ctx, path, state): self._path = path @@ -873,6 +876,29 @@ def shortid(self, revid): return revid[:12] + @annotatesubrepoerror + def revdetails(self, revid): + ctx = self._repo[revid] + desctemplate = 'changeset: %d:%s\n' \ + '%s' \ + '%s' \ + 'user: %s\n' \ + 'date: %s\n' \ + 'summary: %s\n' + branchinfo = '' + branch = ctx.branch() + if branch != 'default': + branchinfo = 'branch %s\n' % branch + taginfo = '' + tags = ctx.tags() + if tags: + taginfo = 'tags: %s\n' % ' '.join(tags) + date = util.datestr(ctx.date()) + return desctemplate % \ + (ctx.rev(), self.shortid(revid), + branchinfo, taginfo, + ctx.user(), date, ctx.description().splitlines()[0]) + class svnsubrepo(abstractsubrepo): def __init__(self, ctx, path, state): self._path = path