# HG changeset patch # User Matt Mackall # Date 2006-11-13 19:26:57 # Node ID 5c9a3621066262984d5f11347e11268e3284bbef # Parent 7b064d8bac5ee41903e72ebbd0112c90ad1bb359 templater: simplify parsestring diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -14,13 +14,9 @@ def parsestring(s, quoted=True): '''parse a string using simple c-like syntax. string must be in quotes if quoted is True.''' if quoted: - first = s[0] - if len(s) < 2: raise SyntaxError(_('string too short')) - if first not in "'\"": raise SyntaxError(_('invalid quote')) - if s[-1] != first: raise SyntaxError(_('unmatched quotes')) - s = s[1:-1].decode('string_escape') - if first in s: raise SyntaxError(_('string ends early')) - return s + if len(s) < 2 or s[0] != s[-1]: + raise SyntaxError(_('unmatched quotes')) + return s[1:-1].decode('string_escape') return s.decode('string_escape')