changeset 35:f29c98e54f50

Implement a "--path" option for kwarchive to select a repository to use as canonical one
author Franz Glasner <hg@dom66.de>
date Sun, 12 Nov 2017 00:03:24 +0100
parents 7c4addd60935
children c0634bed8163
files extensions/kwarchive.py
diffstat 1 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/kwarchive.py	Sat Nov 11 23:23:50 2017 +0100
+++ b/extensions/kwarchive.py	Sun Nov 12 00:03:24 2017 +0100
@@ -58,6 +58,7 @@
      _('PREFIX')),
     ('r', 'rev', '', _('revision to distribute'), _('REV')),
     ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
+    ('', 'path', 'default', _('the canonical repository to use'), _('PATH')),
     ] + cmdutil.subrepoopts + cmdutil.walkopts,
     _('[OPTION]... DEST'))
 def kwarchive(ui, repo, dest, **opts):
@@ -98,6 +99,10 @@
     prefix. The default is the basename of the archive, with suffixes
     removed.
 
+    The canonical repository is given by the ``default`` path setting.
+    Use --path change the default: ``.`` for the current repositorie's
+    root or another path setting from within your configuration.
+
     Returns 0 on success.
     '''
 
@@ -135,7 +140,8 @@
                 repo,
                 ctx,
                 ac,
-                archival.tidyprefix(dest, kind, prefix)))
+                archival.tidyprefix(dest, kind, prefix),
+                hgpath=opts.get("path")))
 
     archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
                      matchfn, prefix, subrepos=opts.get('subrepos'))
@@ -159,9 +165,19 @@
 def make_keyword_filter(ui, repo, ctx, archive_class, prefix,
                         hgpath="default"):
 
+    if hgpath:
+        if hgpath == '.':
+            path_url = repo.root
+        else:
+            try:
+                path_url = util.hidepassword(ui.paths[hgpath].loc)
+            except LookupError:
+                raise error.Abort(_('repository %s not found') % hgpath)
+    else:
+        path_url = repo.root
     # node specific keywords
     keywords = {
-        "HGpath": ui.config("paths", hgpath) or repo.root,
+        "HGpath": path_url,
         "HGrevision": ctx.hex(),
         "Revision": templatefilters.short(ctx.hex()),
         "Author": templatefilters.person(ctx.user()),