Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 24:c91a5c0f1be3
Add a "-d/--data" option that adds additional "KEY: VALUE" pairs into the revinfo.
Works for amending too.
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Thu, 10 Dec 2015 01:06:04 +0100 |
| parents | 09cc21f4e338 |
| children | 9e445fc5eea4 |
| files | extensions/revinfo.py |
| diffstat | 1 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/revinfo.py Mon Oct 12 09:11:43 2015 +0200 +++ b/extensions/revinfo.py Thu Dec 10 01:06:04 2015 +0100 @@ -22,6 +22,7 @@ [("r", "rev", "", _('revision to handle'), _('REV')), ("", "amend", None, _('amend a given file with path information')), ("p", "path", [], _('the configured default path'), _('SOURCE')), + ("d", "data", [], _("add an extra `KEY: VALUE' pair into the file"), _('KEY=VALUE')), ], _("hg revinfo [OPTION]... [DEST]")) def revinfo(ui, repo, dest=None, **opts): @@ -58,9 +59,22 @@ raise util.Abort(_("no working directory: please specify a revision")) msg = archival.buildmetadata(ctx) + + for kv in opts.get("data"): + kvparts = [ i.strip() for i in kv.split("=", 1) ] + if len(kvparts) == 2: + msg += "%s: %s\n" % tuple(kvparts) + else: + raise util.Abort(_("given data `%s' is not a KEY=VALUE pair") % (kv, )) + paths = opts.get("path") - if not paths: - paths = ["default"] + # + # When not amending and no path options is given print the + # "default" path + # + if not opts.get("amend"): + if not paths: + paths = ["default"] for canonicalpath in paths: if canonicalpath: for name, path in sorted(ui.paths.iteritems()):
