Show More
@@ -279,7 +279,7 b' All the above add a comment to the Bugzi' | |||
|
279 | 279 | |
|
280 | 280 | from mercurial.i18n import _ |
|
281 | 281 | from mercurial.node import short |
|
282 |
from mercurial import cmdutil, mail, |
|
|
282 | from mercurial import cmdutil, mail, util | |
|
283 | 283 | import re, time, urlparse, xmlrpclib |
|
284 | 284 | |
|
285 | 285 | testedwith = 'internal' |
@@ -876,8 +876,6 b' class bugzilla(object):' | |||
|
876 | 876 | if not mapfile and not tmpl: |
|
877 | 877 | tmpl = _('changeset {node|short} in repo {root} refers ' |
|
878 | 878 | 'to bug {bug}.\ndetails:\n\t{desc|tabindent}') |
|
879 | if tmpl: | |
|
880 | tmpl = templater.parsestring(tmpl, quoted=False) | |
|
881 | 879 | t = cmdutil.changeset_templater(self.ui, self.repo, |
|
882 | 880 | False, None, tmpl, mapfile, False) |
|
883 | 881 | self.ui.pushbuffer() |
@@ -9,7 +9,7 b'' | |||
|
9 | 9 | '''command to display statistics about repository history''' |
|
10 | 10 | |
|
11 | 11 | from mercurial.i18n import _ |
|
12 |
from mercurial import patch, cmdutil, scmutil, util, |
|
|
12 | from mercurial import patch, cmdutil, scmutil, util, commands | |
|
13 | 13 | from mercurial import encoding |
|
14 | 14 | import os |
|
15 | 15 | import time, datetime |
@@ -19,7 +19,6 b' command = cmdutil.command(cmdtable)' | |||
|
19 | 19 | testedwith = 'internal' |
|
20 | 20 | |
|
21 | 21 | def maketemplater(ui, repo, tmpl): |
|
22 | tmpl = templater.parsestring(tmpl, quoted=False) | |
|
23 | 22 | try: |
|
24 | 23 | t = cmdutil.changeset_templater(ui, repo, False, None, tmpl, |
|
25 | 24 | None, False) |
@@ -43,7 +43,7 b' configure it, set the following options ' | |||
|
43 | 43 | |
|
44 | 44 | from mercurial.i18n import _ |
|
45 | 45 | from mercurial.node import bin, short |
|
46 |
from mercurial import cmdutil, patch, |
|
|
46 | from mercurial import cmdutil, patch, util, mail | |
|
47 | 47 | import email.Parser |
|
48 | 48 | |
|
49 | 49 | import socket, xmlrpclib |
@@ -206,7 +206,6 b' class hgcia(object):' | |||
|
206 | 206 | template = self.dstemplate |
|
207 | 207 | else: |
|
208 | 208 | template = self.deftemplate |
|
209 | template = templater.parsestring(template, quoted=False) | |
|
210 | 209 | t = cmdutil.changeset_templater(self.ui, self.repo, False, None, |
|
211 | 210 | template, style, False) |
|
212 | 211 | self.templater = t |
@@ -83,7 +83,7 b" like CVS' $Log$, are not supported. A ke" | |||
|
83 | 83 | ''' |
|
84 | 84 | |
|
85 | 85 | from mercurial import commands, context, cmdutil, dispatch, filelog, extensions |
|
86 |
from mercurial import localrepo, match, patch, templatefilters, |
|
|
86 | from mercurial import localrepo, match, patch, templatefilters, util | |
|
87 | 87 | from mercurial import scmutil, pathutil |
|
88 | 88 | from mercurial.hgweb import webcommands |
|
89 | 89 | from mercurial.i18n import _ |
@@ -191,8 +191,7 b' class kwtemplater(object):' | |||
|
191 | 191 | |
|
192 | 192 | kwmaps = self.ui.configitems('keywordmaps') |
|
193 | 193 | if kwmaps: # override default templates |
|
194 |
self.templates = dict( |
|
|
195 | for k, v in kwmaps) | |
|
194 | self.templates = dict(kwmaps) | |
|
196 | 195 | else: |
|
197 | 196 | self.templates = _defaultkwmaps(self.ui) |
|
198 | 197 |
@@ -138,7 +138,7 b' import email, socket, time' | |||
|
138 | 138 | # load. This was not a problem on Python 2.7. |
|
139 | 139 | import email.Parser |
|
140 | 140 | from mercurial.i18n import _ |
|
141 |
from mercurial import patch, cmdutil, |
|
|
141 | from mercurial import patch, cmdutil, util, mail | |
|
142 | 142 | import fnmatch |
|
143 | 143 | |
|
144 | 144 | testedwith = 'internal' |
@@ -190,8 +190,6 b' class notifier(object):' | |||
|
190 | 190 | self.ui.config('notify', 'template')) |
|
191 | 191 | if not mapfile and not template: |
|
192 | 192 | template = deftemplates.get(hooktype) or single_template |
|
193 | if template: | |
|
194 | template = templater.parsestring(template, quoted=False) | |
|
195 | 193 | self.t = cmdutil.changeset_templater(self.ui, self.repo, False, None, |
|
196 | 194 | template, mapfile, False) |
|
197 | 195 |
@@ -1445,7 +1445,7 b' def gettemplate(ui, tmpl, style):' | |||
|
1445 | 1445 | try: |
|
1446 | 1446 | tmpl = templater.parsestring(tmpl) |
|
1447 | 1447 | except SyntaxError: |
|
1448 | tmpl = templater.parsestring(tmpl, quoted=False) | |
|
1448 | pass | |
|
1449 | 1449 | return tmpl, None |
|
1450 | 1450 | else: |
|
1451 | 1451 | style = util.expandpath(ui.config('ui', 'style', '')) |
@@ -1479,7 +1479,7 b' def gettemplate(ui, tmpl, style):' | |||
|
1479 | 1479 | try: |
|
1480 | 1480 | tmpl = templater.parsestring(t) |
|
1481 | 1481 | except SyntaxError: |
|
1482 | tmpl = templater.parsestring(t, quoted=False) | |
|
1482 | tmpl = t | |
|
1483 | 1483 | return tmpl, None |
|
1484 | 1484 | |
|
1485 | 1485 | if tmpl == 'list': |
@@ -354,7 +354,6 b' def _formatlabels(repo, fcd, fco, fca, l' | |||
|
354 | 354 | |
|
355 | 355 | ui = repo.ui |
|
356 | 356 | template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) |
|
357 | template = templater.parsestring(template, quoted=False) | |
|
358 | 357 | tmpl = templater.templater(None, cache={'conflictmarker': template}) |
|
359 | 358 | |
|
360 | 359 | pad = max(len(l) for l in labels) |
@@ -618,28 +618,25 b' def _flatten(thing):' | |||
|
618 | 618 | for j in _flatten(i): |
|
619 | 619 | yield j |
|
620 | 620 | |
|
621 |
def parsestring(s |
|
|
622 |
'''unwrap quotes |
|
|
623 | if quoted: | |
|
624 | if len(s) < 2 or s[0] != s[-1]: | |
|
625 | raise SyntaxError(_('unmatched quotes')) | |
|
626 | # de-backslash-ify only <\">. it is invalid syntax in non-string part of | |
|
627 | # template, but we are likely to escape <"> in quoted string and it was | |
|
628 | # accepted before, thanks to issue4290. <\\"> is unmodified because it | |
|
629 | # is ambiguous and it was processed as such before 2.8.1. | |
|
630 | # | |
|
631 | # template result | |
|
632 | # --------- ------------------------ | |
|
633 | # {\"\"} parse error | |
|
634 |
|
|
|
635 |
|
|
|
636 |
|
|
|
637 | # '{"\""}' {"\""} -> <"> | |
|
638 | # "{"\""}" parse error (don't care) | |
|
639 | q = s[0] | |
|
640 | return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q) | |
|
641 | ||
|
642 | return s | |
|
621 | def parsestring(s): | |
|
622 | '''unwrap quotes''' | |
|
623 | if len(s) < 2 or s[0] != s[-1]: | |
|
624 | raise SyntaxError(_('unmatched quotes')) | |
|
625 | # de-backslash-ify only <\">. it is invalid syntax in non-string part of | |
|
626 | # template, but we are likely to escape <"> in quoted string and it was | |
|
627 | # accepted before, thanks to issue4290. <\\"> is unmodified because it | |
|
628 | # is ambiguous and it was processed as such before 2.8.1. | |
|
629 | # | |
|
630 | # template result | |
|
631 | # --------- ------------------------ | |
|
632 | # {\"\"} parse error | |
|
633 | # "{""}" {""} -> <> | |
|
634 | # "{\"\"}" {""} -> <> | |
|
635 | # {"\""} {"\""} -> <"> | |
|
636 | # '{"\""}' {"\""} -> <"> | |
|
637 | # "{"\""}" parse error (don't care) | |
|
638 | q = s[0] | |
|
639 | return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q) | |
|
643 | 640 | |
|
644 | 641 | class engine(object): |
|
645 | 642 | '''template expansion engine. |
General Comments 0
You need to be logged in to leave comments.
Login now