Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefilters.py @ 38304:fabfbbf4dee2
templatefilters: rename commonprefix to commondir
Two reasons:
* It makes it clearer that it's not a generic common string
prefix (e.g. commonprefix(["bar", "baz"]) is not "ba", but "")
* If we ever want a filter for generic common string prefix,
then the name is now available for that.
"commondir" does not describe the prefix-ness, however. I'm happy to
rename it "commondirprefix" or "commonprefixdir" if others prefer.
Differential Revision: https://phab.mercurial-scm.org/D3731
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 13 Jun 2018 14:28:39 -0700 |
parents | 74b4a54002ec |
children | e7aa113b14f7 |
comparison
equal
deleted
inserted
replaced
38303:1fb2510cf8c8 | 38304:fabfbbf4dee2 |
---|---|
97 component of the path after splitting by the path separator. | 97 component of the path after splitting by the path separator. |
98 For example, "foo/bar/baz" becomes "baz" and "foo/bar//" becomes "". | 98 For example, "foo/bar/baz" becomes "baz" and "foo/bar//" becomes "". |
99 """ | 99 """ |
100 return os.path.basename(path) | 100 return os.path.basename(path) |
101 | 101 |
102 @templatefilter('commonprefix') | 102 @templatefilter('commondir') |
103 def commonprefix(filelist): | 103 def commondir(filelist): |
104 """List of text. Treats each list item as file name with / | 104 """List of text. Treats each list item as file name with / |
105 as path separator and returns the longest common directory | 105 as path separator and returns the longest common directory |
106 prefix shared by all list items. | 106 prefix shared by all list items. |
107 Returns the empty string if no common prefix exists. | 107 Returns the empty string if no common prefix exists. |
108 | 108 |