# HG changeset patch # User Martin von Zweigbergk # Date 1528925319 25200 # Node ID fabfbbf4dee21ab04c30464ed8e6cf55e6f08332 # Parent 1fb2510cf8c81f2e26ec49054fdbec67ec56cba0 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 diff -r 1fb2510cf8c8 -r fabfbbf4dee2 mercurial/templatefilters.py --- a/mercurial/templatefilters.py Wed Jun 13 10:24:44 2018 -0400 +++ b/mercurial/templatefilters.py Wed Jun 13 14:28:39 2018 -0700 @@ -99,8 +99,8 @@ """ return os.path.basename(path) -@templatefilter('commonprefix') -def commonprefix(filelist): +@templatefilter('commondir') +def commondir(filelist): """List of text. Treats each list item as file name with / as path separator and returns the longest common directory prefix shared by all list items. diff -r 1fb2510cf8c8 -r fabfbbf4dee2 tests/test-template-filters.t --- a/tests/test-template-filters.t Wed Jun 13 10:24:44 2018 -0400 +++ b/tests/test-template-filters.t Wed Jun 13 14:28:39 2018 -0700 @@ -1,23 +1,23 @@ - $ hg debugtemplate '{""|splitlines|commonprefix}\n' + $ hg debugtemplate '{""|splitlines|commondir}\n' - $ hg debugtemplate '{"foo/bar\nfoo/baz\nfoo/foobar\n"|splitlines|commonprefix}\n' + $ hg debugtemplate '{"foo/bar\nfoo/baz\nfoo/foobar\n"|splitlines|commondir}\n' foo - $ hg debugtemplate '{"foo/bar\nfoo/bar\n"|splitlines|commonprefix}\n' + $ hg debugtemplate '{"foo/bar\nfoo/bar\n"|splitlines|commondir}\n' foo - $ hg debugtemplate '{"/foo/bar\n/foo/bar\n"|splitlines|commonprefix}\n' + $ hg debugtemplate '{"/foo/bar\n/foo/bar\n"|splitlines|commondir}\n' foo - $ hg debugtemplate '{"/foo\n/foo\n"|splitlines|commonprefix}\n' + $ hg debugtemplate '{"/foo\n/foo\n"|splitlines|commondir}\n' - $ hg debugtemplate '{"foo/bar\nbar/baz"|splitlines|commonprefix}\n' + $ hg debugtemplate '{"foo/bar\nbar/baz"|splitlines|commondir}\n' - $ hg debugtemplate '{"foo/bar\nbar/baz\nbar/foo\n"|splitlines|commonprefix}\n' + $ hg debugtemplate '{"foo/bar\nbar/baz\nbar/foo\n"|splitlines|commondir}\n' - $ hg debugtemplate '{"foo/../bar\nfoo/bar"|splitlines|commonprefix}\n' + $ hg debugtemplate '{"foo/../bar\nfoo/bar"|splitlines|commondir}\n' foo - $ hg debugtemplate '{"foo\n/foo"|splitlines|commonprefix}\n' + $ hg debugtemplate '{"foo\n/foo"|splitlines|commondir}\n' $ hg init - $ hg log -r null -T '{rev|commonprefix}' + $ hg log -r null -T '{rev|commondir}' hg: parse error: argument is not a list of text - (template filter 'commonprefix' is not compatible with keyword 'rev') + (template filter 'commondir' is not compatible with keyword 'rev') [255]