The Python 3 implementation is a no-op. So this is equivalent.
We still keep util.iterfile() around for backwards API compatibility to
help the Python 3 migration. It can be deleted in a future release.
( )
Alphare |
hg-reviewers |
The Python 3 implementation is a no-op. So this is equivalent.
We still keep util.iterfile() around for backwards API compatibility to
help the Python 3 migration. It can be deleted in a future release.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | hgext/convert/common.py (2 lines) | |||
M | hgext/convert/convcmd.py (2 lines) | |||
M | mercurial/match.py (2 lines) | |||
M | mercurial/patch.py (4 lines) | |||
M | mercurial/store.py (2 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | D12339 ui: use input() directly | |
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg |
if not self.path: | if not self.path: | ||||
return | return | ||||
try: | try: | ||||
fp = open(self.path, b'rb') | fp = open(self.path, b'rb') | ||||
except IOError as err: | except IOError as err: | ||||
if err.errno != errno.ENOENT: | if err.errno != errno.ENOENT: | ||||
raise | raise | ||||
return | return | ||||
for i, line in enumerate(util.iterfile(fp)): | for i, line in enumerate(fp): | ||||
line = line.splitlines()[0].rstrip() | line = line.splitlines()[0].rstrip() | ||||
if not line: | if not line: | ||||
# Ignore blank lines | # Ignore blank lines | ||||
continue | continue | ||||
try: | try: | ||||
key, value = line.rsplit(b' ', 1) | key, value = line.rsplit(b' ', 1) | ||||
except ValueError: | except ValueError: | ||||
raise error.Abort( | raise error.Abort( |
hg.py, subversion.py etc. | hg.py, subversion.py etc. | ||||
""" | """ | ||||
if not path: | if not path: | ||||
return {} | return {} | ||||
m = {} | m = {} | ||||
try: | try: | ||||
fp = open(path, b'rb') | fp = open(path, b'rb') | ||||
for i, line in enumerate(util.iterfile(fp)): | for i, line in enumerate(fp): | ||||
line = line.splitlines()[0].rstrip() | line = line.splitlines()[0].rstrip() | ||||
if not line: | if not line: | ||||
# Ignore blank lines | # Ignore blank lines | ||||
continue | continue | ||||
# split line | # split line | ||||
lex = common.shlexer(data=line, whitespace=b',') | lex = common.shlexer(data=line, whitespace=b',') | ||||
line = list(lex) | line = list(lex) | ||||
# check number of parents | # check number of parents |
b'rootglob': b'rootglob:', | b'rootglob': b'rootglob:', | ||||
b'include': b'include', | b'include': b'include', | ||||
b'subinclude': b'subinclude', | b'subinclude': b'subinclude', | ||||
} | } | ||||
syntax = b'relre:' | syntax = b'relre:' | ||||
patterns = [] | patterns = [] | ||||
fp = open(filepath, b'rb') | fp = open(filepath, b'rb') | ||||
for lineno, line in enumerate(util.iterfile(fp), start=1): | for lineno, line in enumerate(fp, start=1): | ||||
if b"#" in line: | if b"#" in line: | ||||
global _commentre | global _commentre | ||||
if not _commentre: | if not _commentre: | ||||
_commentre = util.re.compile(br'((?:^|[^\\])(?:\\\\)*)#.*') | _commentre = util.re.compile(br'((?:^|[^\\])(?:\\\\)*)#.*') | ||||
# remove comments prefixed by an even number of escapes | # remove comments prefixed by an even number of escapes | ||||
m = _commentre.search(line) | m = _commentre.search(line) | ||||
if m: | if m: | ||||
line = line[: m.end(1)] | line = line[: m.end(1)] |
blockedtag=b'filterpatch', | blockedtag=b'filterpatch', | ||||
) | ) | ||||
if ret != 0: | if ret != 0: | ||||
ui.warn(_(b"editor exited with exit code %d\n") % ret) | ui.warn(_(b"editor exited with exit code %d\n") % ret) | ||||
continue | continue | ||||
# Remove comment lines | # Remove comment lines | ||||
patchfp = open(patchfn, 'rb') | patchfp = open(patchfn, 'rb') | ||||
ncpatchfp = stringio() | ncpatchfp = stringio() | ||||
for line in util.iterfile(patchfp): | for line in patchfp: | ||||
line = util.fromnativeeol(line) | line = util.fromnativeeol(line) | ||||
if not line.startswith(b'#'): | if not line.startswith(b'#'): | ||||
ncpatchfp.write(line) | ncpatchfp.write(line) | ||||
patchfp.close() | patchfp.close() | ||||
ncpatchfp.seek(0) | ncpatchfp.seek(0) | ||||
newpatches = parsepatch(ncpatchfp) | newpatches = parsepatch(ncpatchfp) | ||||
finally: | finally: | ||||
os.unlink(patchfn) | os.unlink(patchfn) | ||||
patcher, | patcher, | ||||
b' '.join(args), | b' '.join(args), | ||||
strip, | strip, | ||||
procutil.shellquote(patchname), | procutil.shellquote(patchname), | ||||
) | ) | ||||
ui.debug(b'Using external patch tool: %s\n' % cmd) | ui.debug(b'Using external patch tool: %s\n' % cmd) | ||||
fp = procutil.popen(cmd, b'rb') | fp = procutil.popen(cmd, b'rb') | ||||
try: | try: | ||||
for line in util.iterfile(fp): | for line in fp: | ||||
line = line.rstrip() | line = line.rstrip() | ||||
ui.note(line + b'\n') | ui.note(line + b'\n') | ||||
if line.startswith(b'patching file '): | if line.startswith(b'patching file '): | ||||
pf = util.parsepatchoutput(line) | pf = util.parsepatchoutput(line) | ||||
printed_file = False | printed_file = False | ||||
files.add(pf) | files.add(pf) | ||||
elif line.find(b'with fuzz') >= 0: | elif line.find(b'with fuzz') >= 0: | ||||
fuzz = True | fuzz = True |
) | ) | ||||
self._checkentries(fp, warn) | self._checkentries(fp, warn) | ||||
fp.close() | fp.close() | ||||
def _checkentries(self, fp, warn): | def _checkentries(self, fp, warn): | ||||
"""make sure there is no empty string in entries""" | """make sure there is no empty string in entries""" | ||||
if b'' in self.entries: | if b'' in self.entries: | ||||
fp.seek(0) | fp.seek(0) | ||||
for n, line in enumerate(util.iterfile(fp)): | for n, line in enumerate(fp): | ||||
if not line.rstrip(b'\n'): | if not line.rstrip(b'\n'): | ||||
t = _(b'invalid entry in fncache, line %d') % (n + 1) | t = _(b'invalid entry in fncache, line %d') % (n + 1) | ||||
if warn: | if warn: | ||||
warn(t + b'\n') | warn(t + b'\n') | ||||
else: | else: | ||||
raise error.Abort(t) | raise error.Abort(t) | ||||
def write(self, tr): | def write(self, tr): |