Bug 4798 - schemes extension fails when configured scheme ends in backslash
Summary: schemes extension fails when configured scheme ends in backslash
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: stable branch
Hardware: PC Windows
: wish feature
Assignee: Matt Mackall
URL:
Keywords:
: 4799 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-08-27 14:30 UTC by Simon Heimberg
Modified: 2015-09-30 12:51 UTC (History)
2 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Heimberg 2015-08-27 14:30 UTC
This hgrc configuration results in an abort message because the scheme wbackslash ends in a backslash:
[extensions]
schemes =
[schemes]
wbackslash = G:\bla\

Failure message (doing all config in one command):

C:\Users\tests>hg --config extensions.schemes= --config schemes.wbackslash=G:\bla\ id wbackslash://path/to/
** http://mercurial.selenic.com/wiki/BugTracker
** Python 2.7.9 (default, Dec 10 2014, 12:28:03) [MSC v.1500 64 bit (AMD64)]
** Mercurial Distributed SCM (Version 3.5+5)
** Erweiterungen geladen: schemes
Traceback (most recent call last):
  File "hg", line 49, in <module>
  File "mercurial\dispatch.pyo", line 30, in run
  File "mercurial\dispatch.pyo", line 92, in dispatch
  File "mercurial\dispatch.pyo", line 163, in _runcatch
  File "mercurial\dispatch.pyo", line 895, in _dispatch
  File "mercurial\dispatch.pyo", line 656, in runcommand
  File "mercurial\dispatch.pyo", line 1013, in _runcommand
  File "mercurial\dispatch.pyo", line 982, in checkargs
  File "mercurial\dispatch.pyo", line 892, in <lambda>
  File "mercurial\util.pyo", line 792, in check
  File "mercurial\commands.pyo", line 4027, in identify
  File "mercurial\hg.pyo", line 146, in peer
  File "mercurial\hg.pyo", line 123, in _peerorrepo
  File "hgext\schemes.pyo", line 80, in instance
  File "mercurial\templater.pyo", line 759, in process
  File "mercurial\templater.pyo", line 752, in _load
  File "mercurial\templater.pyo", line 174, in compiletemplate
  File "mercurial\templater.pyo", line 150, in _parsetemplate
ValueError: Trailing \ in string

Maybe the failure is expected, but the message does not tell a lot of useful information.
Comment 1 Simon Heimberg 2015-08-27 14:33 UTC
*** Bug 4799 has been marked as a duplicate of this bug. ***
Comment 2 Matt Mackall 2015-08-27 15:24 UTC
It is indeed expected: the value is treated as a Mercurial template, and thus \ is an escape character.

Degrading to wish/feature: we should improve the error message and the docs. FYI, the error comes from Python:

>>> "blah\\".decode('string-escape')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Trailing \ in string
Comment 3 HG Bot 2015-09-11 16:00 UTC
Fixed by https://selenic.com/repo/hg/rev/72aad184f061
Matt Mackall <mpm@selenic.com>
templater: create string unescape helper (issue4798)

This gives us a unified place to do error-handling of string-escaping
syntax errors

(please test the fix)