Path encoding is a little suspect in here, but it's not worse than it
was when we were on Python 2 only.
Subversion subrepo tests now pass in Python 3.
Path encoding is a little suspect in here, but it's not worse than it
was when we were on Python 2 only.
Subversion subrepo tests now pass in Python 3.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/subrepo.py (40 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Augie Fackler | Jan 30 2019, 7:18 PM |
del env['LC_ALL'] | del env['LC_ALL'] | ||||
env['LC_MESSAGES'] = 'C' | env['LC_MESSAGES'] = 'C' | ||||
p = subprocess.Popen(pycompat.rapply(procutil.tonativestr, cmd), | p = subprocess.Popen(pycompat.rapply(procutil.tonativestr, cmd), | ||||
bufsize=-1, close_fds=procutil.closefds, | bufsize=-1, close_fds=procutil.closefds, | ||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, | stdout=subprocess.PIPE, stderr=subprocess.PIPE, | ||||
universal_newlines=True, | universal_newlines=True, | ||||
env=procutil.tonativeenv(env), **extrakw) | env=procutil.tonativeenv(env), **extrakw) | ||||
stdout, stderr = p.communicate() | stdout, stderr = p.communicate() | ||||
stdout, stderr = pycompat.fsencode(stdout), pycompat.fsencode(stderr) | |||||
stderr = stderr.strip() | stderr = stderr.strip() | ||||
if not failok: | if not failok: | ||||
if p.returncode: | if p.returncode: | ||||
raise error.Abort(stderr or 'exited with code %d' | raise error.Abort(stderr or 'exited with code %d' | ||||
% p.returncode) | % p.returncode) | ||||
if stderr: | if stderr: | ||||
self.ui.warn(stderr + '\n') | self.ui.warn(stderr + '\n') | ||||
return stdout, stderr | return stdout, stderr | ||||
return not self.wvfs.exists('.svn') | return not self.wvfs.exists('.svn') | ||||
def _wcrevs(self): | def _wcrevs(self): | ||||
# Get the working directory revision as well as the last | # Get the working directory revision as well as the last | ||||
# commit revision so we can compare the subrepo state with | # commit revision so we can compare the subrepo state with | ||||
# both. We used to store the working directory one. | # both. We used to store the working directory one. | ||||
output, err = self._svncommand(['info', '--xml']) | output, err = self._svncommand(['info', '--xml']) | ||||
doc = xml.dom.minidom.parseString(output) | doc = xml.dom.minidom.parseString(output) | ||||
entries = doc.getElementsByTagName('entry') | entries = doc.getElementsByTagName(r'entry') | ||||
lastrev, rev = '0', '0' | lastrev, rev = '0', '0' | ||||
if entries: | if entries: | ||||
rev = str(entries[0].getAttribute('revision')) or '0' | rev = pycompat.bytestr(entries[0].getAttribute(r'revision')) or '0' | ||||
commits = entries[0].getElementsByTagName('commit') | commits = entries[0].getElementsByTagName(r'commit') | ||||
if commits: | if commits: | ||||
lastrev = str(commits[0].getAttribute('revision')) or '0' | lastrev = pycompat.bytestr( | ||||
commits[0].getAttribute(r'revision')) or '0' | |||||
return (lastrev, rev) | return (lastrev, rev) | ||||
def _wcrev(self): | def _wcrev(self): | ||||
return self._wcrevs()[0] | return self._wcrevs()[0] | ||||
def _wcchanged(self): | def _wcchanged(self): | ||||
"""Return (changes, extchanges, missing) where changes is True | """Return (changes, extchanges, missing) where changes is True | ||||
if the working directory was changed, extchanges is | if the working directory was changed, extchanges is | ||||
True if any of these changes concern an external entry and missing | True if any of these changes concern an external entry and missing | ||||
is True if any change is a missing entry. | is True if any change is a missing entry. | ||||
""" | """ | ||||
output, err = self._svncommand(['status', '--xml']) | output, err = self._svncommand(['status', '--xml']) | ||||
externals, changes, missing = [], [], [] | externals, changes, missing = [], [], [] | ||||
doc = xml.dom.minidom.parseString(output) | doc = xml.dom.minidom.parseString(output) | ||||
for e in doc.getElementsByTagName('entry'): | for e in doc.getElementsByTagName(r'entry'): | ||||
s = e.getElementsByTagName('wc-status') | s = e.getElementsByTagName(r'wc-status') | ||||
if not s: | if not s: | ||||
continue | continue | ||||
item = s[0].getAttribute('item') | item = s[0].getAttribute(r'item') | ||||
props = s[0].getAttribute('props') | props = s[0].getAttribute(r'props') | ||||
path = e.getAttribute('path') | path = e.getAttribute(r'path').encode('utf8') | ||||
if item == 'external': | if item == r'external': | ||||
externals.append(path) | externals.append(path) | ||||
elif item == 'missing': | elif item == r'missing': | ||||
missing.append(path) | missing.append(path) | ||||
if (item not in ('', 'normal', 'unversioned', 'external') | if (item not in (r'', r'normal', r'unversioned', r'external') | ||||
or props not in ('', 'none', 'normal')): | or props not in (r'', r'none', r'normal')): | ||||
changes.append(path) | changes.append(path) | ||||
for path in changes: | for path in changes: | ||||
for ext in externals: | for ext in externals: | ||||
if path == ext or path.startswith(ext + pycompat.ossep): | if path == ext or path.startswith(ext + pycompat.ossep): | ||||
return True, True, bool(missing) | return True, True, bool(missing) | ||||
return bool(changes), False, bool(missing) | return bool(changes), False, bool(missing) | ||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
# push is a no-op for SVN | # push is a no-op for SVN | ||||
return True | return True | ||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def files(self): | def files(self): | ||||
output = self._svncommand(['list', '--recursive', '--xml'])[0] | output = self._svncommand(['list', '--recursive', '--xml'])[0] | ||||
doc = xml.dom.minidom.parseString(output) | doc = xml.dom.minidom.parseString(output) | ||||
paths = [] | paths = [] | ||||
for e in doc.getElementsByTagName('entry'): | for e in doc.getElementsByTagName(r'entry'): | ||||
kind = pycompat.bytestr(e.getAttribute('kind')) | kind = pycompat.bytestr(e.getAttribute(r'kind')) | ||||
if kind != 'file': | if kind != 'file': | ||||
continue | continue | ||||
name = ''.join(c.data for c | name = r''.join(c.data for c | ||||
in e.getElementsByTagName('name')[0].childNodes | in e.getElementsByTagName(r'name')[0].childNodes | ||||
if c.nodeType == c.TEXT_NODE) | if c.nodeType == c.TEXT_NODE) | ||||
paths.append(name.encode('utf-8')) | paths.append(pycompat.fsencode(name)) | ||||
return paths | return paths | ||||
def filedata(self, name, decode): | def filedata(self, name, decode): | ||||
return self._svncommand(['cat'], name)[0] | return self._svncommand(['cat'], name)[0] | ||||
class gitsubrepo(abstractsubrepo): | class gitsubrepo(abstractsubrepo): | ||||
def __init__(self, ctx, path, state, allowcreate): | def __init__(self, ctx, path, state, allowcreate): |