Show More
@@ -307,6 +307,9 from mercurial import ( | |||||
307 | url, |
|
307 | url, | |
308 | util, |
|
308 | util, | |
309 | ) |
|
309 | ) | |
|
310 | from mercurial.utils import ( | |||
|
311 | stringutil, | |||
|
312 | ) | |||
310 |
|
313 | |||
311 | xmlrpclib = util.xmlrpclib |
|
314 | xmlrpclib = util.xmlrpclib | |
312 |
|
315 | |||
@@ -1099,7 +1102,8 class bugzilla(object): | |||||
1099 | root=self.repo.root, |
|
1102 | root=self.repo.root, | |
1100 | webroot=webroot(self.repo.root)) |
|
1103 | webroot=webroot(self.repo.root)) | |
1101 | data = self.ui.popbuffer() |
|
1104 | data = self.ui.popbuffer() | |
1102 |
self.bzdriver.updatebug(bugid, newstate, data, |
|
1105 | self.bzdriver.updatebug(bugid, newstate, data, | |
|
1106 | stringutil.email(ctx.user())) | |||
1103 |
|
1107 | |||
1104 | def notify(self, bugs, committer): |
|
1108 | def notify(self, bugs, committer): | |
1105 | '''ensure Bugzilla users are notified of bug change.''' |
|
1109 | '''ensure Bugzilla users are notified of bug change.''' | |
@@ -1119,6 +1123,6 def hook(ui, repo, hooktype, node=None, | |||||
1119 | if bugs: |
|
1123 | if bugs: | |
1120 | for bug in bugs: |
|
1124 | for bug in bugs: | |
1121 | bz.update(bug, bugs[bug], ctx) |
|
1125 | bz.update(bug, bugs[bug], ctx) | |
1122 | bz.notify(bugs, util.email(ctx.user())) |
|
1126 | bz.notify(bugs, stringutil.email(ctx.user())) | |
1123 | except Exception as e: |
|
1127 | except Exception as e: | |
1124 | raise error.Abort(_('Bugzilla error: %s') % e) |
|
1128 | raise error.Abort(_('Bugzilla error: %s') % e) |
@@ -17,7 +17,10 from mercurial import ( | |||||
17 | pycompat, |
|
17 | pycompat, | |
18 | util, |
|
18 | util, | |
19 | ) |
|
19 | ) | |
20 |
from mercurial.utils import |
|
20 | from mercurial.utils import ( | |
|
21 | dateutil, | |||
|
22 | stringutil, | |||
|
23 | ) | |||
21 |
|
24 | |||
22 | pickle = util.pickle |
|
25 | pickle = util.pickle | |
23 |
|
26 | |||
@@ -452,7 +455,8 def createlog(ui, directory=None, root=" | |||||
452 | rcsmap[e.rcs.replace('/Attic/', '/')] = e.rcs |
|
455 | rcsmap[e.rcs.replace('/Attic/', '/')] = e.rcs | |
453 |
|
456 | |||
454 | if len(log) % 100 == 0: |
|
457 | if len(log) % 100 == 0: | |
455 |
ui.status(util.ellipsis('%d %s' % (len(log), e.file), 80) |
|
458 | ui.status(stringutil.ellipsis('%d %s' % (len(log), e.file), 80) | |
|
459 | + '\n') | |||
456 |
|
460 | |||
457 | log.sort(key=lambda x: (x.rcs, x.revision)) |
|
461 | log.sort(key=lambda x: (x.rcs, x.revision)) | |
458 |
|
462 | |||
@@ -608,7 +612,7 def createchangeset(ui, log, fuzz=60, me | |||||
608 | files = set() |
|
612 | files = set() | |
609 | if len(changesets) % 100 == 0: |
|
613 | if len(changesets) % 100 == 0: | |
610 | t = '%d %s' % (len(changesets), repr(e.comment)[1:-1]) |
|
614 | t = '%d %s' % (len(changesets), repr(e.comment)[1:-1]) | |
611 | ui.status(util.ellipsis(t, 80) + '\n') |
|
615 | ui.status(stringutil.ellipsis(t, 80) + '\n') | |
612 |
|
616 | |||
613 | c.entries.append(e) |
|
617 | c.entries.append(e) | |
614 | files.add(e.file) |
|
618 | files.add(e.file) |
@@ -14,7 +14,10 from mercurial import ( | |||||
14 | error, |
|
14 | error, | |
15 | util, |
|
15 | util, | |
16 | ) |
|
16 | ) | |
17 |
from mercurial.utils import |
|
17 | from mercurial.utils import ( | |
|
18 | dateutil, | |||
|
19 | stringutil, | |||
|
20 | ) | |||
18 |
|
21 | |||
19 | from . import common |
|
22 | from . import common | |
20 |
|
23 | |||
@@ -169,7 +172,7 class p4_source(common.converter_source) | |||||
169 | shortdesc = '**empty changelist description**' |
|
172 | shortdesc = '**empty changelist description**' | |
170 |
|
173 | |||
171 | t = '%s %s' % (c.rev, repr(shortdesc)[1:-1]) |
|
174 | t = '%s %s' % (c.rev, repr(shortdesc)[1:-1]) | |
172 | ui.status(util.ellipsis(t, 80) + '\n') |
|
175 | ui.status(stringutil.ellipsis(t, 80) + '\n') | |
173 |
|
176 | |||
174 | files = [] |
|
177 | files = [] | |
175 | copies = {} |
|
178 | copies = {} |
@@ -16,7 +16,10 from mercurial import ( | |||||
16 | util, |
|
16 | util, | |
17 | vfs as vfsmod, |
|
17 | vfs as vfsmod, | |
18 | ) |
|
18 | ) | |
19 |
from mercurial.utils import |
|
19 | from mercurial.utils import ( | |
|
20 | dateutil, | |||
|
21 | stringutil, | |||
|
22 | ) | |||
20 |
|
23 | |||
21 | from . import common |
|
24 | from . import common | |
22 |
|
25 | |||
@@ -147,7 +150,7 def get_log_child(fp, url, paths, start, | |||||
147 | # Caller may interrupt the iteration |
|
150 | # Caller may interrupt the iteration | |
148 | pickle.dump(None, fp, protocol) |
|
151 | pickle.dump(None, fp, protocol) | |
149 | except Exception as inst: |
|
152 | except Exception as inst: | |
150 | pickle.dump(util.forcebytestr(inst), fp, protocol) |
|
153 | pickle.dump(stringutil.forcebytestr(inst), fp, protocol) | |
151 | else: |
|
154 | else: | |
152 | pickle.dump(None, fp, protocol) |
|
155 | pickle.dump(None, fp, protocol) | |
153 | fp.flush() |
|
156 | fp.flush() | |
@@ -1315,7 +1318,7 class svn_sink(converter_sink, commandli | |||||
1315 | fp.close() |
|
1318 | fp.close() | |
1316 | try: |
|
1319 | try: | |
1317 | output = self.run0('commit', |
|
1320 | output = self.run0('commit', | |
1318 | username=util.shortuser(commit.author), |
|
1321 | username=stringutil.shortuser(commit.author), | |
1319 | file=messagefile, |
|
1322 | file=messagefile, | |
1320 | encoding='utf-8') |
|
1323 | encoding='utf-8') | |
1321 | try: |
|
1324 | try: |
@@ -105,6 +105,9 from mercurial import ( | |||||
105 | registrar, |
|
105 | registrar, | |
106 | util, |
|
106 | util, | |
107 | ) |
|
107 | ) | |
|
108 | from mercurial.utils import ( | |||
|
109 | stringutil, | |||
|
110 | ) | |||
108 |
|
111 | |||
109 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
112 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | |
110 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
113 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | |
@@ -133,7 +136,7 def inconsistenteol(data): | |||||
133 |
|
136 | |||
134 | def tolf(s, params, ui, **kwargs): |
|
137 | def tolf(s, params, ui, **kwargs): | |
135 | """Filter to convert to LF EOLs.""" |
|
138 | """Filter to convert to LF EOLs.""" | |
136 | if util.binary(s): |
|
139 | if stringutil.binary(s): | |
137 | return s |
|
140 | return s | |
138 | if ui.configbool('eol', 'only-consistent') and inconsistenteol(s): |
|
141 | if ui.configbool('eol', 'only-consistent') and inconsistenteol(s): | |
139 | return s |
|
142 | return s | |
@@ -144,7 +147,7 def tolf(s, params, ui, **kwargs): | |||||
144 |
|
147 | |||
145 | def tocrlf(s, params, ui, **kwargs): |
|
148 | def tocrlf(s, params, ui, **kwargs): | |
146 | """Filter to convert to CRLF EOLs.""" |
|
149 | """Filter to convert to CRLF EOLs.""" | |
147 | if util.binary(s): |
|
150 | if stringutil.binary(s): | |
148 | return s |
|
151 | return s | |
149 | if ui.configbool('eol', 'only-consistent') and inconsistenteol(s): |
|
152 | if ui.configbool('eol', 'only-consistent') and inconsistenteol(s): | |
150 | return s |
|
153 | return s | |
@@ -403,7 +406,7 def reposetup(ui, repo): | |||||
403 | if fctx is None: |
|
406 | if fctx is None: | |
404 | continue |
|
407 | continue | |
405 | data = fctx.data() |
|
408 | data = fctx.data() | |
406 | if util.binary(data): |
|
409 | if stringutil.binary(data): | |
407 | # We should not abort here, since the user should |
|
410 | # We should not abort here, since the user should | |
408 | # be able to say "** = native" to automatically |
|
411 | # be able to say "** = native" to automatically | |
409 | # have all non-binary files taken care of. |
|
412 | # have all non-binary files taken care of. |
@@ -82,6 +82,9 from mercurial import ( | |||||
82 | scmutil, |
|
82 | scmutil, | |
83 | util, |
|
83 | util, | |
84 | ) |
|
84 | ) | |
|
85 | from mercurial.utils import ( | |||
|
86 | stringutil, | |||
|
87 | ) | |||
85 |
|
88 | |||
86 | cmdtable = {} |
|
89 | cmdtable = {} | |
87 | command = registrar.command(cmdtable) |
|
90 | command = registrar.command(cmdtable) | |
@@ -367,8 +370,8 class savedcmd(object): | |||||
367 | def __init__(self, path, cmdline): |
|
370 | def __init__(self, path, cmdline): | |
368 | # We can't pass non-ASCII through docstrings (and path is |
|
371 | # We can't pass non-ASCII through docstrings (and path is | |
369 | # in an unknown encoding anyway) |
|
372 | # in an unknown encoding anyway) | |
370 | docpath = util.escapestr(path) |
|
373 | docpath = stringutil.escapestr(path) | |
371 | self.__doc__ %= {r'path': pycompat.sysstr(util.uirepr(docpath))} |
|
374 | self.__doc__ %= {r'path': pycompat.sysstr(stringutil.uirepr(docpath))} | |
372 | self._cmdline = cmdline |
|
375 | self._cmdline = cmdline | |
373 |
|
376 | |||
374 | def __call__(self, ui, repo, *pats, **opts): |
|
377 | def __call__(self, ui, repo, *pats, **opts): |
@@ -15,7 +15,10 demandimport.ignore.extend(['pkgutil', ' | |||||
15 |
|
15 | |||
16 | from mercurial import ( |
|
16 | from mercurial import ( | |
17 | encoding, |
|
17 | encoding, | |
18 | util, |
|
18 | ) | |
|
19 | ||||
|
20 | from mercurial.utils import ( | |||
|
21 | stringutil, | |||
19 | ) |
|
22 | ) | |
20 |
|
23 | |||
21 | with demandimport.deactivated(): |
|
24 | with demandimport.deactivated(): | |
@@ -47,7 +50,7 def pygmentize(field, fctx, style, tmpl, | |||||
47 | tmpl.cache['header'] = new_header |
|
50 | tmpl.cache['header'] = new_header | |
48 |
|
51 | |||
49 | text = fctx.data() |
|
52 | text = fctx.data() | |
50 | if util.binary(text): |
|
53 | if stringutil.binary(text): | |
51 | return |
|
54 | return | |
52 |
|
55 | |||
53 | # str.splitlines() != unicode.splitlines() because "reasons" |
|
56 | # str.splitlines() != unicode.splitlines() because "reasons" |
@@ -209,6 +209,9 from mercurial import ( | |||||
209 | scmutil, |
|
209 | scmutil, | |
210 | util, |
|
210 | util, | |
211 | ) |
|
211 | ) | |
|
212 | from mercurial.utils import ( | |||
|
213 | stringutil, | |||
|
214 | ) | |||
212 |
|
215 | |||
213 | pickle = util.pickle |
|
216 | pickle = util.pickle | |
214 | release = lock.release |
|
217 | release = lock.release | |
@@ -465,7 +468,7 class histeditaction(object): | |||||
465 | # (the 5 more are left for verb) |
|
468 | # (the 5 more are left for verb) | |
466 | maxlen = self.repo.ui.configint('histedit', 'linelen') |
|
469 | maxlen = self.repo.ui.configint('histedit', 'linelen') | |
467 | maxlen = max(maxlen, 22) # avoid truncating hash |
|
470 | maxlen = max(maxlen, 22) # avoid truncating hash | |
468 | return util.ellipsis(line, maxlen) |
|
471 | return stringutil.ellipsis(line, maxlen) | |
469 |
|
472 | |||
470 | def tostate(self): |
|
473 | def tostate(self): | |
471 | """Print an action in format used by histedit state files |
|
474 | """Print an action in format used by histedit state files |
@@ -36,7 +36,10 from mercurial import ( | |||||
36 | registrar, |
|
36 | registrar, | |
37 | util, |
|
37 | util, | |
38 | ) |
|
38 | ) | |
39 |
from mercurial.utils import |
|
39 | from mercurial.utils import ( | |
|
40 | dateutil, | |||
|
41 | stringutil, | |||
|
42 | ) | |||
40 |
|
43 | |||
41 | cmdtable = {} |
|
44 | cmdtable = {} | |
42 | command = registrar.command(cmdtable) |
|
45 | command = registrar.command(cmdtable) | |
@@ -376,9 +379,9 class journalstorage(object): | |||||
376 |
|
379 | |||
377 | """ |
|
380 | """ | |
378 | if namespace is not None: |
|
381 | if namespace is not None: | |
379 | namespace = util.stringmatcher(namespace)[-1] |
|
382 | namespace = stringutil.stringmatcher(namespace)[-1] | |
380 | if name is not None: |
|
383 | if name is not None: | |
381 | name = util.stringmatcher(name)[-1] |
|
384 | name = stringutil.stringmatcher(name)[-1] | |
382 | for entry in self: |
|
385 | for entry in self: | |
383 | if namespace is not None and not namespace(entry.namespace): |
|
386 | if namespace is not None and not namespace(entry.namespace): | |
384 | continue |
|
387 | continue |
@@ -111,7 +111,10 from mercurial import ( | |||||
111 | templatefilters, |
|
111 | templatefilters, | |
112 | util, |
|
112 | util, | |
113 | ) |
|
113 | ) | |
114 |
from mercurial.utils import |
|
114 | from mercurial.utils import ( | |
|
115 | dateutil, | |||
|
116 | stringutil, | |||
|
117 | ) | |||
115 |
|
118 | |||
116 | cmdtable = {} |
|
119 | cmdtable = {} | |
117 | command = registrar.command(cmdtable) |
|
120 | command = registrar.command(cmdtable) | |
@@ -272,7 +275,8 class kwtemplater(object): | |||||
272 |
|
275 | |||
273 | def expand(self, path, node, data): |
|
276 | def expand(self, path, node, data): | |
274 | '''Returns data with keywords expanded.''' |
|
277 | '''Returns data with keywords expanded.''' | |
275 |
if not self.restrict and self.match(path) |
|
278 | if (not self.restrict and self.match(path) | |
|
279 | and not stringutil.binary(data)): | |||
276 | ctx = self.linkctx(path, node) |
|
280 | ctx = self.linkctx(path, node) | |
277 | return self.substitute(data, path, ctx, self.rekw.sub) |
|
281 | return self.substitute(data, path, ctx, self.rekw.sub) | |
278 | return data |
|
282 | return data | |
@@ -304,7 +308,7 class kwtemplater(object): | |||||
304 | data = self.repo.file(f).read(mf[f]) |
|
308 | data = self.repo.file(f).read(mf[f]) | |
305 | else: |
|
309 | else: | |
306 | data = self.repo.wread(f) |
|
310 | data = self.repo.wread(f) | |
307 | if util.binary(data): |
|
311 | if stringutil.binary(data): | |
308 | continue |
|
312 | continue | |
309 | if expand: |
|
313 | if expand: | |
310 | parents = ctx.parents() |
|
314 | parents = ctx.parents() | |
@@ -335,7 +339,7 class kwtemplater(object): | |||||
335 |
|
339 | |||
336 | def shrink(self, fname, text): |
|
340 | def shrink(self, fname, text): | |
337 | '''Returns text with all keyword substitutions removed.''' |
|
341 | '''Returns text with all keyword substitutions removed.''' | |
338 | if self.match(fname) and not util.binary(text): |
|
342 | if self.match(fname) and not stringutil.binary(text): | |
339 | return _shrinktext(text, self.rekwexp.sub) |
|
343 | return _shrinktext(text, self.rekwexp.sub) | |
340 | return text |
|
344 | return text | |
341 |
|
345 | |||
@@ -343,7 +347,7 class kwtemplater(object): | |||||
343 | '''Returns lines with keyword substitutions removed.''' |
|
347 | '''Returns lines with keyword substitutions removed.''' | |
344 | if self.match(fname): |
|
348 | if self.match(fname): | |
345 | text = ''.join(lines) |
|
349 | text = ''.join(lines) | |
346 | if not util.binary(text): |
|
350 | if not stringutil.binary(text): | |
347 | return _shrinktext(text, self.rekwexp.sub).splitlines(True) |
|
351 | return _shrinktext(text, self.rekwexp.sub).splitlines(True) | |
348 | return lines |
|
352 | return lines | |
349 |
|
353 |
@@ -14,6 +14,10 from mercurial import ( | |||||
14 | util, |
|
14 | util, | |
15 | ) |
|
15 | ) | |
16 |
|
16 | |||
|
17 | from mercurial.utils import ( | |||
|
18 | stringutil, | |||
|
19 | ) | |||
|
20 | ||||
17 | from . import ( |
|
21 | from . import ( | |
18 | basestore, |
|
22 | basestore, | |
19 | lfutil, |
|
23 | lfutil, | |
@@ -52,7 +56,7 class remotestore(basestore.basestore): | |||||
52 | except IOError as e: |
|
56 | except IOError as e: | |
53 | raise error.Abort( |
|
57 | raise error.Abort( | |
54 | _('remotestore: could not open file %s: %s') |
|
58 | _('remotestore: could not open file %s: %s') | |
55 | % (filename, util.forcebytestr(e))) |
|
59 | % (filename, stringutil.forcebytestr(e))) | |
56 |
|
60 | |||
57 | def _getfile(self, tmpfile, filename, hash): |
|
61 | def _getfile(self, tmpfile, filename, hash): | |
58 | try: |
|
62 | try: | |
@@ -61,7 +65,7 class remotestore(basestore.basestore): | |||||
61 | # 401s get converted to error.Aborts; everything else is fine being |
|
65 | # 401s get converted to error.Aborts; everything else is fine being | |
62 | # turned into a StoreError |
|
66 | # turned into a StoreError | |
63 | raise basestore.StoreError(filename, hash, self.url, |
|
67 | raise basestore.StoreError(filename, hash, self.url, | |
64 | util.forcebytestr(e)) |
|
68 | stringutil.forcebytestr(e)) | |
65 | except urlerr.urlerror as e: |
|
69 | except urlerr.urlerror as e: | |
66 | # This usually indicates a connection problem, so don't |
|
70 | # This usually indicates a connection problem, so don't | |
67 | # keep trying with the other files... they will probably |
|
71 | # keep trying with the other files... they will probably | |
@@ -70,7 +74,7 class remotestore(basestore.basestore): | |||||
70 | (util.hidepassword(self.url), e.reason)) |
|
74 | (util.hidepassword(self.url), e.reason)) | |
71 | except IOError as e: |
|
75 | except IOError as e: | |
72 | raise basestore.StoreError(filename, hash, self.url, |
|
76 | raise basestore.StoreError(filename, hash, self.url, | |
73 | util.forcebytestr(e)) |
|
77 | stringutil.forcebytestr(e)) | |
74 |
|
78 | |||
75 | return lfutil.copyandhash(chunks, tmpfile) |
|
79 | return lfutil.copyandhash(chunks, tmpfile) | |
76 |
|
80 |
@@ -19,6 +19,10 from mercurial import ( | |||||
19 | util, |
|
19 | util, | |
20 | ) |
|
20 | ) | |
21 |
|
21 | |||
|
22 | from mercurial.utils import ( | |||
|
23 | stringutil, | |||
|
24 | ) | |||
|
25 | ||||
22 | from ..largefiles import lfutil |
|
26 | from ..largefiles import lfutil | |
23 |
|
27 | |||
24 | from . import ( |
|
28 | from . import ( | |
@@ -95,7 +99,7 def writetostore(self, text): | |||||
95 | # by default, we expect the content to be binary. however, LFS could also |
|
99 | # by default, we expect the content to be binary. however, LFS could also | |
96 | # be used for non-binary content. add a special entry for non-binary data. |
|
100 | # be used for non-binary content. add a special entry for non-binary data. | |
97 | # this will be used by filectx.isbinary(). |
|
101 | # this will be used by filectx.isbinary(). | |
98 | if not util.binary(text): |
|
102 | if not stringutil.binary(text): | |
99 | # not hg filelog metadata (affecting commit hash), no "x-hg-" prefix |
|
103 | # not hg filelog metadata (affecting commit hash), no "x-hg-" prefix | |
100 | metadata['x-is-binary'] = '0' |
|
104 | metadata['x-is-binary'] = '0' | |
101 |
|
105 |
@@ -98,7 +98,10 from mercurial import ( | |||||
98 | util, |
|
98 | util, | |
99 | vfs as vfsmod, |
|
99 | vfs as vfsmod, | |
100 | ) |
|
100 | ) | |
101 |
from mercurial.utils import |
|
101 | from mercurial.utils import ( | |
|
102 | dateutil, | |||
|
103 | stringutil, | |||
|
104 | ) | |||
102 |
|
105 | |||
103 | release = lockmod.release |
|
106 | release = lockmod.release | |
104 | seriesopts = [('s', 'summary', None, _('print first line of patch header'))] |
|
107 | seriesopts = [('s', 'summary', None, _('print first line of patch header'))] | |
@@ -469,7 +472,7 class queue(object): | |||||
469 | self.guardsdirty = False |
|
472 | self.guardsdirty = False | |
470 | # Handle mq.git as a bool with extended values |
|
473 | # Handle mq.git as a bool with extended values | |
471 | gitmode = ui.config('mq', 'git').lower() |
|
474 | gitmode = ui.config('mq', 'git').lower() | |
472 | boolmode = util.parsebool(gitmode) |
|
475 | boolmode = stringutil.parsebool(gitmode) | |
473 | if boolmode is not None: |
|
476 | if boolmode is not None: | |
474 | if boolmode: |
|
477 | if boolmode: | |
475 | gitmode = 'yes' |
|
478 | gitmode = 'yes' | |
@@ -724,7 +727,7 class queue(object): | |||||
724 | os.unlink(undo) |
|
727 | os.unlink(undo) | |
725 | except OSError as inst: |
|
728 | except OSError as inst: | |
726 | self.ui.warn(_('error removing undo: %s\n') % |
|
729 | self.ui.warn(_('error removing undo: %s\n') % | |
727 | util.forcebytestr(inst)) |
|
730 | stringutil.forcebytestr(inst)) | |
728 |
|
731 | |||
729 | def backup(self, repo, files, copy=False): |
|
732 | def backup(self, repo, files, copy=False): | |
730 | # backup local changes in --force case |
|
733 | # backup local changes in --force case | |
@@ -857,7 +860,7 class queue(object): | |||||
857 | files=files, eolmode=None) |
|
860 | files=files, eolmode=None) | |
858 | return (True, list(files), fuzz) |
|
861 | return (True, list(files), fuzz) | |
859 | except Exception as inst: |
|
862 | except Exception as inst: | |
860 | self.ui.note(util.forcebytestr(inst) + '\n') |
|
863 | self.ui.note(stringutil.forcebytestr(inst) + '\n') | |
861 | if not self.ui.verbose: |
|
864 | if not self.ui.verbose: | |
862 | self.ui.warn(_("patch failed, unable to continue (try -v)\n")) |
|
865 | self.ui.warn(_("patch failed, unable to continue (try -v)\n")) | |
863 | self.ui.traceback() |
|
866 | self.ui.traceback() | |
@@ -1917,7 +1920,7 class queue(object): | |||||
1917 | if self.ui.formatted(): |
|
1920 | if self.ui.formatted(): | |
1918 | width = self.ui.termwidth() - len(pfx) - len(patchname) - 2 |
|
1921 | width = self.ui.termwidth() - len(pfx) - len(patchname) - 2 | |
1919 | if width > 0: |
|
1922 | if width > 0: | |
1920 | msg = util.ellipsis(msg, width) |
|
1923 | msg = stringutil.ellipsis(msg, width) | |
1921 | else: |
|
1924 | else: | |
1922 | msg = '' |
|
1925 | msg = '' | |
1923 | self.ui.write(patchname, label='qseries.' + state) |
|
1926 | self.ui.write(patchname, label='qseries.' + state) |
@@ -29,6 +29,9 from mercurial import ( | |||||
29 | util, |
|
29 | util, | |
30 | wireproto, |
|
30 | wireproto, | |
31 | ) |
|
31 | ) | |
|
32 | from mercurial.utils import ( | |||
|
33 | stringutil, | |||
|
34 | ) | |||
32 |
|
35 | |||
33 | NARROWCAP = 'narrow' |
|
36 | NARROWCAP = 'narrow' | |
34 | _NARROWACL_SECTION = 'narrowhgacl' |
|
37 | _NARROWACL_SECTION = 'narrowhgacl' | |
@@ -449,7 +452,7 def handlechangegroup_widen(op, inpart): | |||||
449 | except OSError as e: |
|
452 | except OSError as e: | |
450 | if e.errno != errno.ENOENT: |
|
453 | if e.errno != errno.ENOENT: | |
451 | ui.warn(_('error removing %s: %s\n') % |
|
454 | ui.warn(_('error removing %s: %s\n') % | |
452 | (undovfs.join(undofile), util.forcebytestr(e))) |
|
455 | (undovfs.join(undofile), stringutil.forcebytestr(e))) | |
453 |
|
456 | |||
454 | # Remove partial backup only if there were no exceptions |
|
457 | # Remove partial backup only if there were no exceptions | |
455 | vfs.unlink(chgrpfile) |
|
458 | vfs.unlink(chgrpfile) |
@@ -149,7 +149,10 from mercurial import ( | |||||
149 | registrar, |
|
149 | registrar, | |
150 | util, |
|
150 | util, | |
151 | ) |
|
151 | ) | |
152 |
from mercurial.utils import |
|
152 | from mercurial.utils import ( | |
|
153 | dateutil, | |||
|
154 | stringutil, | |||
|
155 | ) | |||
153 |
|
156 | |||
154 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
157 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | |
155 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
158 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | |
@@ -277,7 +280,7 class notifier(object): | |||||
277 | def fixmail(self, addr): |
|
280 | def fixmail(self, addr): | |
278 | '''try to clean up email addresses.''' |
|
281 | '''try to clean up email addresses.''' | |
279 |
|
282 | |||
280 | addr = util.email(addr.strip()) |
|
283 | addr = stringutil.email(addr.strip()) | |
281 | if self.domain: |
|
284 | if self.domain: | |
282 | a = addr.find('@localhost') |
|
285 | a = addr.find('@localhost') | |
283 | if a != -1: |
|
286 | if a != -1: | |
@@ -372,7 +375,7 class notifier(object): | |||||
372 | subject = '%s: %s' % (self.root, s) |
|
375 | subject = '%s: %s' % (self.root, s) | |
373 | maxsubject = int(self.ui.config('notify', 'maxsubject')) |
|
376 | maxsubject = int(self.ui.config('notify', 'maxsubject')) | |
374 | if maxsubject: |
|
377 | if maxsubject: | |
375 | subject = util.ellipsis(subject, maxsubject) |
|
378 | subject = stringutil.ellipsis(subject, maxsubject) | |
376 | msg['Subject'] = mail.headencode(self.ui, subject, |
|
379 | msg['Subject'] = mail.headencode(self.ui, subject, | |
377 | self.charsets, self.test) |
|
380 | self.charsets, self.test) | |
378 |
|
381 | |||
@@ -399,7 +402,7 class notifier(object): | |||||
399 | else: |
|
402 | else: | |
400 | self.ui.status(_('notify: sending %d subscribers %d changes\n') % |
|
403 | self.ui.status(_('notify: sending %d subscribers %d changes\n') % | |
401 | (len(subs), count)) |
|
404 | (len(subs), count)) | |
402 | mail.sendmail(self.ui, util.email(msg['From']), |
|
405 | mail.sendmail(self.ui, stringutil.email(msg['From']), | |
403 | subs, msgtext, mbox=self.mbox) |
|
406 | subs, msgtext, mbox=self.mbox) | |
404 |
|
407 | |||
405 | def diff(self, ctx, ref=None): |
|
408 | def diff(self, ctx, ref=None): |
@@ -18,6 +18,9 from mercurial import ( | |||||
18 | registrar, |
|
18 | registrar, | |
19 | util, |
|
19 | util, | |
20 | ) |
|
20 | ) | |
|
21 | from mercurial.utils import ( | |||
|
22 | stringutil, | |||
|
23 | ) | |||
21 |
|
24 | |||
22 | cmdtable = {} |
|
25 | cmdtable = {} | |
23 | command = registrar.command(cmdtable) |
|
26 | command = registrar.command(cmdtable) | |
@@ -187,7 +190,7 def do_relink(src, dst, files, ui): | |||||
187 | relinked += 1 |
|
190 | relinked += 1 | |
188 | savedbytes += sz |
|
191 | savedbytes += sz | |
189 | except OSError as inst: |
|
192 | except OSError as inst: | |
190 | ui.warn('%s: %s\n' % (tgt, util.forcebytestr(inst))) |
|
193 | ui.warn('%s: %s\n' % (tgt, stringutil.forcebytestr(inst))) | |
191 |
|
194 | |||
192 | ui.progress(_('relinking'), None) |
|
195 | ui.progress(_('relinking'), None) | |
193 |
|
196 |
@@ -56,7 +56,10 from mercurial import ( | |||||
56 | from . import ( |
|
56 | from . import ( | |
57 | rebase, |
|
57 | rebase, | |
58 | ) |
|
58 | ) | |
59 |
from mercurial.utils import |
|
59 | from mercurial.utils import ( | |
|
60 | dateutil, | |||
|
61 | stringutil, | |||
|
62 | ) | |||
60 |
|
63 | |||
61 | cmdtable = {} |
|
64 | cmdtable = {} | |
62 | command = registrar.command(cmdtable) |
|
65 | command = registrar.command(cmdtable) | |
@@ -477,7 +480,7 def _docreatecmd(ui, repo, pats, opts): | |||||
477 | _shelvecreatedcommit(repo, node, name) |
|
480 | _shelvecreatedcommit(repo, node, name) | |
478 |
|
481 | |||
479 | if ui.formatted(): |
|
482 | if ui.formatted(): | |
480 | desc = util.ellipsis(desc, ui.termwidth()) |
|
483 | desc = stringutil.ellipsis(desc, ui.termwidth()) | |
481 | ui.status(_('shelved as %s\n') % name) |
|
484 | ui.status(_('shelved as %s\n') % name) | |
482 | hg.update(repo, parent.node()) |
|
485 | hg.update(repo, parent.node()) | |
483 | if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts): |
|
486 | if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts): | |
@@ -578,7 +581,7 def listcmd(ui, repo, pats, opts): | |||||
578 | if not line.startswith('#'): |
|
581 | if not line.startswith('#'): | |
579 | desc = line.rstrip() |
|
582 | desc = line.rstrip() | |
580 | if ui.formatted(): |
|
583 | if ui.formatted(): | |
581 | desc = util.ellipsis(desc, width - used) |
|
584 | desc = stringutil.ellipsis(desc, width - used) | |
582 | ui.write(desc) |
|
585 | ui.write(desc) | |
583 | break |
|
586 | break | |
584 | ui.write('\n') |
|
587 | ui.write('\n') |
@@ -38,6 +38,9 from mercurial import ( | |||||
38 | util, |
|
38 | util, | |
39 | vfs as vfsmod, |
|
39 | vfs as vfsmod, | |
40 | ) |
|
40 | ) | |
|
41 | from mercurial.utils import ( | |||
|
42 | stringutil, | |||
|
43 | ) | |||
41 |
|
44 | |||
42 | class TransplantError(error.Abort): |
|
45 | class TransplantError(error.Abort): | |
43 | pass |
|
46 | pass | |
@@ -311,7 +314,7 class transplanter(object): | |||||
311 | p1 = repo.dirstate.p1() |
|
314 | p1 = repo.dirstate.p1() | |
312 | p2 = node |
|
315 | p2 = node | |
313 | self.log(user, date, message, p1, p2, merge=merge) |
|
316 | self.log(user, date, message, p1, p2, merge=merge) | |
314 | self.ui.write(util.forcebytestr(inst) + '\n') |
|
317 | self.ui.write(stringutil.forcebytestr(inst) + '\n') | |
315 | raise TransplantError(_('fix up the working directory and run ' |
|
318 | raise TransplantError(_('fix up the working directory and run ' | |
316 | 'hg transplant --continue')) |
|
319 | 'hg transplant --continue')) | |
317 | else: |
|
320 | else: |
@@ -50,7 +50,9 from mercurial.node import ( | |||||
50 | ) |
|
50 | ) | |
51 | from mercurial import ( |
|
51 | from mercurial import ( | |
52 | registrar, |
|
52 | registrar, | |
53 | util, |
|
53 | ) | |
|
54 | from mercurial.utils import ( | |||
|
55 | stringutil, | |||
54 | ) |
|
56 | ) | |
55 |
|
57 | |||
56 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
58 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | |
@@ -100,22 +102,22 def macdumbencode(s, cmd): | |||||
100 | return s.replace('\r', '\n') |
|
102 | return s.replace('\r', '\n') | |
101 |
|
103 | |||
102 | def cleverdecode(s, cmd, **kwargs): |
|
104 | def cleverdecode(s, cmd, **kwargs): | |
103 | if not util.binary(s): |
|
105 | if not stringutil.binary(s): | |
104 | return dumbdecode(s, cmd, **kwargs) |
|
106 | return dumbdecode(s, cmd, **kwargs) | |
105 | return s |
|
107 | return s | |
106 |
|
108 | |||
107 | def cleverencode(s, cmd): |
|
109 | def cleverencode(s, cmd): | |
108 | if not util.binary(s): |
|
110 | if not stringutil.binary(s): | |
109 | return dumbencode(s, cmd) |
|
111 | return dumbencode(s, cmd) | |
110 | return s |
|
112 | return s | |
111 |
|
113 | |||
112 | def macdecode(s, cmd, **kwargs): |
|
114 | def macdecode(s, cmd, **kwargs): | |
113 | if not util.binary(s): |
|
115 | if not stringutil.binary(s): | |
114 | return macdumbdecode(s, cmd, **kwargs) |
|
116 | return macdumbdecode(s, cmd, **kwargs) | |
115 | return s |
|
117 | return s | |
116 |
|
118 | |||
117 | def macencode(s, cmd): |
|
119 | def macencode(s, cmd): | |
118 | if not util.binary(s): |
|
120 | if not stringutil.binary(s): | |
119 | return macdumbencode(s, cmd) |
|
121 | return macdumbencode(s, cmd) | |
120 | return s |
|
122 | return s | |
121 |
|
123 | |||
@@ -146,7 +148,7 def forbidnewline(ui, repo, hooktype, no | |||||
146 | continue |
|
148 | continue | |
147 | seen.add(f) |
|
149 | seen.add(f) | |
148 | data = c[f].data() |
|
150 | data = c[f].data() | |
149 | if not util.binary(data) and newline in data: |
|
151 | if not stringutil.binary(data) and newline in data: | |
150 | if not halt: |
|
152 | if not halt: | |
151 | ui.warn(_('attempt to commit or push text file(s) ' |
|
153 | ui.warn(_('attempt to commit or push text file(s) ' | |
152 | 'using %s line endings\n') % |
|
154 | 'using %s line endings\n') % |
@@ -22,6 +22,9 from . import ( | |||||
22 | scmutil, |
|
22 | scmutil, | |
23 | util, |
|
23 | util, | |
24 | ) |
|
24 | ) | |
|
25 | from .utils import ( | |||
|
26 | stringutil, | |||
|
27 | ) | |||
25 |
|
28 | |||
26 | calcsize = struct.calcsize |
|
29 | calcsize = struct.calcsize | |
27 | pack_into = struct.pack_into |
|
30 | pack_into = struct.pack_into | |
@@ -256,7 +259,7 class branchcache(dict): | |||||
256 | except (IOError, OSError, error.Abort) as inst: |
|
259 | except (IOError, OSError, error.Abort) as inst: | |
257 | # Abort may be raised by read only opener, so log and continue |
|
260 | # Abort may be raised by read only opener, so log and continue | |
258 | repo.ui.debug("couldn't write branch cache: %s\n" % |
|
261 | repo.ui.debug("couldn't write branch cache: %s\n" % | |
259 | util.forcebytestr(inst)) |
|
262 | stringutil.forcebytestr(inst)) | |
260 |
|
263 | |||
261 | def update(self, repo, revgen): |
|
264 | def update(self, repo, revgen): | |
262 | """Given a branchhead cache, self, that may have extra nodes or be |
|
265 | """Given a branchhead cache, self, that may have extra nodes or be | |
@@ -378,7 +381,7 class revbranchcache(object): | |||||
378 | self._rbcrevs[:] = data |
|
381 | self._rbcrevs[:] = data | |
379 | except (IOError, OSError) as inst: |
|
382 | except (IOError, OSError) as inst: | |
380 | repo.ui.debug("couldn't read revision branch cache: %s\n" % |
|
383 | repo.ui.debug("couldn't read revision branch cache: %s\n" % | |
381 | util.forcebytestr(inst)) |
|
384 | stringutil.forcebytestr(inst)) | |
382 | # remember number of good records on disk |
|
385 | # remember number of good records on disk | |
383 | self._rbcrevslen = min(len(self._rbcrevs) // _rbcrecsize, |
|
386 | self._rbcrevslen = min(len(self._rbcrevs) // _rbcrecsize, | |
384 | len(repo.changelog)) |
|
387 | len(repo.changelog)) | |
@@ -540,7 +543,7 class revbranchcache(object): | |||||
540 | self._rbcrevslen = revs |
|
543 | self._rbcrevslen = revs | |
541 | except (IOError, OSError, error.Abort, error.LockError) as inst: |
|
544 | except (IOError, OSError, error.Abort, error.LockError) as inst: | |
542 | repo.ui.debug("couldn't write revision branch cache%s: %s\n" |
|
545 | repo.ui.debug("couldn't write revision branch cache%s: %s\n" | |
543 | % (step, util.forcebytestr(inst))) |
|
546 | % (step, stringutil.forcebytestr(inst))) | |
544 | finally: |
|
547 | finally: | |
545 | if wlock is not None: |
|
548 | if wlock is not None: | |
546 | wlock.release() |
|
549 | wlock.release() |
@@ -171,6 +171,9 from . import ( | |||||
171 | url, |
|
171 | url, | |
172 | util, |
|
172 | util, | |
173 | ) |
|
173 | ) | |
|
174 | from .utils import ( | |||
|
175 | stringutil, | |||
|
176 | ) | |||
174 |
|
177 | |||
175 | urlerr = util.urlerr |
|
178 | urlerr = util.urlerr | |
176 | urlreq = util.urlreq |
|
179 | urlreq = util.urlreq | |
@@ -1091,7 +1094,7 class bundlepart(object): | |||||
1091 | ui.debug('bundle2-generatorexit\n') |
|
1094 | ui.debug('bundle2-generatorexit\n') | |
1092 | raise |
|
1095 | raise | |
1093 | except BaseException as exc: |
|
1096 | except BaseException as exc: | |
1094 | bexc = util.forcebytestr(exc) |
|
1097 | bexc = stringutil.forcebytestr(exc) | |
1095 | # backup exception data for later |
|
1098 | # backup exception data for later | |
1096 | ui.debug('bundle2-input-stream-interrupt: encoding exception %s' |
|
1099 | ui.debug('bundle2-input-stream-interrupt: encoding exception %s' | |
1097 | % bexc) |
|
1100 | % bexc) |
@@ -28,6 +28,10 from . import ( | |||||
28 | util, |
|
28 | util, | |
29 | ) |
|
29 | ) | |
30 |
|
30 | |||
|
31 | from .utils import ( | |||
|
32 | stringutil, | |||
|
33 | ) | |||
|
34 | ||||
31 | _CHANGEGROUPV1_DELTA_HEADER = "20s20s20s20s" |
|
35 | _CHANGEGROUPV1_DELTA_HEADER = "20s20s20s20s" | |
32 | _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s" |
|
36 | _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s" | |
33 | _CHANGEGROUPV3_DELTA_HEADER = ">20s20s20s20s20sH" |
|
37 | _CHANGEGROUPV3_DELTA_HEADER = ">20s20s20s20s20sH" | |
@@ -514,7 +518,7 class cg1packer(object): | |||||
514 | if reorder == 'auto': |
|
518 | if reorder == 'auto': | |
515 | reorder = None |
|
519 | reorder = None | |
516 | else: |
|
520 | else: | |
517 | reorder = util.parsebool(reorder) |
|
521 | reorder = stringutil.parsebool(reorder) | |
518 | self._repo = repo |
|
522 | self._repo = repo | |
519 | self._reorder = reorder |
|
523 | self._reorder = reorder | |
520 | self._progress = repo.ui.progress |
|
524 | self._progress = repo.ui.progress |
@@ -24,7 +24,10 from . import ( | |||||
24 | revlog, |
|
24 | revlog, | |
25 | util, |
|
25 | util, | |
26 | ) |
|
26 | ) | |
27 |
from .utils import |
|
27 | from .utils import ( | |
|
28 | dateutil, | |||
|
29 | stringutil, | |||
|
30 | ) | |||
28 |
|
31 | |||
29 | _defaultextra = {'branch': 'default'} |
|
32 | _defaultextra = {'branch': 'default'} | |
30 |
|
33 | |||
@@ -36,7 +39,7 def _string_escape(text): | |||||
36 | >>> s |
|
39 | >>> s | |
37 | 'ab\\ncd\\\\\\\\n\\x00ab\\rcd\\\\\\n' |
|
40 | 'ab\\ncd\\\\\\\\n\\x00ab\\rcd\\\\\\n' | |
38 | >>> res = _string_escape(s) |
|
41 | >>> res = _string_escape(s) | |
39 | >>> s == util.unescapestr(res) |
|
42 | >>> s == stringutil.unescapestr(res) | |
40 | True |
|
43 | True | |
41 | """ |
|
44 | """ | |
42 | # subset of the string_escape codec |
|
45 | # subset of the string_escape codec | |
@@ -62,7 +65,7 def decodeextra(text): | |||||
62 | l = l.replace('\\\\', '\\\\\n') |
|
65 | l = l.replace('\\\\', '\\\\\n') | |
63 | l = l.replace('\\0', '\0') |
|
66 | l = l.replace('\\0', '\0') | |
64 | l = l.replace('\n', '') |
|
67 | l = l.replace('\n', '') | |
65 | k, v = util.unescapestr(l).split(':', 1) |
|
68 | k, v = stringutil.unescapestr(l).split(':', 1) | |
66 | extra[k] = v |
|
69 | extra[k] = v | |
67 | return extra |
|
70 | return extra | |
68 |
|
71 |
@@ -48,7 +48,12 from . import ( | |||||
48 | util, |
|
48 | util, | |
49 | vfs as vfsmod, |
|
49 | vfs as vfsmod, | |
50 | ) |
|
50 | ) | |
51 | from .utils import dateutil |
|
51 | ||
|
52 | from .utils import ( | |||
|
53 | dateutil, | |||
|
54 | stringutil, | |||
|
55 | ) | |||
|
56 | ||||
52 | stringio = util.stringio |
|
57 | stringio = util.stringio | |
53 |
|
58 | |||
54 | # templates of common command options |
|
59 | # templates of common command options | |
@@ -962,9 +967,9 def _buildfntemplate(pat, total=None, se | |||||
962 | while i < end: |
|
967 | while i < end: | |
963 | n = pat.find(b'%', i, end) |
|
968 | n = pat.find(b'%', i, end) | |
964 | if n < 0: |
|
969 | if n < 0: | |
965 | newname.append(util.escapestr(pat[i:end])) |
|
970 | newname.append(stringutil.escapestr(pat[i:end])) | |
966 | break |
|
971 | break | |
967 | newname.append(util.escapestr(pat[i:n])) |
|
972 | newname.append(stringutil.escapestr(pat[i:n])) | |
968 | if n + 2 > end: |
|
973 | if n + 2 > end: | |
969 | raise error.Abort(_("incomplete format spec in output " |
|
974 | raise error.Abort(_("incomplete format spec in output " | |
970 | "filename")) |
|
975 | "filename")) | |
@@ -1479,7 +1484,7 def tryimportone(ui, repo, hunk, parents | |||||
1479 | patch.patchrepo(ui, repo, p1, store, tmpname, strip, prefix, |
|
1484 | patch.patchrepo(ui, repo, p1, store, tmpname, strip, prefix, | |
1480 | files, eolmode=None) |
|
1485 | files, eolmode=None) | |
1481 | except error.PatchError as e: |
|
1486 | except error.PatchError as e: | |
1482 | raise error.Abort(util.forcebytestr(e)) |
|
1487 | raise error.Abort(stringutil.forcebytestr(e)) | |
1483 | if opts.get('exact'): |
|
1488 | if opts.get('exact'): | |
1484 | editor = None |
|
1489 | editor = None | |
1485 | else: |
|
1490 | else: |
@@ -14,7 +14,10 from .i18n import _ | |||||
14 | from . import ( |
|
14 | from . import ( | |
15 | encoding, |
|
15 | encoding, | |
16 | pycompat, |
|
16 | pycompat, | |
17 | util |
|
17 | ) | |
|
18 | ||||
|
19 | from .utils import ( | |||
|
20 | stringutil, | |||
18 | ) |
|
21 | ) | |
19 |
|
22 | |||
20 | try: |
|
23 | try: | |
@@ -200,7 +203,7 def _modesetup(ui): | |||||
200 |
|
203 | |||
201 | auto = (config == 'auto') |
|
204 | auto = (config == 'auto') | |
202 | always = False |
|
205 | always = False | |
203 | if not auto and util.parsebool(config): |
|
206 | if not auto and stringutil.parsebool(config): | |
204 | # We want the config to behave like a boolean, "on" is actually auto, |
|
207 | # We want the config to behave like a boolean, "on" is actually auto, | |
205 | # but "always" value is treated as a special case to reduce confusion. |
|
208 | # but "always" value is treated as a special case to reduce confusion. | |
206 | if ui.configsource('ui', 'color') == '--color' or config == 'always': |
|
209 | if ui.configsource('ui', 'color') == '--color' or config == 'always': |
@@ -61,7 +61,10 from . import ( | |||||
61 | util, |
|
61 | util, | |
62 | wireprotoserver, |
|
62 | wireprotoserver, | |
63 | ) |
|
63 | ) | |
64 |
from .utils import |
|
64 | from .utils import ( | |
|
65 | dateutil, | |||
|
66 | stringutil, | |||
|
67 | ) | |||
65 |
|
68 | |||
66 | release = lockmod.release |
|
69 | release = lockmod.release | |
67 |
|
70 | |||
@@ -2469,7 +2472,7 def grep(ui, repo, pattern, *pats, **opt | |||||
2469 | @util.cachefunc |
|
2472 | @util.cachefunc | |
2470 | def binary(): |
|
2473 | def binary(): | |
2471 | flog = getfile(fn) |
|
2474 | flog = getfile(fn) | |
2472 | return util.binary(flog.read(ctx.filenode(fn))) |
|
2475 | return stringutil.binary(flog.read(ctx.filenode(fn))) | |
2473 |
|
2476 | |||
2474 | fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} |
|
2477 | fieldnamemap = {'filename': 'file', 'linenumber': 'line_number'} | |
2475 | if opts.get('all'): |
|
2478 | if opts.get('all'): | |
@@ -3914,7 +3917,7 def postincoming(ui, repo, modheads, opt | |||||
3914 | try: |
|
3917 | try: | |
3915 | return hg.updatetotally(ui, repo, checkout, brev) |
|
3918 | return hg.updatetotally(ui, repo, checkout, brev) | |
3916 | except error.UpdateAbort as inst: |
|
3919 | except error.UpdateAbort as inst: | |
3917 | msg = _("not updating: %s") % util.forcebytestr(inst) |
|
3920 | msg = _("not updating: %s") % stringutil.forcebytestr(inst) | |
3918 | hint = inst.hint |
|
3921 | hint = inst.hint | |
3919 | raise error.UpdateAbort(msg, hint=hint) |
|
3922 | raise error.UpdateAbort(msg, hint=hint) | |
3920 | if modheads > 1: |
|
3923 | if modheads > 1: |
@@ -46,7 +46,10 from . import ( | |||||
46 | subrepoutil, |
|
46 | subrepoutil, | |
47 | util, |
|
47 | util, | |
48 | ) |
|
48 | ) | |
49 |
from .utils import |
|
49 | from .utils import ( | |
|
50 | dateutil, | |||
|
51 | stringutil, | |||
|
52 | ) | |||
50 |
|
53 | |||
51 | propertycache = util.propertycache |
|
54 | propertycache = util.propertycache | |
52 |
|
55 | |||
@@ -818,7 +821,7 class basefilectx(object): | |||||
818 |
|
821 | |||
819 | def isbinary(self): |
|
822 | def isbinary(self): | |
820 | try: |
|
823 | try: | |
821 | return util.binary(self.data()) |
|
824 | return stringutil.binary(self.data()) | |
822 | except IOError: |
|
825 | except IOError: | |
823 | return False |
|
826 | return False | |
824 | def isexec(self): |
|
827 | def isexec(self): | |
@@ -1500,7 +1503,8 class workingctx(committablectx): | |||||
1500 | for f in files: |
|
1503 | for f in files: | |
1501 | if self.flags(f) == 'l': |
|
1504 | if self.flags(f) == 'l': | |
1502 | d = self[f].data() |
|
1505 | d = self[f].data() | |
1503 |
if d == '' or len(d) >= 1024 or '\n' in d |
|
1506 | if (d == '' or len(d) >= 1024 or '\n' in d | |
|
1507 | or stringutil.binary(d)): | |||
1504 | self._repo.ui.debug('ignoring suspect symlink placeholder' |
|
1508 | self._repo.ui.debug('ignoring suspect symlink placeholder' | |
1505 | ' "%s"\n' % f) |
|
1509 | ' "%s"\n' % f) | |
1506 | continue |
|
1510 | continue |
@@ -23,6 +23,9 from . import ( | |||||
23 | scmutil, |
|
23 | scmutil, | |
24 | util, |
|
24 | util, | |
25 | ) |
|
25 | ) | |
|
26 | from .utils import ( | |||
|
27 | stringutil, | |||
|
28 | ) | |||
26 | stringio = util.stringio |
|
29 | stringio = util.stringio | |
27 |
|
30 | |||
28 | # This is required for ncurses to display non-ASCII characters in default user |
|
31 | # This is required for ncurses to display non-ASCII characters in default user | |
@@ -585,7 +588,7 class curseschunkselector(object): | |||||
585 | # long as not explicitly set to a falsy value - especially, |
|
588 | # long as not explicitly set to a falsy value - especially, | |
586 | # when not set at all. This is to stay most compatible with |
|
589 | # when not set at all. This is to stay most compatible with | |
587 | # previous (color only) behaviour. |
|
590 | # previous (color only) behaviour. | |
588 | uicolor = util.parsebool(self.ui.config('ui', 'color')) |
|
591 | uicolor = stringutil.parsebool(self.ui.config('ui', 'color')) | |
589 | self.usecolor = uicolor is not False |
|
592 | self.usecolor = uicolor is not False | |
590 |
|
593 | |||
591 | # the currently selected header, hunk, or hunk-line |
|
594 | # the currently selected header, hunk, or hunk-line | |
@@ -1058,7 +1061,7 class curseschunkselector(object): | |||||
1058 | if len(lines) != self.numstatuslines: |
|
1061 | if len(lines) != self.numstatuslines: | |
1059 | self.numstatuslines = len(lines) |
|
1062 | self.numstatuslines = len(lines) | |
1060 | self.statuswin.resize(self.numstatuslines, self.xscreensize) |
|
1063 | self.statuswin.resize(self.numstatuslines, self.xscreensize) | |
1061 | return [util.ellipsis(l, self.xscreensize - 1) for l in lines] |
|
1064 | return [stringutil.ellipsis(l, self.xscreensize - 1) for l in lines] | |
1062 |
|
1065 | |||
1063 | def updatescreen(self): |
|
1066 | def updatescreen(self): | |
1064 | self.statuswin.erase() |
|
1067 | self.statuswin.erase() |
@@ -14,7 +14,9 from .i18n import _ | |||||
14 | from . import ( |
|
14 | from . import ( | |
15 | error, |
|
15 | error, | |
16 | pycompat, |
|
16 | pycompat, | |
17 | util, |
|
17 | ) | |
|
18 | from .utils import ( | |||
|
19 | stringutil, | |||
18 | ) |
|
20 | ) | |
19 |
|
21 | |||
20 | def parsedag(desc): |
|
22 | def parsedag(desc): | |
@@ -372,8 +374,8 def dagtextlines(events, | |||||
372 | else: |
|
374 | else: | |
373 | raise error.Abort(_("invalid event type in dag: " |
|
375 | raise error.Abort(_("invalid event type in dag: " | |
374 | "('%s', '%s')") |
|
376 | "('%s', '%s')") | |
375 | % (util.escapestr(kind), |
|
377 | % (stringutil.escapestr(kind), | |
376 | util.escapestr(data))) |
|
378 | stringutil.escapestr(data))) | |
377 | if run: |
|
379 | if run: | |
378 | yield '+%d' % run |
|
380 | yield '+%d' % run | |
379 |
|
381 |
@@ -81,7 +81,10 from . import ( | |||||
81 | wireprotoframing, |
|
81 | wireprotoframing, | |
82 | wireprotoserver, |
|
82 | wireprotoserver, | |
83 | ) |
|
83 | ) | |
84 |
from .utils import |
|
84 | from .utils import ( | |
|
85 | dateutil, | |||
|
86 | stringutil, | |||
|
87 | ) | |||
85 |
|
88 | |||
86 | release = lockmod.release |
|
89 | release = lockmod.release | |
87 |
|
90 | |||
@@ -1141,7 +1144,7 def debuginstall(ui, **opts): | |||||
1141 | try: |
|
1144 | try: | |
1142 | codecs.lookup(pycompat.sysstr(encoding.encoding)) |
|
1145 | codecs.lookup(pycompat.sysstr(encoding.encoding)) | |
1143 | except LookupError as inst: |
|
1146 | except LookupError as inst: | |
1144 | err = util.forcebytestr(inst) |
|
1147 | err = stringutil.forcebytestr(inst) | |
1145 | problems += 1 |
|
1148 | problems += 1 | |
1146 | fm.condwrite(err, 'encodingerror', _(" %s\n" |
|
1149 | fm.condwrite(err, 'encodingerror', _(" %s\n" | |
1147 | " (check that your locale is properly set)\n"), err) |
|
1150 | " (check that your locale is properly set)\n"), err) | |
@@ -1197,7 +1200,7 def debuginstall(ui, **opts): | |||||
1197 | ) |
|
1200 | ) | |
1198 | dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes |
|
1201 | dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes | |
1199 | except Exception as inst: |
|
1202 | except Exception as inst: | |
1200 | err = util.forcebytestr(inst) |
|
1203 | err = stringutil.forcebytestr(inst) | |
1201 | problems += 1 |
|
1204 | problems += 1 | |
1202 | fm.condwrite(err, 'extensionserror', " %s\n", err) |
|
1205 | fm.condwrite(err, 'extensionserror', " %s\n", err) | |
1203 |
|
1206 | |||
@@ -1234,7 +1237,7 def debuginstall(ui, **opts): | |||||
1234 | try: |
|
1237 | try: | |
1235 | templater.templater.frommapfile(m) |
|
1238 | templater.templater.frommapfile(m) | |
1236 | except Exception as inst: |
|
1239 | except Exception as inst: | |
1237 | err = util.forcebytestr(inst) |
|
1240 | err = stringutil.forcebytestr(inst) | |
1238 | p = None |
|
1241 | p = None | |
1239 | fm.condwrite(err, 'defaulttemplateerror', " %s\n", err) |
|
1242 | fm.condwrite(err, 'defaulttemplateerror', " %s\n", err) | |
1240 | else: |
|
1243 | else: | |
@@ -1271,7 +1274,7 def debuginstall(ui, **opts): | |||||
1271 | try: |
|
1274 | try: | |
1272 | username = ui.username() |
|
1275 | username = ui.username() | |
1273 | except error.Abort as e: |
|
1276 | except error.Abort as e: | |
1274 | err = util.forcebytestr(e) |
|
1277 | err = stringutil.forcebytestr(e) | |
1275 | problems += 1 |
|
1278 | problems += 1 | |
1276 |
|
1279 | |||
1277 | fm.condwrite(username, 'username', _("checking username (%s)\n"), username) |
|
1280 | fm.condwrite(username, 'username', _("checking username (%s)\n"), username) | |
@@ -1822,8 +1825,8 def debugpushkey(ui, repopath, namespace | |||||
1822 | return not r |
|
1825 | return not r | |
1823 | else: |
|
1826 | else: | |
1824 | for k, v in sorted(target.listkeys(namespace).iteritems()): |
|
1827 | for k, v in sorted(target.listkeys(namespace).iteritems()): | |
1825 | ui.write("%s\t%s\n" % (util.escapestr(k), |
|
1828 | ui.write("%s\t%s\n" % (stringutil.escapestr(k), | |
1826 | util.escapestr(v))) |
|
1829 | stringutil.escapestr(v))) | |
1827 |
|
1830 | |||
1828 | @command('debugpvec', [], _('A B')) |
|
1831 | @command('debugpvec', [], _('A B')) | |
1829 | def debugpvec(ui, repo, a, b=None): |
|
1832 | def debugpvec(ui, repo, a, b=None): | |
@@ -2909,7 +2912,7 def debugwireproto(ui, repo, path=None, | |||||
2909 |
|
2912 | |||
2910 | # Concatenate the data together. |
|
2913 | # Concatenate the data together. | |
2911 | data = ''.join(l.lstrip() for l in lines) |
|
2914 | data = ''.join(l.lstrip() for l in lines) | |
2912 | data = util.unescapestr(data) |
|
2915 | data = stringutil.unescapestr(data) | |
2913 | stdin.write(data) |
|
2916 | stdin.write(data) | |
2914 |
|
2917 | |||
2915 | if action == 'raw+': |
|
2918 | if action == 'raw+': | |
@@ -2935,7 +2938,7 def debugwireproto(ui, repo, path=None, | |||||
2935 | else: |
|
2938 | else: | |
2936 | key, value = fields |
|
2939 | key, value = fields | |
2937 |
|
2940 | |||
2938 | args[key] = util.unescapestr(value) |
|
2941 | args[key] = stringutil.unescapestr(value) | |
2939 |
|
2942 | |||
2940 | if batchedcommands is not None: |
|
2943 | if batchedcommands is not None: | |
2941 | batchedcommands.append((command, args)) |
|
2944 | batchedcommands.append((command, args)) | |
@@ -2948,12 +2951,12 def debugwireproto(ui, repo, path=None, | |||||
2948 | del args['PUSHFILE'] |
|
2951 | del args['PUSHFILE'] | |
2949 | res, output = peer._callpush(command, fh, |
|
2952 | res, output = peer._callpush(command, fh, | |
2950 | **pycompat.strkwargs(args)) |
|
2953 | **pycompat.strkwargs(args)) | |
2951 | ui.status(_('result: %s\n') % util.escapedata(res)) |
|
2954 | ui.status(_('result: %s\n') % stringutil.escapedata(res)) | |
2952 | ui.status(_('remote output: %s\n') % |
|
2955 | ui.status(_('remote output: %s\n') % | |
2953 | util.escapedata(output)) |
|
2956 | stringutil.escapedata(output)) | |
2954 | else: |
|
2957 | else: | |
2955 | res = peer._call(command, **pycompat.strkwargs(args)) |
|
2958 | res = peer._call(command, **pycompat.strkwargs(args)) | |
2956 | ui.status(_('response: %s\n') % util.escapedata(res)) |
|
2959 | ui.status(_('response: %s\n') % stringutil.escapedata(res)) | |
2957 |
|
2960 | |||
2958 | elif action == 'batchbegin': |
|
2961 | elif action == 'batchbegin': | |
2959 | if batchedcommands is not None: |
|
2962 | if batchedcommands is not None: | |
@@ -2967,7 +2970,8 def debugwireproto(ui, repo, path=None, | |||||
2967 | ui.status(_('sending batch with %d sub-commands\n') % |
|
2970 | ui.status(_('sending batch with %d sub-commands\n') % | |
2968 | len(batchedcommands)) |
|
2971 | len(batchedcommands)) | |
2969 | for i, chunk in enumerate(peer._submitbatch(batchedcommands)): |
|
2972 | for i, chunk in enumerate(peer._submitbatch(batchedcommands)): | |
2970 |
ui.status(_('response #%d: %s\n') % |
|
2973 | ui.status(_('response #%d: %s\n') % | |
|
2974 | (i, stringutil.escapedata(chunk))) | |||
2971 |
|
2975 | |||
2972 | batchedcommands = None |
|
2976 | batchedcommands = None | |
2973 |
|
2977 |
@@ -41,6 +41,10 from . import ( | |||||
41 | util, |
|
41 | util, | |
42 | ) |
|
42 | ) | |
43 |
|
43 | |||
|
44 | from .utils import ( | |||
|
45 | stringutil, | |||
|
46 | ) | |||
|
47 | ||||
44 | unrecoverablewrite = registrar.command.unrecoverablewrite |
|
48 | unrecoverablewrite = registrar.command.unrecoverablewrite | |
45 |
|
49 | |||
46 | class request(object): |
|
50 | class request(object): | |
@@ -496,7 +500,7 class cmdalias(object): | |||||
496 | args = pycompat.shlexsplit(self.definition) |
|
500 | args = pycompat.shlexsplit(self.definition) | |
497 | except ValueError as inst: |
|
501 | except ValueError as inst: | |
498 | self.badalias = (_("error in definition for alias '%s': %s") |
|
502 | self.badalias = (_("error in definition for alias '%s': %s") | |
499 | % (self.name, util.forcebytestr(inst))) |
|
503 | % (self.name, stringutil.forcebytestr(inst))) | |
500 | return |
|
504 | return | |
501 | earlyopts, args = _earlysplitopts(args) |
|
505 | earlyopts, args = _earlysplitopts(args) | |
502 | if earlyopts: |
|
506 | if earlyopts: | |
@@ -623,7 +627,7 def _parse(ui, args): | |||||
623 | try: |
|
627 | try: | |
624 | args = fancyopts.fancyopts(args, commands.globalopts, options) |
|
628 | args = fancyopts.fancyopts(args, commands.globalopts, options) | |
625 | except getopt.GetoptError as inst: |
|
629 | except getopt.GetoptError as inst: | |
626 | raise error.CommandError(None, util.forcebytestr(inst)) |
|
630 | raise error.CommandError(None, stringutil.forcebytestr(inst)) | |
627 |
|
631 | |||
628 | if args: |
|
632 | if args: | |
629 | cmd, args = args[0], args[1:] |
|
633 | cmd, args = args[0], args[1:] | |
@@ -647,7 +651,7 def _parse(ui, args): | |||||
647 | try: |
|
651 | try: | |
648 | args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True) |
|
652 | args = fancyopts.fancyopts(args, c, cmdoptions, gnu=True) | |
649 | except getopt.GetoptError as inst: |
|
653 | except getopt.GetoptError as inst: | |
650 | raise error.CommandError(cmd, util.forcebytestr(inst)) |
|
654 | raise error.CommandError(cmd, stringutil.forcebytestr(inst)) | |
651 |
|
655 | |||
652 | # separate global options back out |
|
656 | # separate global options back out | |
653 | for o in commands.globalopts: |
|
657 | for o in commands.globalopts: | |
@@ -872,7 +876,7 def _dispatch(req): | |||||
872 | ui_.setconfig('ui', 'color', coloropt, '--color') |
|
876 | ui_.setconfig('ui', 'color', coloropt, '--color') | |
873 | color.setup(ui_) |
|
877 | color.setup(ui_) | |
874 |
|
878 | |||
875 | if util.parsebool(options['pager']): |
|
879 | if stringutil.parsebool(options['pager']): | |
876 | # ui.pager() expects 'internal-always-' prefix in this case |
|
880 | # ui.pager() expects 'internal-always-' prefix in this case | |
877 | ui.pager('internal-always-' + cmd) |
|
881 | ui.pager('internal-always-' + cmd) | |
878 | elif options['pager'] != 'auto': |
|
882 | elif options['pager'] != 'auto': | |
@@ -968,7 +972,7 def _exceptionwarning(ui): | |||||
968 | for name, mod in extensions.extensions(): |
|
972 | for name, mod in extensions.extensions(): | |
969 | # 'testedwith' should be bytes, but not all extensions are ported |
|
973 | # 'testedwith' should be bytes, but not all extensions are ported | |
970 | # to py3 and we don't want UnicodeException because of that. |
|
974 | # to py3 and we don't want UnicodeException because of that. | |
971 | testedwith = util.forcebytestr(getattr(mod, 'testedwith', '')) |
|
975 | testedwith = stringutil.forcebytestr(getattr(mod, 'testedwith', '')) | |
972 | report = getattr(mod, 'buglink', _('the extension author.')) |
|
976 | report = getattr(mod, 'buglink', _('the extension author.')) | |
973 | if not testedwith.strip(): |
|
977 | if not testedwith.strip(): | |
974 | # We found an untested extension. It's likely the culprit. |
|
978 | # We found an untested extension. It's likely the culprit. | |
@@ -990,7 +994,8 def _exceptionwarning(ui): | |||||
990 | if worst[0] is not None: |
|
994 | if worst[0] is not None: | |
991 | name, testedwith, report = worst |
|
995 | name, testedwith, report = worst | |
992 | if not isinstance(testedwith, (bytes, str)): |
|
996 | if not isinstance(testedwith, (bytes, str)): | |
993 |
testedwith = '.'.join([util.forcebytestr(c) |
|
997 | testedwith = '.'.join([stringutil.forcebytestr(c) | |
|
998 | for c in testedwith]) | |||
994 | warning = (_('** Unknown exception encountered with ' |
|
999 | warning = (_('** Unknown exception encountered with ' | |
995 | 'possibly-broken third-party extension %s\n' |
|
1000 | 'possibly-broken third-party extension %s\n' | |
996 | '** which supports versions %s of Mercurial.\n' |
|
1001 | '** which supports versions %s of Mercurial.\n' |
@@ -35,6 +35,9 from . import ( | |||||
35 | url as urlmod, |
|
35 | url as urlmod, | |
36 | util, |
|
36 | util, | |
37 | ) |
|
37 | ) | |
|
38 | from .utils import ( | |||
|
39 | stringutil, | |||
|
40 | ) | |||
38 |
|
41 | |||
39 | urlerr = util.urlerr |
|
42 | urlerr = util.urlerr | |
40 | urlreq = util.urlreq |
|
43 | urlreq = util.urlreq | |
@@ -2180,7 +2183,7 def filterclonebundleentries(repo, entri | |||||
2180 | except error.UnsupportedBundleSpecification as e: |
|
2183 | except error.UnsupportedBundleSpecification as e: | |
2181 | repo.ui.debug('filtering %s because unsupported bundle ' |
|
2184 | repo.ui.debug('filtering %s because unsupported bundle ' | |
2182 | 'spec: %s\n' % ( |
|
2185 | 'spec: %s\n' % ( | |
2183 | entry['URL'], util.forcebytestr(e))) |
|
2186 | entry['URL'], stringutil.forcebytestr(e))) | |
2184 | continue |
|
2187 | continue | |
2185 | # If we don't have a spec and requested a stream clone, we don't know |
|
2188 | # If we don't have a spec and requested a stream clone, we don't know | |
2186 | # what the entry is so don't attempt to apply it. |
|
2189 | # what the entry is so don't attempt to apply it. | |
@@ -2286,9 +2289,9 def trypullbundlefromurl(ui, repo, url): | |||||
2286 | return True |
|
2289 | return True | |
2287 | except urlerr.httperror as e: |
|
2290 | except urlerr.httperror as e: | |
2288 | ui.warn(_('HTTP error fetching bundle: %s\n') % |
|
2291 | ui.warn(_('HTTP error fetching bundle: %s\n') % | |
2289 | util.forcebytestr(e)) |
|
2292 | stringutil.forcebytestr(e)) | |
2290 | except urlerr.urlerror as e: |
|
2293 | except urlerr.urlerror as e: | |
2291 | ui.warn(_('error fetching bundle: %s\n') % |
|
2294 | ui.warn(_('error fetching bundle: %s\n') % | |
2292 | util.forcebytestr(e.reason)) |
|
2295 | stringutil.forcebytestr(e.reason)) | |
2293 |
|
2296 | |||
2294 | return False |
|
2297 | return False |
@@ -25,6 +25,10 from . import ( | |||||
25 | util, |
|
25 | util, | |
26 | ) |
|
26 | ) | |
27 |
|
27 | |||
|
28 | from .utils import ( | |||
|
29 | stringutil, | |||
|
30 | ) | |||
|
31 | ||||
28 | _extensions = {} |
|
32 | _extensions = {} | |
29 | _disabledextensions = {} |
|
33 | _disabledextensions = {} | |
30 | _aftercallbacks = {} |
|
34 | _aftercallbacks = {} | |
@@ -118,7 +122,7 def _reportimporterror(ui, err, failed, | |||||
118 | # note: this ui.debug happens before --debug is processed, |
|
122 | # note: this ui.debug happens before --debug is processed, | |
119 | # Use --config ui.debug=1 to see them. |
|
123 | # Use --config ui.debug=1 to see them. | |
120 | ui.debug('could not import %s (%s): trying %s\n' |
|
124 | ui.debug('could not import %s (%s): trying %s\n' | |
121 | % (failed, util.forcebytestr(err), next)) |
|
125 | % (failed, stringutil.forcebytestr(err), next)) | |
122 | if ui.debugflag: |
|
126 | if ui.debugflag: | |
123 | ui.traceback() |
|
127 | ui.traceback() | |
124 |
|
128 | |||
@@ -129,7 +133,7 def _rejectunicode(name, xs): | |||||
129 | elif isinstance(xs, dict): |
|
133 | elif isinstance(xs, dict): | |
130 | for k, v in xs.items(): |
|
134 | for k, v in xs.items(): | |
131 | _rejectunicode(name, k) |
|
135 | _rejectunicode(name, k) | |
132 | _rejectunicode(b'%s.%s' % (name, util.forcebytestr(k)), v) |
|
136 | _rejectunicode(b'%s.%s' % (name, stringutil.forcebytestr(k)), v) | |
133 | elif isinstance(xs, type(u'')): |
|
137 | elif isinstance(xs, type(u'')): | |
134 | raise error.ProgrammingError(b"unicode %r found in %s" % (xs, name), |
|
138 | raise error.ProgrammingError(b"unicode %r found in %s" % (xs, name), | |
135 | hint="use b'' to make it byte string") |
|
139 | hint="use b'' to make it byte string") | |
@@ -198,7 +202,7 def _runuisetup(name, ui): | |||||
198 | uisetup(ui) |
|
202 | uisetup(ui) | |
199 | except Exception as inst: |
|
203 | except Exception as inst: | |
200 | ui.traceback(force=True) |
|
204 | ui.traceback(force=True) | |
201 | msg = util.forcebytestr(inst) |
|
205 | msg = stringutil.forcebytestr(inst) | |
202 | ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) |
|
206 | ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) | |
203 | return False |
|
207 | return False | |
204 | return True |
|
208 | return True | |
@@ -215,7 +219,7 def _runextsetup(name, ui): | |||||
215 | extsetup() # old extsetup with no ui argument |
|
219 | extsetup() # old extsetup with no ui argument | |
216 | except Exception as inst: |
|
220 | except Exception as inst: | |
217 | ui.traceback(force=True) |
|
221 | ui.traceback(force=True) | |
218 | msg = util.forcebytestr(inst) |
|
222 | msg = stringutil.forcebytestr(inst) | |
219 | ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) |
|
223 | ui.warn(_("*** failed to set up extension %s: %s\n") % (name, msg)) | |
220 | return False |
|
224 | return False | |
221 | return True |
|
225 | return True | |
@@ -233,7 +237,7 def loadall(ui, whitelist=None): | |||||
233 | try: |
|
237 | try: | |
234 | load(ui, name, path) |
|
238 | load(ui, name, path) | |
235 | except Exception as inst: |
|
239 | except Exception as inst: | |
236 | msg = util.forcebytestr(inst) |
|
240 | msg = stringutil.forcebytestr(inst) | |
237 | if path: |
|
241 | if path: | |
238 | ui.warn(_("*** failed to import extension %s from %s: %s\n") |
|
242 | ui.warn(_("*** failed to import extension %s from %s: %s\n") | |
239 | % (name, path, msg)) |
|
243 | % (name, path, msg)) |
@@ -31,6 +31,10 from . import ( | |||||
31 | util, |
|
31 | util, | |
32 | ) |
|
32 | ) | |
33 |
|
33 | |||
|
34 | from .utils import ( | |||
|
35 | stringutil, | |||
|
36 | ) | |||
|
37 | ||||
34 | def _toolstr(ui, tool, part, *args): |
|
38 | def _toolstr(ui, tool, part, *args): | |
35 | return ui.config("merge-tools", tool + "." + part, *args) |
|
39 | return ui.config("merge-tools", tool + "." + part, *args) | |
36 |
|
40 | |||
@@ -573,7 +577,7 def _formatconflictmarker(ctx, template, | |||||
573 | mark = mark.splitlines()[0] # split for safety |
|
577 | mark = mark.splitlines()[0] # split for safety | |
574 |
|
578 | |||
575 | # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ') |
|
579 | # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ') | |
576 | return util.ellipsis(mark, 80 - 8) |
|
580 | return stringutil.ellipsis(mark, 80 - 8) | |
577 |
|
581 | |||
578 | _defaultconflictlabels = ['local', 'other'] |
|
582 | _defaultconflictlabels = ['local', 'other'] | |
579 |
|
583 |
@@ -20,6 +20,9 from . import ( | |||||
20 | scmutil, |
|
20 | scmutil, | |
21 | util, |
|
21 | util, | |
22 | ) |
|
22 | ) | |
|
23 | from .utils import ( | |||
|
24 | stringutil, | |||
|
25 | ) | |||
23 |
|
26 | |||
24 | elements = { |
|
27 | elements = { | |
25 | # token-type: binding-strength, primary, prefix, infix, suffix |
|
28 | # token-type: binding-strength, primary, prefix, infix, suffix | |
@@ -445,7 +448,7 def eol(mctx, x): | |||||
445 | s = [] |
|
448 | s = [] | |
446 | for f in mctx.existing(): |
|
449 | for f in mctx.existing(): | |
447 | d = mctx.ctx[f].data() |
|
450 | d = mctx.ctx[f].data() | |
448 | if util.binary(d): |
|
451 | if stringutil.binary(d): | |
449 | continue |
|
452 | continue | |
450 | if (enc == 'dos' or enc == 'win') and '\r\n' in d: |
|
453 | if (enc == 'dos' or enc == 'win') and '\r\n' in d: | |
451 | s.append(f) |
|
454 | s.append(f) |
@@ -48,6 +48,10 from . import ( | |||||
48 | vfs as vfsmod, |
|
48 | vfs as vfsmod, | |
49 | ) |
|
49 | ) | |
50 |
|
50 | |||
|
51 | from .utils import ( | |||
|
52 | stringutil, | |||
|
53 | ) | |||
|
54 | ||||
51 | release = lock.release |
|
55 | release = lock.release | |
52 |
|
56 | |||
53 | # shared features |
|
57 | # shared features | |
@@ -270,7 +274,7 def share(ui, source, dest=None, update= | |||||
270 | # ValueError is raised on Windows if the drive letters differ on |
|
274 | # ValueError is raised on Windows if the drive letters differ on | |
271 | # each path |
|
275 | # each path | |
272 | raise error.Abort(_('cannot calculate relative path'), |
|
276 | raise error.Abort(_('cannot calculate relative path'), | |
273 | hint=util.forcebytestr(e)) |
|
277 | hint=stringutil.forcebytestr(e)) | |
274 | else: |
|
278 | else: | |
275 | requirements += 'shared\n' |
|
279 | requirements += 'shared\n' | |
276 |
|
280 |
@@ -36,7 +36,10 from .. import ( | |||||
36 | scmutil, |
|
36 | scmutil, | |
37 | smartset, |
|
37 | smartset, | |
38 | templater, |
|
38 | templater, | |
39 | util, |
|
39 | ) | |
|
40 | ||||
|
41 | from ..utils import ( | |||
|
42 | stringutil, | |||
40 | ) |
|
43 | ) | |
41 |
|
44 | |||
42 | from . import ( |
|
45 | from . import ( | |
@@ -121,7 +124,7 def rawfile(web): | |||||
121 | if guessmime: |
|
124 | if guessmime: | |
122 | mt = mimetypes.guess_type(path)[0] |
|
125 | mt = mimetypes.guess_type(path)[0] | |
123 | if mt is None: |
|
126 | if mt is None: | |
124 | if util.binary(text): |
|
127 | if stringutil.binary(text): | |
125 | mt = 'application/binary' |
|
128 | mt = 'application/binary' | |
126 | else: |
|
129 | else: | |
127 | mt = 'text/plain' |
|
130 | mt = 'text/plain' | |
@@ -141,7 +144,7 def _filerevision(web, fctx): | |||||
141 | parity = paritygen(web.stripecount) |
|
144 | parity = paritygen(web.stripecount) | |
142 | ishead = fctx.filerev() in fctx.filelog().headrevs() |
|
145 | ishead = fctx.filerev() in fctx.filelog().headrevs() | |
143 |
|
146 | |||
144 | if util.binary(text): |
|
147 | if stringutil.binary(text): | |
145 | mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' |
|
148 | mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' | |
146 | text = '(binary:%s)' % mt |
|
149 | text = '(binary:%s)' % mt | |
147 |
|
150 |
@@ -38,6 +38,10 from .. import ( | |||||
38 | util, |
|
38 | util, | |
39 | ) |
|
39 | ) | |
40 |
|
40 | |||
|
41 | from ..utils import ( | |||
|
42 | stringutil, | |||
|
43 | ) | |||
|
44 | ||||
41 | def up(p): |
|
45 | def up(p): | |
42 | if p[0:1] != "/": |
|
46 | if p[0:1] != "/": | |
43 | p = "/" + p |
|
47 | p = "/" + p | |
@@ -180,7 +184,7 def difffeatureopts(req, ui, section): | |||||
180 | for k in ('ignorews', 'ignorewsamount', 'ignorewseol', 'ignoreblanklines'): |
|
184 | for k in ('ignorews', 'ignorewsamount', 'ignorewseol', 'ignoreblanklines'): | |
181 | v = req.qsparams.get(k) |
|
185 | v = req.qsparams.get(k) | |
182 | if v is not None: |
|
186 | if v is not None: | |
183 | v = util.parsebool(v) |
|
187 | v = stringutil.parsebool(v) | |
184 | setattr(diffopts, k, v if v is not None else True) |
|
188 | setattr(diffopts, k, v if v is not None else True) | |
185 |
|
189 | |||
186 | return diffopts |
|
190 | return diffopts |
@@ -64,6 +64,9 from . import ( | |||||
64 | util, |
|
64 | util, | |
65 | vfs as vfsmod, |
|
65 | vfs as vfsmod, | |
66 | ) |
|
66 | ) | |
|
67 | from .utils import ( | |||
|
68 | stringutil, | |||
|
69 | ) | |||
67 |
|
70 | |||
68 | release = lockmod.release |
|
71 | release = lockmod.release | |
69 | urlerr = util.urlerr |
|
72 | urlerr = util.urlerr | |
@@ -263,7 +266,7 class localpeer(repository.peer): | |||||
263 | raise |
|
266 | raise | |
264 | except error.PushRaced as exc: |
|
267 | except error.PushRaced as exc: | |
265 | raise error.ResponseError(_('push failed:'), |
|
268 | raise error.ResponseError(_('push failed:'), | |
266 | util.forcebytestr(exc)) |
|
269 | stringutil.forcebytestr(exc)) | |
267 |
|
270 | |||
268 | # End of _basewirecommands interface. |
|
271 | # End of _basewirecommands interface. | |
269 |
|
272 |
@@ -35,7 +35,10 from . import ( | |||||
35 | templater, |
|
35 | templater, | |
36 | util, |
|
36 | util, | |
37 | ) |
|
37 | ) | |
38 |
from .utils import |
|
38 | from .utils import ( | |
|
39 | dateutil, | |||
|
40 | stringutil, | |||
|
41 | ) | |||
39 |
|
42 | |||
40 | def getlimit(opts): |
|
43 | def getlimit(opts): | |
41 | """get the log limit according to option -l/--limit""" |
|
44 | """get the log limit according to option -l/--limit""" | |
@@ -260,7 +263,8 class changesetprinter(object): | |||||
260 | extra = ctx.extra() |
|
263 | extra = ctx.extra() | |
261 | if extra and self.ui.debugflag: |
|
264 | if extra and self.ui.debugflag: | |
262 | for key, value in sorted(extra.items()): |
|
265 | for key, value in sorted(extra.items()): | |
263 |
self.ui.write(columns['extra'] |
|
266 | self.ui.write(columns['extra'] | |
|
267 | % (key, stringutil.escapestr(value)), | |||
264 | label='ui.debug log.extra') |
|
268 | label='ui.debug log.extra') | |
265 |
|
269 | |||
266 | description = ctx.description().strip() |
|
270 | description = ctx.description().strip() |
@@ -24,6 +24,9 from . import ( | |||||
24 | sslutil, |
|
24 | sslutil, | |
25 | util, |
|
25 | util, | |
26 | ) |
|
26 | ) | |
|
27 | from .utils import ( | |||
|
28 | stringutil, | |||
|
29 | ) | |||
27 |
|
30 | |||
28 | class STARTTLS(smtplib.SMTP): |
|
31 | class STARTTLS(smtplib.SMTP): | |
29 | '''Derived class to verify the peer certificate for STARTTLS. |
|
32 | '''Derived class to verify the peer certificate for STARTTLS. | |
@@ -81,7 +84,7 def _smtp(ui): | |||||
81 | local_hostname = ui.config('smtp', 'local_hostname') |
|
84 | local_hostname = ui.config('smtp', 'local_hostname') | |
82 | tls = ui.config('smtp', 'tls') |
|
85 | tls = ui.config('smtp', 'tls') | |
83 | # backward compatible: when tls = true, we use starttls. |
|
86 | # backward compatible: when tls = true, we use starttls. | |
84 | starttls = tls == 'starttls' or util.parsebool(tls) |
|
87 | starttls = tls == 'starttls' or stringutil.parsebool(tls) | |
85 | smtps = tls == 'smtps' |
|
88 | smtps = tls == 'smtps' | |
86 | if (starttls or smtps) and not util.safehasattr(socket, 'ssl'): |
|
89 | if (starttls or smtps) and not util.safehasattr(socket, 'ssl'): | |
87 | raise error.Abort(_("can't use TLS: Python SSL support not installed")) |
|
90 | raise error.Abort(_("can't use TLS: Python SSL support not installed")) | |
@@ -137,8 +140,8 def _smtp(ui): | |||||
137 | def _sendmail(ui, sender, recipients, msg): |
|
140 | def _sendmail(ui, sender, recipients, msg): | |
138 | '''send mail using sendmail.''' |
|
141 | '''send mail using sendmail.''' | |
139 | program = ui.config('email', 'method') |
|
142 | program = ui.config('email', 'method') | |
140 | cmdline = '%s -f %s %s' % (program, util.email(sender), |
|
143 | cmdline = '%s -f %s %s' % (program, stringutil.email(sender), | |
141 | ' '.join(map(util.email, recipients))) |
|
144 | ' '.join(map(stringutil.email, recipients))) | |
142 | ui.note(_('sending mail: %s\n') % cmdline) |
|
145 | ui.note(_('sending mail: %s\n') % cmdline) | |
143 | fp = util.popen(cmdline, 'w') |
|
146 | fp = util.popen(cmdline, 'w') | |
144 | fp.write(msg) |
|
147 | fp.write(msg) |
@@ -19,6 +19,9 from . import ( | |||||
19 | pycompat, |
|
19 | pycompat, | |
20 | util, |
|
20 | util, | |
21 | ) |
|
21 | ) | |
|
22 | from .utils import ( | |||
|
23 | stringutil, | |||
|
24 | ) | |||
22 |
|
25 | |||
23 | allpatternkinds = ('re', 'glob', 'path', 'relglob', 'relpath', 'relre', |
|
26 | allpatternkinds = ('re', 'glob', 'path', 'relglob', 'relpath', 'relre', | |
24 | 'listfile', 'listfile0', 'set', 'include', 'subinclude', |
|
27 | 'listfile', 'listfile0', 'set', 'include', 'subinclude', | |
@@ -227,7 +230,7 def _donormalize(patterns, default, root | |||||
227 | except IOError as inst: |
|
230 | except IOError as inst: | |
228 | if warn: |
|
231 | if warn: | |
229 | warn(_("skipping unreadable pattern file '%s': %s\n") % |
|
232 | warn(_("skipping unreadable pattern file '%s': %s\n") % | |
230 | (pat, util.forcebytestr(inst.strerror))) |
|
233 | (pat, stringutil.forcebytestr(inst.strerror))) | |
231 | continue |
|
234 | continue | |
232 | # else: re or relre - which cannot be normalized |
|
235 | # else: re or relre - which cannot be normalized | |
233 | kindpats.append((kind, pat, '')) |
|
236 | kindpats.append((kind, pat, '')) |
@@ -27,7 +27,9 from . import ( | |||||
27 | encoding, |
|
27 | encoding, | |
28 | pycompat, |
|
28 | pycompat, | |
29 | url, |
|
29 | url, | |
30 | util, |
|
30 | ) | |
|
31 | from .utils import ( | |||
|
32 | stringutil, | |||
31 | ) |
|
33 | ) | |
32 |
|
34 | |||
33 | def section(s): |
|
35 | def section(s): | |
@@ -459,7 +461,7 def formatoption(block, width): | |||||
459 | hanging = block['optstrwidth'] |
|
461 | hanging = block['optstrwidth'] | |
460 | initindent = '%s%s ' % (block['optstr'], ' ' * ((hanging - colwidth))) |
|
462 | initindent = '%s%s ' % (block['optstr'], ' ' * ((hanging - colwidth))) | |
461 | hangindent = ' ' * (encoding.colwidth(initindent) + 1) |
|
463 | hangindent = ' ' * (encoding.colwidth(initindent) + 1) | |
462 | return ' %s\n' % (util.wrap(desc, usablewidth, |
|
464 | return ' %s\n' % (stringutil.wrap(desc, usablewidth, | |
463 |
|
|
465 | initindent=initindent, | |
464 |
|
|
466 | hangindent=hangindent)) | |
465 |
|
467 | |||
@@ -477,7 +479,7 def formatblock(block, width): | |||||
477 | defindent = indent + hang * ' ' |
|
479 | defindent = indent + hang * ' ' | |
478 | text = ' '.join(map(bytes.strip, block['lines'])) |
|
480 | text = ' '.join(map(bytes.strip, block['lines'])) | |
479 | return '%s\n%s\n' % (indent + admonition, |
|
481 | return '%s\n%s\n' % (indent + admonition, | |
480 | util.wrap(text, width=width, |
|
482 | stringutil.wrap(text, width=width, | |
481 | initindent=defindent, |
|
483 | initindent=defindent, | |
482 | hangindent=defindent)) |
|
484 | hangindent=defindent)) | |
483 | if block['type'] == 'margin': |
|
485 | if block['type'] == 'margin': | |
@@ -503,7 +505,9 def formatblock(block, width): | |||||
503 | pad = ' ' * (w - encoding.colwidth(v)) |
|
505 | pad = ' ' * (w - encoding.colwidth(v)) | |
504 | l.append(v + pad) |
|
506 | l.append(v + pad) | |
505 | l = ' '.join(l) |
|
507 | l = ' '.join(l) | |
506 |
l = util.wrap(l, width=width, |
|
508 | l = stringutil.wrap(l, width=width, | |
|
509 | initindent=indent, | |||
|
510 | hangindent=hang) | |||
507 | if not text and block['header']: |
|
511 | if not text and block['header']: | |
508 | text = l + '\n' + indent + '-' * (min(width, span)) + '\n' |
|
512 | text = l + '\n' + indent + '-' * (min(width, span)) + '\n' | |
509 | else: |
|
513 | else: | |
@@ -514,7 +518,7 def formatblock(block, width): | |||||
514 | hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip()) |
|
518 | hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip()) | |
515 | defindent = indent + hang * ' ' |
|
519 | defindent = indent + hang * ' ' | |
516 | text = ' '.join(map(bytes.strip, block['lines'][1:])) |
|
520 | text = ' '.join(map(bytes.strip, block['lines'][1:])) | |
517 | return '%s\n%s\n' % (term, util.wrap(text, width=width, |
|
521 | return '%s\n%s\n' % (term, stringutil.wrap(text, width=width, | |
518 | initindent=defindent, |
|
522 | initindent=defindent, | |
519 | hangindent=defindent)) |
|
523 | hangindent=defindent)) | |
520 | subindent = indent |
|
524 | subindent = indent | |
@@ -540,7 +544,7 def formatblock(block, width): | |||||
540 | return formatoption(block, width) |
|
544 | return formatoption(block, width) | |
541 |
|
545 | |||
542 | text = ' '.join(map(bytes.strip, block['lines'])) |
|
546 | text = ' '.join(map(bytes.strip, block['lines'])) | |
543 | return util.wrap(text, width=width, |
|
547 | return stringutil.wrap(text, width=width, | |
544 | initindent=indent, |
|
548 | initindent=indent, | |
545 | hangindent=subindent) + '\n' |
|
549 | hangindent=subindent) + '\n' | |
546 |
|
550 |
@@ -25,6 +25,9 from . import ( | |||||
25 | pycompat, |
|
25 | pycompat, | |
26 | util, |
|
26 | util, | |
27 | ) |
|
27 | ) | |
|
28 | from .utils import ( | |||
|
29 | stringutil, | |||
|
30 | ) | |||
28 |
|
31 | |||
29 | class parser(object): |
|
32 | class parser(object): | |
30 | def __init__(self, elements, methods=None): |
|
33 | def __init__(self, elements, methods=None): | |
@@ -190,14 +193,14 def buildargsdict(trees, funcname, argsp | |||||
190 |
|
193 | |||
191 | def unescapestr(s): |
|
194 | def unescapestr(s): | |
192 | try: |
|
195 | try: | |
193 | return util.unescapestr(s) |
|
196 | return stringutil.unescapestr(s) | |
194 | except ValueError as e: |
|
197 | except ValueError as e: | |
195 | # mangle Python's exception into our format |
|
198 | # mangle Python's exception into our format | |
196 | raise error.ParseError(pycompat.bytestr(e).lower()) |
|
199 | raise error.ParseError(pycompat.bytestr(e).lower()) | |
197 |
|
200 | |||
198 | def _brepr(obj): |
|
201 | def _brepr(obj): | |
199 | if isinstance(obj, bytes): |
|
202 | if isinstance(obj, bytes): | |
200 | return b"'%s'" % util.escapestr(obj) |
|
203 | return b"'%s'" % stringutil.escapestr(obj) | |
201 | return encoding.strtolocal(repr(obj)) |
|
204 | return encoding.strtolocal(repr(obj)) | |
202 |
|
205 | |||
203 | def _prettyformat(tree, leafnodes, level, lines): |
|
206 | def _prettyformat(tree, leafnodes, level, lines): |
@@ -40,7 +40,10 from . import ( | |||||
40 | util, |
|
40 | util, | |
41 | vfs as vfsmod, |
|
41 | vfs as vfsmod, | |
42 | ) |
|
42 | ) | |
43 |
from .utils import |
|
43 | from .utils import ( | |
|
44 | dateutil, | |||
|
45 | stringutil, | |||
|
46 | ) | |||
44 |
|
47 | |||
45 | diffhelpers = policy.importmod(r'diffhelpers') |
|
48 | diffhelpers = policy.importmod(r'diffhelpers') | |
46 | stringio = util.stringio |
|
49 | stringio = util.stringio | |
@@ -1461,7 +1464,7 class binhunk(object): | |||||
1461 | dec.append(util.b85decode(line[1:])[:l]) |
|
1464 | dec.append(util.b85decode(line[1:])[:l]) | |
1462 | except ValueError as e: |
|
1465 | except ValueError as e: | |
1463 | raise PatchError(_('could not decode "%s" binary patch: %s') |
|
1466 | raise PatchError(_('could not decode "%s" binary patch: %s') | |
1464 | % (self._fname, util.forcebytestr(e))) |
|
1467 | % (self._fname, stringutil.forcebytestr(e))) | |
1465 | line = getline(lr, self.hunk) |
|
1468 | line = getline(lr, self.hunk) | |
1466 | text = zlib.decompress(''.join(dec)) |
|
1469 | text = zlib.decompress(''.join(dec)) | |
1467 | if len(text) != size: |
|
1470 | if len(text) != size: |
@@ -26,6 +26,9 from . import ( | |||||
26 | obsutil, |
|
26 | obsutil, | |
27 | util, |
|
27 | util, | |
28 | ) |
|
28 | ) | |
|
29 | from .utils import ( | |||
|
30 | stringutil, | |||
|
31 | ) | |||
29 |
|
32 | |||
30 | def backupbundle(repo, bases, heads, node, suffix, compress=True, |
|
33 | def backupbundle(repo, bases, heads, node, suffix, compress=True, | |
31 | obsolescence=True): |
|
34 | obsolescence=True): | |
@@ -236,7 +239,8 def strip(ui, repo, nodelist, backup=Tru | |||||
236 | except OSError as e: |
|
239 | except OSError as e: | |
237 | if e.errno != errno.ENOENT: |
|
240 | if e.errno != errno.ENOENT: | |
238 | ui.warn(_('error removing %s: %s\n') % |
|
241 | ui.warn(_('error removing %s: %s\n') % | |
239 |
(undovfs.join(undofile), |
|
242 | (undovfs.join(undofile), | |
|
243 | stringutil.forcebytestr(e))) | |||
240 |
|
244 | |||
241 | except: # re-raises |
|
245 | except: # re-raises | |
242 | if backupfile: |
|
246 | if backupfile: |
@@ -45,6 +45,9 from . import ( | |||||
45 | templatefilters, |
|
45 | templatefilters, | |
46 | util, |
|
46 | util, | |
47 | ) |
|
47 | ) | |
|
48 | from .utils import ( | |||
|
49 | stringutil, | |||
|
50 | ) | |||
48 |
|
51 | |||
49 | parsers = policy.importmod(r'parsers') |
|
52 | parsers = policy.importmod(r'parsers') | |
50 |
|
53 | |||
@@ -2017,7 +2020,7 class revlog(object): | |||||
2017 | return _zlibdecompress(data) |
|
2020 | return _zlibdecompress(data) | |
2018 | except zlib.error as e: |
|
2021 | except zlib.error as e: | |
2019 | raise RevlogError(_('revlog decompress error: %s') % |
|
2022 | raise RevlogError(_('revlog decompress error: %s') % | |
2020 | util.forcebytestr(e)) |
|
2023 | stringutil.forcebytestr(e)) | |
2021 | # '\0' is more common than 'u' so it goes first. |
|
2024 | # '\0' is more common than 'u' so it goes first. | |
2022 | elif t == '\0': |
|
2025 | elif t == '\0': | |
2023 | return data |
|
2026 | return data |
@@ -31,7 +31,10 from . import ( | |||||
31 | stack, |
|
31 | stack, | |
32 | util, |
|
32 | util, | |
33 | ) |
|
33 | ) | |
34 |
from .utils import |
|
34 | from .utils import ( | |
|
35 | dateutil, | |||
|
36 | stringutil, | |||
|
37 | ) | |||
35 |
|
38 | |||
36 | # helpers for processing parsed tree |
|
39 | # helpers for processing parsed tree | |
37 | getsymbol = revsetlang.getsymbol |
|
40 | getsymbol = revsetlang.getsymbol | |
@@ -447,7 +450,7 def bookmark(repo, subset, x): | |||||
447 | bm = getstring(args[0], |
|
450 | bm = getstring(args[0], | |
448 | # i18n: "bookmark" is a keyword |
|
451 | # i18n: "bookmark" is a keyword | |
449 | _('the argument to bookmark must be a string')) |
|
452 | _('the argument to bookmark must be a string')) | |
450 | kind, pattern, matcher = util.stringmatcher(bm) |
|
453 | kind, pattern, matcher = stringutil.stringmatcher(bm) | |
451 | bms = set() |
|
454 | bms = set() | |
452 | if kind == 'literal': |
|
455 | if kind == 'literal': | |
453 | bmrev = repo._bookmarks.get(pattern, None) |
|
456 | bmrev = repo._bookmarks.get(pattern, None) | |
@@ -492,7 +495,7 def branch(repo, subset, x): | |||||
492 | # not a string, but another revspec, e.g. tip() |
|
495 | # not a string, but another revspec, e.g. tip() | |
493 | pass |
|
496 | pass | |
494 | else: |
|
497 | else: | |
495 | kind, pattern, matcher = util.stringmatcher(b) |
|
498 | kind, pattern, matcher = stringutil.stringmatcher(b) | |
496 | if kind == 'literal': |
|
499 | if kind == 'literal': | |
497 | # note: falls through to the revspec case if no branch with |
|
500 | # note: falls through to the revspec case if no branch with | |
498 | # this name exists and pattern kind is not specified explicitly |
|
501 | # this name exists and pattern kind is not specified explicitly | |
@@ -819,7 +822,7 def extra(repo, subset, x): | |||||
819 | # i18n: "extra" is a keyword |
|
822 | # i18n: "extra" is a keyword | |
820 | value = getstring(args['value'], _('second argument to extra must be ' |
|
823 | value = getstring(args['value'], _('second argument to extra must be ' | |
821 | 'a string')) |
|
824 | 'a string')) | |
822 | kind, value, matcher = util.stringmatcher(value) |
|
825 | kind, value, matcher = stringutil.stringmatcher(value) | |
823 |
|
826 | |||
824 | def _matchvalue(r): |
|
827 | def _matchvalue(r): | |
825 | extra = repo[r].extra() |
|
828 | extra = repo[r].extra() | |
@@ -1014,7 +1017,7 def grep(repo, subset, x): | |||||
1014 | gr = re.compile(getstring(x, _("grep requires a string"))) |
|
1017 | gr = re.compile(getstring(x, _("grep requires a string"))) | |
1015 | except re.error as e: |
|
1018 | except re.error as e: | |
1016 | raise error.ParseError( |
|
1019 | raise error.ParseError( | |
1017 | _('invalid match pattern: %s') % util.forcebytestr(e)) |
|
1020 | _('invalid match pattern: %s') % stringutil.forcebytestr(e)) | |
1018 |
|
1021 | |||
1019 | def matches(x): |
|
1022 | def matches(x): | |
1020 | c = repo[x] |
|
1023 | c = repo[x] | |
@@ -1286,7 +1289,7 def named(repo, subset, x): | |||||
1286 | ns = getstring(args[0], |
|
1289 | ns = getstring(args[0], | |
1287 | # i18n: "named" is a keyword |
|
1290 | # i18n: "named" is a keyword | |
1288 | _('the argument to named must be a string')) |
|
1291 | _('the argument to named must be a string')) | |
1289 | kind, pattern, matcher = util.stringmatcher(ns) |
|
1292 | kind, pattern, matcher = stringutil.stringmatcher(ns) | |
1290 | namespaces = set() |
|
1293 | namespaces = set() | |
1291 | if kind == 'literal': |
|
1294 | if kind == 'literal': | |
1292 | if pattern not in repo.names: |
|
1295 | if pattern not in repo.names: | |
@@ -1942,7 +1945,7 def subrepo(repo, subset, x): | |||||
1942 | m = matchmod.exact(repo.root, repo.root, ['.hgsubstate']) |
|
1945 | m = matchmod.exact(repo.root, repo.root, ['.hgsubstate']) | |
1943 |
|
1946 | |||
1944 | def submatches(names): |
|
1947 | def submatches(names): | |
1945 | k, p, m = util.stringmatcher(pat) |
|
1948 | k, p, m = stringutil.stringmatcher(pat) | |
1946 | for name in names: |
|
1949 | for name in names: | |
1947 | if m(name): |
|
1950 | if m(name): | |
1948 | yield name |
|
1951 | yield name | |
@@ -1995,8 +1998,8 def successors(repo, subset, x): | |||||
1995 | return subset & d |
|
1998 | return subset & d | |
1996 |
|
1999 | |||
1997 | def _substringmatcher(pattern, casesensitive=True): |
|
2000 | def _substringmatcher(pattern, casesensitive=True): | |
1998 |
kind, pattern, matcher = util.stringmatcher( |
|
2001 | kind, pattern, matcher = stringutil.stringmatcher( | |
1999 |
|
|
2002 | pattern, casesensitive=casesensitive) | |
2000 | if kind == 'literal': |
|
2003 | if kind == 'literal': | |
2001 | if not casesensitive: |
|
2004 | if not casesensitive: | |
2002 | pattern = encoding.lower(pattern) |
|
2005 | pattern = encoding.lower(pattern) | |
@@ -2019,7 +2022,7 def tag(repo, subset, x): | |||||
2019 | pattern = getstring(args[0], |
|
2022 | pattern = getstring(args[0], | |
2020 | # i18n: "tag" is a keyword |
|
2023 | # i18n: "tag" is a keyword | |
2021 | _('the argument to tag must be a string')) |
|
2024 | _('the argument to tag must be a string')) | |
2022 | kind, pattern, matcher = util.stringmatcher(pattern) |
|
2025 | kind, pattern, matcher = stringutil.stringmatcher(pattern) | |
2023 | if kind == 'literal': |
|
2026 | if kind == 'literal': | |
2024 | # avoid resolving all tags |
|
2027 | # avoid resolving all tags | |
2025 | tn = repo._tagscache.tags.get(pattern, None) |
|
2028 | tn = repo._tagscache.tags.get(pattern, None) |
@@ -17,6 +17,9 from . import ( | |||||
17 | pycompat, |
|
17 | pycompat, | |
18 | util, |
|
18 | util, | |
19 | ) |
|
19 | ) | |
|
20 | from .utils import ( | |||
|
21 | stringutil, | |||
|
22 | ) | |||
20 |
|
23 | |||
21 | elements = { |
|
24 | elements = { | |
22 | # token-type: binding-strength, primary, prefix, infix, suffix |
|
25 | # token-type: binding-strength, primary, prefix, infix, suffix | |
@@ -207,7 +210,7 def getinteger(x, err, default=_notset): | |||||
207 | raise error.ParseError(err) |
|
210 | raise error.ParseError(err) | |
208 |
|
211 | |||
209 | def getboolean(x, err): |
|
212 | def getboolean(x, err): | |
210 | value = util.parsebool(getsymbol(x)) |
|
213 | value = stringutil.parsebool(getsymbol(x)) | |
211 | if value is not None: |
|
214 | if value is not None: | |
212 | return value |
|
215 | return value | |
213 | raise error.ParseError(err) |
|
216 | raise error.ParseError(err) | |
@@ -565,7 +568,7 def _quote(s): | |||||
565 | >>> _quote(1) |
|
568 | >>> _quote(1) | |
566 | "'1'" |
|
569 | "'1'" | |
567 | """ |
|
570 | """ | |
568 | return "'%s'" % util.escapestr(pycompat.bytestr(s)) |
|
571 | return "'%s'" % stringutil.escapestr(pycompat.bytestr(s)) | |
569 |
|
572 | |||
570 | def _formatargtype(c, arg): |
|
573 | def _formatargtype(c, arg): | |
571 | if c == 'd': |
|
574 | if c == 'd': |
@@ -41,6 +41,10 from . import ( | |||||
41 | vfs, |
|
41 | vfs, | |
42 | ) |
|
42 | ) | |
43 |
|
43 | |||
|
44 | from .utils import ( | |||
|
45 | stringutil, | |||
|
46 | ) | |||
|
47 | ||||
44 | if pycompat.iswindows: |
|
48 | if pycompat.iswindows: | |
45 | from . import scmwindows as scmplatform |
|
49 | from . import scmwindows as scmplatform | |
46 | else: |
|
50 | else: | |
@@ -163,12 +167,12 def callcatch(ui, func): | |||||
163 | else: |
|
167 | else: | |
164 | reason = _('lock held by %r') % inst.locker |
|
168 | reason = _('lock held by %r') % inst.locker | |
165 | ui.warn(_("abort: %s: %s\n") |
|
169 | ui.warn(_("abort: %s: %s\n") | |
166 | % (inst.desc or util.forcebytestr(inst.filename), reason)) |
|
170 | % (inst.desc or stringutil.forcebytestr(inst.filename), reason)) | |
167 | if not inst.locker: |
|
171 | if not inst.locker: | |
168 | ui.warn(_("(lock might be very busy)\n")) |
|
172 | ui.warn(_("(lock might be very busy)\n")) | |
169 | except error.LockUnavailable as inst: |
|
173 | except error.LockUnavailable as inst: | |
170 | ui.warn(_("abort: could not lock %s: %s\n") % |
|
174 | ui.warn(_("abort: could not lock %s: %s\n") % | |
171 | (inst.desc or util.forcebytestr(inst.filename), |
|
175 | (inst.desc or stringutil.forcebytestr(inst.filename), | |
172 | encoding.strtolocal(inst.strerror))) |
|
176 | encoding.strtolocal(inst.strerror))) | |
173 | except error.OutOfBandError as inst: |
|
177 | except error.OutOfBandError as inst: | |
174 | if inst.args: |
|
178 | if inst.args: | |
@@ -194,7 +198,7 def callcatch(ui, func): | |||||
194 | elif not msg: |
|
198 | elif not msg: | |
195 | ui.warn(_(" empty string\n")) |
|
199 | ui.warn(_(" empty string\n")) | |
196 | else: |
|
200 | else: | |
197 | ui.warn("\n%r\n" % util.ellipsis(msg)) |
|
201 | ui.warn("\n%r\n" % stringutil.ellipsis(msg)) | |
198 | except error.CensoredNodeError as inst: |
|
202 | except error.CensoredNodeError as inst: | |
199 | ui.warn(_("abort: file censored %s!\n") % inst) |
|
203 | ui.warn(_("abort: file censored %s!\n") % inst) | |
200 | except error.RevlogError as inst: |
|
204 | except error.RevlogError as inst: | |
@@ -211,15 +215,15 def callcatch(ui, func): | |||||
211 | if inst.hint: |
|
215 | if inst.hint: | |
212 | ui.warn(_("(%s)\n") % inst.hint) |
|
216 | ui.warn(_("(%s)\n") % inst.hint) | |
213 | except ImportError as inst: |
|
217 | except ImportError as inst: | |
214 | ui.warn(_("abort: %s!\n") % util.forcebytestr(inst)) |
|
218 | ui.warn(_("abort: %s!\n") % stringutil.forcebytestr(inst)) | |
215 | m = util.forcebytestr(inst).split()[-1] |
|
219 | m = stringutil.forcebytestr(inst).split()[-1] | |
216 | if m in "mpatch bdiff".split(): |
|
220 | if m in "mpatch bdiff".split(): | |
217 | ui.warn(_("(did you forget to compile extensions?)\n")) |
|
221 | ui.warn(_("(did you forget to compile extensions?)\n")) | |
218 | elif m in "zlib".split(): |
|
222 | elif m in "zlib".split(): | |
219 | ui.warn(_("(is your Python install correct?)\n")) |
|
223 | ui.warn(_("(is your Python install correct?)\n")) | |
220 | except IOError as inst: |
|
224 | except IOError as inst: | |
221 | if util.safehasattr(inst, "code"): |
|
225 | if util.safehasattr(inst, "code"): | |
222 | ui.warn(_("abort: %s\n") % util.forcebytestr(inst)) |
|
226 | ui.warn(_("abort: %s\n") % stringutil.forcebytestr(inst)) | |
223 | elif util.safehasattr(inst, "reason"): |
|
227 | elif util.safehasattr(inst, "reason"): | |
224 | try: # usually it is in the form (errno, strerror) |
|
228 | try: # usually it is in the form (errno, strerror) | |
225 | reason = inst.reason.args[1] |
|
229 | reason = inst.reason.args[1] | |
@@ -237,7 +241,7 def callcatch(ui, func): | |||||
237 | if getattr(inst, "filename", None): |
|
241 | if getattr(inst, "filename", None): | |
238 | ui.warn(_("abort: %s: %s\n") % ( |
|
242 | ui.warn(_("abort: %s: %s\n") % ( | |
239 | encoding.strtolocal(inst.strerror), |
|
243 | encoding.strtolocal(inst.strerror), | |
240 | util.forcebytestr(inst.filename))) |
|
244 | stringutil.forcebytestr(inst.filename))) | |
241 | else: |
|
245 | else: | |
242 | ui.warn(_("abort: %s\n") % encoding.strtolocal(inst.strerror)) |
|
246 | ui.warn(_("abort: %s\n") % encoding.strtolocal(inst.strerror)) | |
243 | else: |
|
247 | else: | |
@@ -246,7 +250,7 def callcatch(ui, func): | |||||
246 | if getattr(inst, "filename", None) is not None: |
|
250 | if getattr(inst, "filename", None) is not None: | |
247 | ui.warn(_("abort: %s: '%s'\n") % ( |
|
251 | ui.warn(_("abort: %s: '%s'\n") % ( | |
248 | encoding.strtolocal(inst.strerror), |
|
252 | encoding.strtolocal(inst.strerror), | |
249 | util.forcebytestr(inst.filename))) |
|
253 | stringutil.forcebytestr(inst.filename))) | |
250 | else: |
|
254 | else: | |
251 | ui.warn(_("abort: %s\n") % encoding.strtolocal(inst.strerror)) |
|
255 | ui.warn(_("abort: %s\n") % encoding.strtolocal(inst.strerror)) | |
252 | except MemoryError: |
|
256 | except MemoryError: | |
@@ -256,7 +260,7 def callcatch(ui, func): | |||||
256 | # Just in case catch this and and pass exit code to caller. |
|
260 | # Just in case catch this and and pass exit code to caller. | |
257 | return inst.code |
|
261 | return inst.code | |
258 | except socket.error as inst: |
|
262 | except socket.error as inst: | |
259 | ui.warn(_("abort: %s\n") % util.forcebytestr(inst.args[-1])) |
|
263 | ui.warn(_("abort: %s\n") % stringutil.forcebytestr(inst.args[-1])) | |
260 |
|
264 | |||
261 | return -1 |
|
265 | return -1 | |
262 |
|
266 | |||
@@ -299,7 +303,7 def checkportabilityalert(ui): | |||||
299 | non-portable filenames''' |
|
303 | non-portable filenames''' | |
300 | val = ui.config('ui', 'portablefilenames') |
|
304 | val = ui.config('ui', 'portablefilenames') | |
301 | lval = val.lower() |
|
305 | lval = val.lower() | |
302 | bval = util.parsebool(val) |
|
306 | bval = stringutil.parsebool(val) | |
303 | abort = pycompat.iswindows or lval == 'abort' |
|
307 | abort = pycompat.iswindows or lval == 'abort' | |
304 | warn = bval or lval == 'warn' |
|
308 | warn = bval or lval == 'warn' | |
305 | if bval is None and not (warn or abort or lval == 'ignore'): |
|
309 | if bval is None and not (warn or abort or lval == 'ignore'): |
@@ -23,7 +23,9 from . import ( | |||||
23 | error, |
|
23 | error, | |
24 | mdiff, |
|
24 | mdiff, | |
25 | pycompat, |
|
25 | pycompat, | |
26 | util, |
|
26 | ) | |
|
27 | from .utils import ( | |||
|
28 | stringutil, | |||
27 | ) |
|
29 | ) | |
28 |
|
30 | |||
29 | class CantReprocessAndShowBase(Exception): |
|
31 | class CantReprocessAndShowBase(Exception): | |
@@ -397,7 +399,7 class Merge3Text(object): | |||||
397 | def _verifytext(text, path, ui, opts): |
|
399 | def _verifytext(text, path, ui, opts): | |
398 | """verifies that text is non-binary (unless opts[text] is passed, |
|
400 | """verifies that text is non-binary (unless opts[text] is passed, | |
399 | then we just warn)""" |
|
401 | then we just warn)""" | |
400 | if util.binary(text): |
|
402 | if stringutil.binary(text): | |
401 | msg = _("%s looks like a binary file.") % path |
|
403 | msg = _("%s looks like a binary file.") % path | |
402 | if not opts.get('quiet'): |
|
404 | if not opts.get('quiet'): | |
403 | ui.warn(_('warning: %s\n') % msg) |
|
405 | ui.warn(_('warning: %s\n') % msg) |
@@ -21,6 +21,9 from . import ( | |||||
21 | pycompat, |
|
21 | pycompat, | |
22 | util, |
|
22 | util, | |
23 | ) |
|
23 | ) | |
|
24 | from .utils import ( | |||
|
25 | stringutil, | |||
|
26 | ) | |||
24 |
|
27 | |||
25 | # Python 2.7.9+ overhauled the built-in SSL/TLS features of Python. It added |
|
28 | # Python 2.7.9+ overhauled the built-in SSL/TLS features of Python. It added | |
26 | # support for TLS 1.1, TLS 1.2, SNI, system CA stores, etc. These features are |
|
29 | # support for TLS 1.1, TLS 1.2, SNI, system CA stores, etc. These features are | |
@@ -374,7 +377,8 def wrapsocket(sock, keyfile, certfile, | |||||
374 | sslcontext.set_ciphers(pycompat.sysstr(settings['ciphers'])) |
|
377 | sslcontext.set_ciphers(pycompat.sysstr(settings['ciphers'])) | |
375 | except ssl.SSLError as e: |
|
378 | except ssl.SSLError as e: | |
376 | raise error.Abort( |
|
379 | raise error.Abort( | |
377 |
_('could not set ciphers: %s') |
|
380 | _('could not set ciphers: %s') | |
|
381 | % stringutil.forcebytestr(e.args[0]), | |||
378 | hint=_('change cipher string (%s) in config') % |
|
382 | hint=_('change cipher string (%s) in config') % | |
379 | settings['ciphers']) |
|
383 | settings['ciphers']) | |
380 |
|
384 | |||
@@ -393,7 +397,7 def wrapsocket(sock, keyfile, certfile, | |||||
393 | else: |
|
397 | else: | |
394 | msg = e.args[1] |
|
398 | msg = e.args[1] | |
395 | raise error.Abort(_('error loading CA file %s: %s') % ( |
|
399 | raise error.Abort(_('error loading CA file %s: %s') % ( | |
396 | settings['cafile'], util.forcebytestr(msg)), |
|
400 | settings['cafile'], stringutil.forcebytestr(msg)), | |
397 | hint=_('file is empty or malformed?')) |
|
401 | hint=_('file is empty or malformed?')) | |
398 | caloaded = True |
|
402 | caloaded = True | |
399 | elif settings['allowloaddefaultcerts']: |
|
403 | elif settings['allowloaddefaultcerts']: | |
@@ -642,7 +646,7 def _verifycert(cert, hostname): | |||||
642 | if _dnsnamematch(value, hostname): |
|
646 | if _dnsnamematch(value, hostname): | |
643 | return |
|
647 | return | |
644 | except wildcarderror as e: |
|
648 | except wildcarderror as e: | |
645 | return util.forcebytestr(e.args[0]) |
|
649 | return stringutil.forcebytestr(e.args[0]) | |
646 |
|
650 | |||
647 | dnsnames.append(value) |
|
651 | dnsnames.append(value) | |
648 |
|
652 | |||
@@ -663,7 +667,7 def _verifycert(cert, hostname): | |||||
663 | if _dnsnamematch(value, hostname): |
|
667 | if _dnsnamematch(value, hostname): | |
664 | return |
|
668 | return | |
665 | except wildcarderror as e: |
|
669 | except wildcarderror as e: | |
666 | return util.forcebytestr(e.args[0]) |
|
670 | return stringutil.forcebytestr(e.args[0]) | |
667 |
|
671 | |||
668 | dnsnames.append(value) |
|
672 | dnsnames.append(value) | |
669 |
|
673 |
@@ -36,7 +36,10 from . import ( | |||||
36 | util, |
|
36 | util, | |
37 | vfs as vfsmod, |
|
37 | vfs as vfsmod, | |
38 | ) |
|
38 | ) | |
39 |
from .utils import |
|
39 | from .utils import ( | |
|
40 | dateutil, | |||
|
41 | stringutil, | |||
|
42 | ) | |||
40 |
|
43 | |||
41 | hg = None |
|
44 | hg = None | |
42 | reporelpath = subrepoutil.reporelpath |
|
45 | reporelpath = subrepoutil.reporelpath | |
@@ -74,7 +77,7 def annotatesubrepoerror(func): | |||||
74 | raise ex |
|
77 | raise ex | |
75 | except error.Abort as ex: |
|
78 | except error.Abort as ex: | |
76 | subrepo = subrelpath(self) |
|
79 | subrepo = subrelpath(self) | |
77 | errormsg = (util.forcebytestr(ex) + ' ' |
|
80 | errormsg = (stringutil.forcebytestr(ex) + ' ' | |
78 | + _('(in subrepository "%s")') % subrepo) |
|
81 | + _('(in subrepository "%s")') % subrepo) | |
79 | # avoid handling this exception by raising a SubrepoAbort exception |
|
82 | # avoid handling this exception by raising a SubrepoAbort exception | |
80 | raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo, |
|
83 | raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo, |
@@ -21,6 +21,9 from . import ( | |||||
21 | phases, |
|
21 | phases, | |
22 | util, |
|
22 | util, | |
23 | ) |
|
23 | ) | |
|
24 | from .utils import ( | |||
|
25 | stringutil, | |||
|
26 | ) | |||
24 |
|
27 | |||
25 | nullstate = ('', '', 'empty') |
|
28 | nullstate = ('', '', 'empty') | |
26 |
|
29 | |||
@@ -74,7 +77,7 def state(ctx, ui): | |||||
74 | for pattern, repl in p.items('subpaths'): |
|
77 | for pattern, repl in p.items('subpaths'): | |
75 | # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub |
|
78 | # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub | |
76 | # does a string decode. |
|
79 | # does a string decode. | |
77 | repl = util.escapestr(repl) |
|
80 | repl = stringutil.escapestr(repl) | |
78 | # However, we still want to allow back references to go |
|
81 | # However, we still want to allow back references to go | |
79 | # through unharmed, so we turn r'\\1' into r'\1'. Again, |
|
82 | # through unharmed, so we turn r'\\1' into r'\1'. Again, | |
80 | # extra escapes are needed because re.sub string decodes. |
|
83 | # extra escapes are needed because re.sub string decodes. |
@@ -28,6 +28,9 from . import ( | |||||
28 | scmutil, |
|
28 | scmutil, | |
29 | util, |
|
29 | util, | |
30 | ) |
|
30 | ) | |
|
31 | from .utils import ( | |||
|
32 | stringutil, | |||
|
33 | ) | |||
31 |
|
34 | |||
32 | # Tags computation can be expensive and caches exist to make it fast in |
|
35 | # Tags computation can be expensive and caches exist to make it fast in | |
33 | # the common case. |
|
36 | # the common case. | |
@@ -783,6 +786,6 class hgtagsfnodescache(object): | |||||
783 | except (IOError, OSError) as inst: |
|
786 | except (IOError, OSError) as inst: | |
784 | repo.ui.log('tagscache', |
|
787 | repo.ui.log('tagscache', | |
785 | "couldn't write cache/%s: %s\n" % ( |
|
788 | "couldn't write cache/%s: %s\n" % ( | |
786 | _fnodescachefile, util.forcebytestr(inst))) |
|
789 | _fnodescachefile, stringutil.forcebytestr(inst))) | |
787 | finally: |
|
790 | finally: | |
788 | lock.release() |
|
791 | lock.release() |
@@ -21,7 +21,10 from . import ( | |||||
21 | url, |
|
21 | url, | |
22 | util, |
|
22 | util, | |
23 | ) |
|
23 | ) | |
24 |
from .utils import |
|
24 | from .utils import ( | |
|
25 | dateutil, | |||
|
26 | stringutil, | |||
|
27 | ) | |||
25 |
|
28 | |||
26 | urlerr = util.urlerr |
|
29 | urlerr = util.urlerr | |
27 | urlreq = util.urlreq |
|
30 | urlreq = util.urlreq | |
@@ -128,7 +131,7 def email(text): | |||||
128 | address. Example: ``User <user@example.com>`` becomes |
|
131 | address. Example: ``User <user@example.com>`` becomes | |
129 | ``user@example.com``. |
|
132 | ``user@example.com``. | |
130 | """ |
|
133 | """ | |
131 | return util.email(text) |
|
134 | return stringutil.email(text) | |
132 |
|
135 | |||
133 | @templatefilter('escape') |
|
136 | @templatefilter('escape') | |
134 | def escape(text): |
|
137 | def escape(text): | |
@@ -162,7 +165,8 def fill(text, width, initindent='', han | |||||
162 | yield text[start:m.start(0)], m.group(1) |
|
165 | yield text[start:m.start(0)], m.group(1) | |
163 | start = m.end(1) |
|
166 | start = m.end(1) | |
164 |
|
167 | |||
165 |
return "".join([util.wrap(space_re.sub(' ', |
|
168 | return "".join([stringutil.wrap(space_re.sub(' ', | |
|
169 | stringutil.wrap(para, width)), | |||
166 | width, initindent, hangindent) + rest |
|
170 | width, initindent, hangindent) + rest | |
167 | for para, rest in findparas()]) |
|
171 | for para, rest in findparas()]) | |
168 |
|
172 | |||
@@ -369,7 +373,7 def splitlines(text): | |||||
369 |
|
373 | |||
370 | @templatefilter('stringescape') |
|
374 | @templatefilter('stringescape') | |
371 | def stringescape(text): |
|
375 | def stringescape(text): | |
372 | return util.escapestr(text) |
|
376 | return stringutil.escapestr(text) | |
373 |
|
377 | |||
374 | @templatefilter('stringify') |
|
378 | @templatefilter('stringify') | |
375 | def stringify(thing): |
|
379 | def stringify(thing): | |
@@ -412,12 +416,12 def urlescape(text): | |||||
412 | def userfilter(text): |
|
416 | def userfilter(text): | |
413 | """Any text. Returns a short representation of a user name or email |
|
417 | """Any text. Returns a short representation of a user name or email | |
414 | address.""" |
|
418 | address.""" | |
415 | return util.shortuser(text) |
|
419 | return stringutil.shortuser(text) | |
416 |
|
420 | |||
417 | @templatefilter('emailuser') |
|
421 | @templatefilter('emailuser') | |
418 | def emailuser(text): |
|
422 | def emailuser(text): | |
419 | """Any text. Returns the user portion of an email address.""" |
|
423 | """Any text. Returns the user portion of an email address.""" | |
420 | return util.emailuser(text) |
|
424 | return stringutil.emailuser(text) | |
421 |
|
425 | |||
422 | @templatefilter('utf8') |
|
426 | @templatefilter('utf8') | |
423 | def utf8(text): |
|
427 | def utf8(text): |
@@ -26,6 +26,9 from . import ( | |||||
26 | templateutil, |
|
26 | templateutil, | |
27 | util, |
|
27 | util, | |
28 | ) |
|
28 | ) | |
|
29 | from .utils import ( | |||
|
30 | stringutil, | |||
|
31 | ) | |||
29 |
|
32 | |||
30 | _hybrid = templateutil.hybrid |
|
33 | _hybrid = templateutil.hybrid | |
31 | _mappable = templateutil.mappable |
|
34 | _mappable = templateutil.mappable | |
@@ -72,7 +75,7 def getlatesttags(context, mapping, patt | |||||
72 | cachename = 'latesttags' |
|
75 | cachename = 'latesttags' | |
73 | if pattern is not None: |
|
76 | if pattern is not None: | |
74 | cachename += '-' + pattern |
|
77 | cachename += '-' + pattern | |
75 | match = util.stringmatcher(pattern)[2] |
|
78 | match = stringutil.stringmatcher(pattern)[2] | |
76 | else: |
|
79 | else: | |
77 | match = util.always |
|
80 | match = util.always | |
78 |
|
81 | |||
@@ -307,7 +310,7 def showextras(context, mapping): | |||||
307 | c = [makemap(k) for k in extras] |
|
310 | c = [makemap(k) for k in extras] | |
308 | f = _showcompatlist(context, mapping, 'extra', c, plural='extras') |
|
311 | f = _showcompatlist(context, mapping, 'extra', c, plural='extras') | |
309 | return _hybrid(f, extras, makemap, |
|
312 | return _hybrid(f, extras, makemap, | |
310 | lambda k: '%s=%s' % (k, util.escapestr(extras[k]))) |
|
313 | lambda k: '%s=%s' % (k, stringutil.escapestr(extras[k]))) | |
311 |
|
314 | |||
312 | def _showfilesbystat(context, mapping, name, index): |
|
315 | def _showfilesbystat(context, mapping, name, index): | |
313 | repo = context.resource(mapping, 'repo') |
|
316 | repo = context.resource(mapping, 'repo') |
@@ -63,6 +63,9 from . import ( | |||||
63 | templateutil, |
|
63 | templateutil, | |
64 | util, |
|
64 | util, | |
65 | ) |
|
65 | ) | |
|
66 | from .utils import ( | |||
|
67 | stringutil, | |||
|
68 | ) | |||
66 |
|
69 | |||
67 | # template parsing |
|
70 | # template parsing | |
68 |
|
71 | |||
@@ -811,7 +814,8 class templater(object): | |||||
811 | _('"%s" not in template map') % inst.args[0]) |
|
814 | _('"%s" not in template map') % inst.args[0]) | |
812 | except IOError as inst: |
|
815 | except IOError as inst: | |
813 | reason = (_('template file %s: %s') |
|
816 | reason = (_('template file %s: %s') | |
814 |
% (self.map[t][1], |
|
817 | % (self.map[t][1], | |
|
818 | stringutil.forcebytestr(inst.args[1]))) | |||
815 | raise IOError(inst.args[0], encoding.strfromlocal(reason)) |
|
819 | raise IOError(inst.args[0], encoding.strfromlocal(reason)) | |
816 | return self.cache[t] |
|
820 | return self.cache[t] | |
817 |
|
821 |
@@ -15,6 +15,9 from . import ( | |||||
15 | pycompat, |
|
15 | pycompat, | |
16 | util, |
|
16 | util, | |
17 | ) |
|
17 | ) | |
|
18 | from .utils import ( | |||
|
19 | stringutil, | |||
|
20 | ) | |||
18 |
|
21 | |||
19 | class ResourceUnavailable(error.Abort): |
|
22 | class ResourceUnavailable(error.Abort): | |
20 | pass |
|
23 | pass | |
@@ -281,7 +284,7 def evalboolean(context, mapping, arg): | |||||
281 | thing = func(context, mapping, data, default=None) |
|
284 | thing = func(context, mapping, data, default=None) | |
282 | if thing is None: |
|
285 | if thing is None: | |
283 | # not a template keyword, takes as a boolean literal |
|
286 | # not a template keyword, takes as a boolean literal | |
284 | thing = util.parsebool(data) |
|
287 | thing = stringutil.parsebool(data) | |
285 | else: |
|
288 | else: | |
286 | thing = func(context, mapping, data) |
|
289 | thing = func(context, mapping, data) | |
287 | thing = unwrapvalue(thing) |
|
290 | thing = unwrapvalue(thing) |
@@ -37,7 +37,10 from . import ( | |||||
37 | scmutil, |
|
37 | scmutil, | |
38 | util, |
|
38 | util, | |
39 | ) |
|
39 | ) | |
40 |
from .utils import |
|
40 | from .utils import ( | |
|
41 | dateutil, | |||
|
42 | stringutil, | |||
|
43 | ) | |||
41 |
|
44 | |||
42 | urlreq = util.urlreq |
|
45 | urlreq = util.urlreq | |
43 |
|
46 | |||
@@ -371,7 +374,7 class ui(object): | |||||
371 | except error.ConfigError as inst: |
|
374 | except error.ConfigError as inst: | |
372 | if trusted: |
|
375 | if trusted: | |
373 | raise |
|
376 | raise | |
374 | self.warn(_("ignored: %s\n") % util.forcebytestr(inst)) |
|
377 | self.warn(_("ignored: %s\n") % stringutil.forcebytestr(inst)) | |
375 |
|
378 | |||
376 | if self.plain(): |
|
379 | if self.plain(): | |
377 | for k in ('debug', 'fallbackencoding', 'quiet', 'slash', |
|
380 | for k in ('debug', 'fallbackencoding', 'quiet', 'slash', | |
@@ -591,7 +594,7 class ui(object): | |||||
591 | return default |
|
594 | return default | |
592 | if isinstance(v, bool): |
|
595 | if isinstance(v, bool): | |
593 | return v |
|
596 | return v | |
594 | b = util.parsebool(v) |
|
597 | b = stringutil.parsebool(v) | |
595 | if b is None: |
|
598 | if b is None: | |
596 | raise error.ConfigError(_("%s.%s is not a boolean ('%s')") |
|
599 | raise error.ConfigError(_("%s.%s is not a boolean ('%s')") | |
597 | % (section, name, v)) |
|
600 | % (section, name, v)) | |
@@ -821,7 +824,7 class ui(object): | |||||
821 | def shortuser(self, user): |
|
824 | def shortuser(self, user): | |
822 | """Return a short representation of a user name or email address.""" |
|
825 | """Return a short representation of a user name or email address.""" | |
823 | if not self.verbose: |
|
826 | if not self.verbose: | |
824 | user = util.shortuser(user) |
|
827 | user = stringutil.shortuser(user) | |
825 | return user |
|
828 | return user | |
826 |
|
829 | |||
827 | def expandpath(self, loc, default=None): |
|
830 | def expandpath(self, loc, default=None): |
@@ -24,6 +24,9 from . import ( | |||||
24 | urllibcompat, |
|
24 | urllibcompat, | |
25 | util, |
|
25 | util, | |
26 | ) |
|
26 | ) | |
|
27 | from .utils import ( | |||
|
28 | stringutil, | |||
|
29 | ) | |||
27 |
|
30 | |||
28 | httplib = util.httplib |
|
31 | httplib = util.httplib | |
29 | stringio = util.stringio |
|
32 | stringio = util.stringio | |
@@ -477,7 +480,7 class cookiehandler(urlreq.basehandler): | |||||
477 | self.cookiejar = cookiejar |
|
480 | self.cookiejar = cookiejar | |
478 | except util.cookielib.LoadError as e: |
|
481 | except util.cookielib.LoadError as e: | |
479 | ui.warn(_('(error loading cookie file %s: %s; continuing without ' |
|
482 | ui.warn(_('(error loading cookie file %s: %s; continuing without ' | |
480 | 'cookies)\n') % (cookiefile, util.forcebytestr(e))) |
|
483 | 'cookies)\n') % (cookiefile, stringutil.forcebytestr(e))) | |
481 |
|
484 | |||
482 | def http_request(self, request): |
|
485 | def http_request(self, request): | |
483 | if self.cookiejar: |
|
486 | if self.cookiejar: |
@@ -820,9 +820,10 class baseproxyobserver(object): | |||||
820 | # Simple case writes all data on a single line. |
|
820 | # Simple case writes all data on a single line. | |
821 | if b'\n' not in data: |
|
821 | if b'\n' not in data: | |
822 | if self.logdataapis: |
|
822 | if self.logdataapis: | |
823 | self.fh.write(': %s\n' % escapedata(data)) |
|
823 | self.fh.write(': %s\n' % stringutil.escapedata(data)) | |
824 | else: |
|
824 | else: | |
825 |
self.fh.write('%s> %s\n' |
|
825 | self.fh.write('%s> %s\n' | |
|
826 | % (self.name, stringutil.escapedata(data))) | |||
826 | self.fh.flush() |
|
827 | self.fh.flush() | |
827 | return |
|
828 | return | |
828 |
|
829 | |||
@@ -832,7 +833,8 class baseproxyobserver(object): | |||||
832 |
|
833 | |||
833 | lines = data.splitlines(True) |
|
834 | lines = data.splitlines(True) | |
834 | for line in lines: |
|
835 | for line in lines: | |
835 |
self.fh.write('%s> %s\n' |
|
836 | self.fh.write('%s> %s\n' | |
|
837 | % (self.name, stringutil.escapedata(line))) | |||
836 | self.fh.flush() |
|
838 | self.fh.flush() | |
837 |
|
839 | |||
838 | class fileobjectobserver(baseproxyobserver): |
|
840 | class fileobjectobserver(baseproxyobserver): | |
@@ -1915,7 +1917,7 def checkwinfilename(path): | |||||
1915 | "on Windows") % c |
|
1917 | "on Windows") % c | |
1916 | if ord(c) <= 31: |
|
1918 | if ord(c) <= 31: | |
1917 | return _("filename contains '%s', which is invalid " |
|
1919 | return _("filename contains '%s', which is invalid " | |
1918 | "on Windows") % escapestr(c) |
|
1920 | "on Windows") % stringutil.escapestr(c) | |
1919 | base = n.split('.')[0] |
|
1921 | base = n.split('.')[0] | |
1920 | if base and base.lower() in _winreservednames: |
|
1922 | if base and base.lower() in _winreservednames: | |
1921 | return _("filename contains '%s', which is reserved " |
|
1923 | return _("filename contains '%s', which is reserved " | |
@@ -3679,7 +3681,7 class _zlibengine(compressionengine): | |||||
3679 | return zlib.decompress(data) |
|
3681 | return zlib.decompress(data) | |
3680 | except zlib.error as e: |
|
3682 | except zlib.error as e: | |
3681 | raise error.RevlogError(_('revlog decompress error: %s') % |
|
3683 | raise error.RevlogError(_('revlog decompress error: %s') % | |
3682 | forcebytestr(e)) |
|
3684 | stringutil.forcebytestr(e)) | |
3683 |
|
3685 | |||
3684 | def revlogcompressor(self, opts=None): |
|
3686 | def revlogcompressor(self, opts=None): | |
3685 | return self.zlibrevlogcompressor() |
|
3687 | return self.zlibrevlogcompressor() | |
@@ -3905,7 +3907,7 class _zstdengine(compressionengine): | |||||
3905 | return ''.join(chunks) |
|
3907 | return ''.join(chunks) | |
3906 | except Exception as e: |
|
3908 | except Exception as e: | |
3907 | raise error.RevlogError(_('revlog decompress error: %s') % |
|
3909 | raise error.RevlogError(_('revlog decompress error: %s') % | |
3908 | forcebytestr(e)) |
|
3910 | stringutil.forcebytestr(e)) | |
3909 |
|
3911 | |||
3910 | def revlogcompressor(self, opts=None): |
|
3912 | def revlogcompressor(self, opts=None): | |
3911 | opts = opts or {} |
|
3913 | opts = opts or {} |
@@ -34,6 +34,10 from . import ( | |||||
34 | wireprototypes, |
|
34 | wireprototypes, | |
35 | ) |
|
35 | ) | |
36 |
|
36 | |||
|
37 | from .utils import ( | |||
|
38 | stringutil, | |||
|
39 | ) | |||
|
40 | ||||
37 | urlerr = util.urlerr |
|
41 | urlerr = util.urlerr | |
38 | urlreq = util.urlreq |
|
42 | urlreq = util.urlreq | |
39 |
|
43 | |||
@@ -994,7 +998,7 def lookup(repo, proto, key): | |||||
994 | r = c.hex() |
|
998 | r = c.hex() | |
995 | success = 1 |
|
999 | success = 1 | |
996 | except Exception as inst: |
|
1000 | except Exception as inst: | |
997 | r = util.forcebytestr(inst) |
|
1001 | r = stringutil.forcebytestr(inst) | |
998 | success = 0 |
|
1002 | success = 0 | |
999 | return bytesresponse('%d %s\n' % (success, r)) |
|
1003 | return bytesresponse('%d %s\n' % (success, r)) | |
1000 |
|
1004 | |||
@@ -1007,7 +1011,7 def known(repo, proto, nodes, others): | |||||
1007 | def pushkey(repo, proto, namespace, key, old, new): |
|
1011 | def pushkey(repo, proto, namespace, key, old, new): | |
1008 | # compatibility with pre-1.8 clients which were accidentally |
|
1012 | # compatibility with pre-1.8 clients which were accidentally | |
1009 | # sending raw binary nodes rather than utf-8-encoded hex |
|
1013 | # sending raw binary nodes rather than utf-8-encoded hex | |
1010 | if len(new) == 20 and util.escapestr(new) != new: |
|
1014 | if len(new) == 20 and stringutil.escapestr(new) != new: | |
1011 | # looks like it could be a binary node |
|
1015 | # looks like it could be a binary node | |
1012 | try: |
|
1016 | try: | |
1013 | new.decode('utf-8') |
|
1017 | new.decode('utf-8') | |
@@ -1123,7 +1127,7 def unbundle(repo, proto, heads): | |||||
1123 | if exc.params: |
|
1127 | if exc.params: | |
1124 | errpart.addparam('params', '\0'.join(exc.params)) |
|
1128 | errpart.addparam('params', '\0'.join(exc.params)) | |
1125 | except error.Abort as exc: |
|
1129 | except error.Abort as exc: | |
1126 | manargs = [('message', util.forcebytestr(exc))] |
|
1130 | manargs = [('message', stringutil.forcebytestr(exc))] | |
1127 | advargs = [] |
|
1131 | advargs = [] | |
1128 | if exc.hint is not None: |
|
1132 | if exc.hint is not None: | |
1129 | advargs.append(('hint', exc.hint)) |
|
1133 | advargs.append(('hint', exc.hint)) | |
@@ -1131,5 +1135,5 def unbundle(repo, proto, heads): | |||||
1131 | manargs, advargs)) |
|
1135 | manargs, advargs)) | |
1132 | except error.PushRaced as exc: |
|
1136 | except error.PushRaced as exc: | |
1133 | bundler.newpart('error:pushraced', |
|
1137 | bundler.newpart('error:pushraced', | |
1134 | [('message', util.forcebytestr(exc))]) |
|
1138 | [('message', stringutil.forcebytestr(exc))]) | |
1135 | return streamres_legacy(gen=bundler.getchunks()) |
|
1139 | return streamres_legacy(gen=bundler.getchunks()) |
@@ -21,6 +21,9 from . import ( | |||||
21 | error, |
|
21 | error, | |
22 | util, |
|
22 | util, | |
23 | ) |
|
23 | ) | |
|
24 | from .utils import ( | |||
|
25 | stringutil, | |||
|
26 | ) | |||
24 |
|
27 | |||
25 | FRAME_HEADER_SIZE = 6 |
|
28 | FRAME_HEADER_SIZE = 6 | |
26 | DEFAULT_MAX_FRAME_SIZE = 32768 |
|
29 | DEFAULT_MAX_FRAME_SIZE = 32768 | |
@@ -164,7 +167,7 def makeframefromhumanstring(s): | |||||
164 | else: |
|
167 | else: | |
165 | finalflags |= int(flag) |
|
168 | finalflags |= int(flag) | |
166 |
|
169 | |||
167 | payload = util.unescapestr(payload) |
|
170 | payload = stringutil.unescapestr(payload) | |
168 |
|
171 | |||
169 | return makeframe(requestid=requestid, typeid=frametype, |
|
172 | return makeframe(requestid=requestid, typeid=frametype, | |
170 | flags=finalflags, payload=payload) |
|
173 | flags=finalflags, payload=payload) |
@@ -22,6 +22,10 from mercurial import ( | |||||
22 | util, |
|
22 | util, | |
23 | ) |
|
23 | ) | |
24 |
|
24 | |||
|
25 | from mercurial.utils import ( | |||
|
26 | stringutil, | |||
|
27 | ) | |||
|
28 | ||||
25 | TestCase = unittest.TestCase |
|
29 | TestCase = unittest.TestCase | |
26 | # bzr compatible interface, for the tests |
|
30 | # bzr compatible interface, for the tests | |
27 | class Merge3(simplemerge.Merge3Text): |
|
31 | class Merge3(simplemerge.Merge3Text): | |
@@ -34,7 +38,8 class Merge3(simplemerge.Merge3Text): | |||||
34 | basetext = '\n'.join([i.strip('\n') for i in base] + ['']) |
|
38 | basetext = '\n'.join([i.strip('\n') for i in base] + ['']) | |
35 | atext = '\n'.join([i.strip('\n') for i in a] + ['']) |
|
39 | atext = '\n'.join([i.strip('\n') for i in a] + ['']) | |
36 | btext = '\n'.join([i.strip('\n') for i in b] + ['']) |
|
40 | btext = '\n'.join([i.strip('\n') for i in b] + ['']) | |
37 |
if util.binary(basetext) or util.binary(atext) |
|
41 | if (stringutil.binary(basetext) or stringutil.binary(atext) | |
|
42 | or stringutil.binary(btext)): | |||
38 | raise error.Abort("don't know how to merge binary files") |
|
43 | raise error.Abort("don't know how to merge binary files") | |
39 | simplemerge.Merge3Text.__init__(self, basetext, atext, btext, |
|
44 | simplemerge.Merge3Text.__init__(self, basetext, atext, btext, | |
40 | base, a, b) |
|
45 | base, a, b) | |
@@ -358,4 +363,3 if __name__ == '__main__': | |||||
358 | unittest.main() |
|
363 | unittest.main() | |
359 | finally: |
|
364 | finally: | |
360 | time.time = orig |
|
365 | time.time = orig | |
361 |
|
General Comments 0
You need to be logged in to leave comments.
Login now