Mercurial > hgrepos > DevTools > mercurial-extensions
changeset 93:fa84debfb50e
Replace "no-shorten-url" by "path-filter"
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Wed, 28 Feb 2018 10:56:56 +0100 |
| parents | e1dc7aa60cd4 |
| children | 1d004f4a60a9 |
| files | extensions/kwarchive.py |
| diffstat | 1 files changed, 34 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/kwarchive.py Tue Feb 27 18:41:24 2018 +0100 +++ b/extensions/kwarchive.py Wed Feb 28 10:56:56 2018 +0100 @@ -68,6 +68,7 @@ ('', 'path', 'default', _('the canonical repository to use'), _('PATH')), ('', "kwconfig", '', _('an alternate pattern configuration configuration file'), _('PATTERNCONFIG')), ('', "no-shorten-path", None, _("don't shorten the path urls")), + ('', "path-filter", "short", _("determine how the path will be printed")), ('', "user-filter", "user", _("the part of the user to be printed"), _("USERFILTER")), ] + cmdutil.subrepoopts + cmdutil.walkopts, _('[OPTION]... DEST')) @@ -125,6 +126,13 @@ :``full``: the complete user information w/o filtering :``none``: an alias for ``full`` + The --path-filter values detemine how the path will be printed: + + :``full``: the path will be printed as is (including passwords et al.) + :``nopwd``: like ``full`` but without passwords + :``short``: shorten the path somehow: now user/passwordinformation and + only a short server name + Returns 0 on success. ''' @@ -165,7 +173,7 @@ ac, archival.tidyprefix(dest, kind, prefix), hgpath=opts.get("path"), - shorten_path_url=not opts.get("no_shorten_path"), + path_filter=get_checked_path_filter(opts), user_filter=get_checked_user_filter(opts), kwconfig=opts.get("kwconfig"))) @@ -184,6 +192,7 @@ [('r', 'rev', '', _('revision to distribute'), _('REV')), ('', 'path', 'default', _('the canonical repository to use'), _('PATH')), ('', "no-shorten-path", None, _("don't shorten the path urls")), + ('', "path-filter", "short", _("determine how the path will be printed")), ('', "user-filter", "user", _("the part of the user to be printed"), _("USERFILTER")), ('', "reST", None, _("output in reST substitution definition syntax")), ] + cmdutil.subrepoopts + cmdutil.walkopts, @@ -210,6 +219,13 @@ :``full``: the complete user information w/o filtering :``none``: an alias for ``full`` + The --path-filter values detemine how the path will be printed: + + :``full``: the path will be printed as is (including passwords et al.) + :``nopwd``: like ``full`` but without passwords + :``short``: shorten the path somehow: now user/passwordinformation and + only a short server name + Use --reST to output the keyword in a format suitable for including in reStructuredText (reST) documents by using it's substitution feature. All revision keyword names have a ``VCS`` prefix. @@ -229,7 +245,7 @@ keywords = make_node_keywords( ui, repo, ctx, prefix, hgpath=opts.get("path"), - shorten_path_url=not opts.get("no_shorten_path"), + path_filter=get_checked_path_filter(opts), user_filter=get_checked_user_filter(opts)) for key in sorted(keywords.keys()): if opts.get("reST"): @@ -253,12 +269,12 @@ def make_keyword_filter(ui, repo, ctx, archive_class, prefix, hgpath="default", - shorten_path_url=True, + path_filter="short", user_filter="user", kwconfig=""): keywords = make_node_keywords(ui, repo, ctx, prefix, hgpath=hgpath, - shorten_path_url=shorten_path_url, + path_filter=path_filter, user_filter=user_filter) kwconfigdata = kwconfigname = None if kwconfig: @@ -344,7 +360,7 @@ def make_node_keywords(ui, repo, ctx, prefix, hgpath="default", - shorten_path_url=True, + path_filter="short", user_filter="user"): """Make all the node-specific (i.e. file-path independent) keywords @@ -354,7 +370,11 @@ path_uri = repo.root else: try: - if shorten_path_url: + if path_filter == "full": + path_uri = bytes(util.url(ui.paths[hgpath].loc)) + elif path_filter == "nopwd": + path_uri = util.hidepassword(ui.paths[hgpath].loc) + elif path_filter == "short": path_url = util.url(ui.paths[hgpath].loc) path_url.scheme = SHORTENED_HG_SCHEMES.get(path_url.scheme, "hg") path_url.user = None @@ -363,7 +383,7 @@ path_url.port = None path_uri = bytes(path_url) else: - path_uri = util.hidepassword(ui.paths[hgpath].loc) + raise error.Abort("path-filter `%s' not implemented" % path_filter) except LookupError: raise error.Abort(_('repository %s not found') % hgpath) else: @@ -416,3 +436,10 @@ if not uf in ("person", "user", "email", "full", "none"): raise error.Abort(_("user filter must be any of `user', `person' or `email'")) return uf + + +def get_checked_path_filter(opts): + pf = opts.get("path_filter") + if not pf in ("full", "nopwd", "short"): + raise error.Abort(_("path filter must be any of `full', `nopwd' or `short'")) + return pf
