hgsubversion: refactor method for svnrev template keyword to easy wrapping

Summary:
This commit is just a simple refactor of the method for the resolving
the `svnrev` template keyword. In particular, we split the method so that it
can be easily wrapped by other extensions like globalrevs in D16361887.

Reviewed By: quark-zju

Differential Revision: D16361888

fbshipit-source-id: 9f20fb33afd2b286c4f30571fa257b8284f2bb54
This commit is contained in:
Saurabh Singh 2019-07-18 12:19:29 -07:00 committed by Facebook Github Bot
parent 53cc0f0766
commit 0766f36b29

View File

@ -432,9 +432,18 @@ configitem("hgsubversion", "rewritesvncommitwithhghash", default=False)
@templatekeyword("svnrev")
def svnrevkw(**args):
def svnrevkw(repo, ctx, **kwargs):
""":svnrev: String. Converted subversion revision number."""
convertinfo = util.getsvnrev(args["ctx"], "")
return _svnrevkw(repo, ctx, **kwargs)
def _svnrevkw(repo, ctx, **kwargs):
""":svnrev: String. Converted subversion revision number.
Isolating this method allows easy wrapping by other extensions like
globalrevs.
"""
convertinfo = util.getsvnrev(ctx, "")
if not convertinfo or not convertinfo.startswith("svn:"):
return ""