Mercurial > hgrepos > DevTools > mercurial-extensions
diff extensions/kwarchive.py @ 100:eed73af1ab79
Implemented a "last" option for the "--path-filter": shorten to the last path component.
The last path component typically is a directory name.
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Thu, 02 Aug 2018 13:27:00 +0200 |
| parents | d7c453c740ef |
| children | ec4392ae8c92 |
line wrap: on
line diff
--- a/extensions/kwarchive.py Thu Aug 02 12:58:15 2018 +0200 +++ b/extensions/kwarchive.py Thu Aug 02 13:27:00 2018 +0200 @@ -132,6 +132,7 @@ :``nopwd``: like ``full`` but without passwords :``short``: shorten the path somehow: now user/passwordinformation and only a short server name + :``last``: shorten the path to the last component Returns 0 on success. @@ -225,6 +226,7 @@ :``nopwd``: like ``full`` but without passwords :``short``: shorten the path somehow: now user/passwordinformation and only a short server name + :``last``: shorten the path to the last component Use --reST to output the keyword in a format suitable for including in reStructuredText (reST) documents by using it's substitution feature. @@ -382,6 +384,9 @@ path_url.host = stripped_hostname(path_url.host) path_url.port = None path_uri = bytes(path_url) + elif path_filter == "last": + path_url = str(util.url(ui.paths[hgpath].loc)).split("/") + path_uri = bytes(path_url[-1]) else: raise error.Abort("path-filter `%s' not implemented" % path_filter) except LookupError: @@ -443,6 +448,6 @@ def get_checked_path_filter(opts): pf = opts.get("path_filter") - if not pf in ("full", "nopwd", "short"): + if not pf in ("full", "nopwd", "short", "last"): raise error.Abort(_("path filter must be any of `full', `nopwd' or `short'")) return pf
