D3439: templatefilters: add commonprefix

Yuya Nishihara yuya at tcha.org
Thu May 10 08:40:30 EDT 2018


> +  $ hg debugtemplate '{"foo/bar\nfoo/bar\n"|splitlines|commonprefix}\n'
> +  foo

should be "foo/bar"

> +  $ hg debugtemplate '{"/foo/bar\n/foo/bar\n"|splitlines|commonprefix}\n'
> +  foo

should be "/foo/bar"

> +  $ hg debugtemplate '{"/foo\n/foo\n"|splitlines|commonprefix}\n'
> +  

should e "/foo"

FWIW, I doubt if scanning all elements with the seen set is faster than
calling min()/max() to pick the farthest pair because Python is slow.

> {str|commonprefix} is not really interesting since it is naturally an
> iterable of text.

I think it's better to error out, but that could be addressed later.


More information about the Mercurial-devel mailing list