diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -90,9 +90,8 @@ def age(date, abbrev=False): @templatefilter('basename') def basename(path): """Any text. Treats the text as a path, and returns the last - component of the path after splitting by the path separator - (ignoring trailing separators). For example, "foo/bar/baz" becomes - "baz" and "foo/bar//" becomes "bar". + component of the path after splitting by the path separator. + For example, "foo/bar/baz" becomes "baz" and "foo/bar//" becomes "". """ return os.path.basename(path) diff --git a/tests/test-command-template.t b/tests/test-command-template.t --- a/tests/test-command-template.t +++ b/tests/test-command-template.t @@ -2218,6 +2218,11 @@ Age filter: $ cd .. $ rm -rf unstable-hash +Filename filters: + + $ hg debugtemplate '{"foo/bar"|basename}|{"foo/"|basename}|{"foo"|basename}|\n' + bar||foo| + Add a dummy commit to make up for the instability of the above: $ echo a > a