Mercurial > hgrepos > DevTools > mercurial-extensions
diff extensions/revinfo.py @ 13:c78608f802d4
Implemented "--amend" for revinfo to put extra "path" items into existing files
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Sun, 27 Sep 2015 13:49:09 +0200 |
| parents | 230cf9ee8ae3 |
| children | 92774da07ebc |
line wrap: on
line diff
--- a/extensions/revinfo.py Sun Sep 27 13:34:06 2015 +0200 +++ b/extensions/revinfo.py Sun Sep 27 13:49:09 2015 +0200 @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- """write a revision summary similar to .hg_archival.txt - """ __version__ = "1.0" @@ -21,6 +20,7 @@ @command("revinfo", [("r", "rev", "", _('revision to handle'), _('REV')), + ("a", "amend", None, _('amend a given file with path information')), ("p", "path", "default", _('the configured default path'), _('SOURCE')), ], _("hg revinfo [OPTION]... [DEST]")) @@ -38,15 +38,26 @@ printed as "path" item to the output. Disable this by providing an empty SOURCE. + Use --amend to extend a given file with a "path" item. + Can also be used to put more than one path item into the file. + The printed information is the same as the :hg:`archive` command - writes into ".hg_archival.txt". - + writes into ".hg_archival.txt". The "path" info is an extra item. """ - ctx = scmutil.revsingle(repo, opts.get("rev")) - if not ctx: - raise util.Abort(_('no working directory: please specify a revision')) + if opts.get("amend") and opts.get("rev"): + raise util.Abort(_("cannot use -r/--rev together with --amend")) - msg = archival.buildmetadata(ctx) + if opts.get("amend"): + if not dest: + raise util.Abort(_('need a destination file with --amend')) + with open(dest, "rb") as rfile: + msg = rfile.read() + else: + ctx = scmutil.revsingle(repo, opts.get("rev")) + if not ctx: + raise util.Abort(_("no working directory: please specify a revision")) + + msg = archival.buildmetadata(ctx) canonicalpath = opts.get("path") if canonicalpath: for name, path in sorted(ui.paths.iteritems()):
