# HG changeset patch # User Franz Glasner # Date 1510648042 -3600 # Node ID c077d30da0eec81a73ce9cb9d9f24a5bd3ddfc78 # Parent 71b321436cc1ff2c44e9f664fc204bb1f9a92ffa Implemented a "kwprint" command to print just some file-independent keywords diff -r 71b321436cc1 -r c077d30da0ee extensions/kwarchive.py --- a/extensions/kwarchive.py Mon Nov 13 09:39:06 2017 +0100 +++ b/extensions/kwarchive.py Tue Nov 14 09:27:22 2017 +0100 @@ -149,6 +149,40 @@ # XXX FIXME: Should the original methods be restored here? +@command('kwprint', + [('r', 'rev', '', _('revision to distribute'), _('REV')), + ('', 'path', 'default', _('the canonical repository to use'), _('PATH')), + ] + cmdutil.subrepoopts + cmdutil.walkopts, + _('[OPTION]...')) +def kwprint(ui, repo, **opts): + '''print the file-independent keywords + + By default, the revision used is the parent of the working + directory; use -r/--rev to specify a different revision. + + Use --path to specify named path information from :hg:`paths` as + the canonical repository location. Use ``.`` for the current + repository root root. If no path is given then ``default`` is + assumed. + + Returns 0 on success. + + ''' + + opts = pycompat.byteskwargs(opts) + ctx = scmutil.revsingle(repo, opts.get('rev')) + if not ctx: + raise error.Abort(_('no working directory: please specify a revision')) + node = ctx.node() + + prefix = cmdutil.makefilename(repo, "", node) + + keywords = make_node_keywords( + ui, repo, ctx, prefix, hgpath=opts.get("path")) + for key in sorted(keywords.keys()): + ui.write("$%s: %s $\n" % (key, keywords[key])) + + def patch_archiver_class(archivername, filter): """Patch an archiver class and return the original unbound method"""