Incorrectly behaving Escapes in Templates/Styles?

Kevin O. Grover kevin at kevingrover.net
Tue Mar 10 23:45:21 UTC 2015


First a caveat: at work I don't have access to the Internet (normally).   I
quickly checked the bug tracker and could find nothing relevant (but I do
not have an account and may not have been doing it correctly).

Background: I wanted a quick style to output the list of files in a
repository in a format I could paste into an Outlook email message and turn
them into links.

In the process, I noticed that escapes are not occurring as I would
expect.  I made a go at looking at the code, but I could not quickly locate
anything.

I'm game to turn this into a bug, but I've never done it before, so I was
hoping to make sure I'm not wasting peoples time, and to maybe get some
tips on what to do/not do.

I've attached some bash scripts to that recreate the issue.  (Script at the
end)

I've done this under Debian 7 and Ubuntu 14.04 (running hg 3.3 on Ubuntu)
and manually on Windows 7 running hg 3.3.  I've also switched the style to
use " and \", but it does not seem to make any difference.

NOTE: I've worked around the issue: I created HTML output with links and
copied and pasted that into the email.  If there truly is a bug, I'd rather
not let it go unreported.

Summary.   If I have these styles: works.style, broke.style

## works.style
changeset = '{files}'
file = '    "//path/to/dir/{file|urlescape}"\n'


## broke.style
changeset = '{files}'
file = '    "\\\\path\\to\\dir\\{file|urlescape}"\n'

## This seems OK

$ hg -R repo log --style=./works.style
    "//path/to/dir/afile.txt"
    "//path/to/dir/anotherfile.txt"
    "//path/to/dir/with%20space.txt"

## This is not what I expect

$ hg -R repo log --style=./broke.style
    "\path o\dir{file|urlescape}"
    "\path o\dir{file|urlescape}"
    "\path o\dir{file|urlescape}"

I would expect the \\ to take precedence over the others, but \t and \{
seems to take precedence  - I would surmise that all standard escape codes
take precedence.

To run the scripts

chmod +x mkrepo mktemplates test_templates
./mkrepo
./mktemplates
./test_templates
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150310/889760e6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mkrepo
Type: application/octet-stream
Size: 232 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150310/889760e6/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_templates
Type: application/octet-stream
Size: 157 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150310/889760e6/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mktemplates
Type: application/octet-stream
Size: 222 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150310/889760e6/attachment-0002.obj>


More information about the Mercurial-devel mailing list