Since we are internally dealing with bytes only, we need to use bytes in the
tests too. This is one of the many patches which will make all the tests
completely use bytes.
- skip-blame because we are just adding b''
durin42 |
hg-reviewers |
Since we are internally dealing with bytes only, we need to use bytes in the
tests too. This is one of the many patches which will make all the tests
completely use bytes.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
For patches like this that are just adding bytes prefixes, let's go ahead and do a '# skip-blame' as in d92dc725223bbde09963fc431e57d32a40c4167d (aka D1170) so that blame is cleaner in the future.
Path | Packages | |||
---|---|---|---|---|
M | tests/dummyssh (4 lines) | |||
M | tests/flagprocessorext.py (8 lines) | |||
M | tests/revlog-formatv0.py (42 lines) | |||
M | tests/test-bundle2-multiple-changegroups.t (16 lines) | |||
M | tests/test-diffstat.t (4 lines) |
#!/usr/bin/env python | #!/usr/bin/env python | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
import os | import os | ||||
import sys | import sys | ||||
os.chdir(os.getenv('TESTTMP')) | os.chdir(os.getenv('TESTTMP')) | ||||
if sys.argv[1] != "user@dummy": | if sys.argv[1] != "user@dummy": | ||||
sys.exit(-1) | sys.exit(-1) | ||||
os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get('LOCALIP', '127.0.0.1') | os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get('LOCALIP', '127.0.0.1') | ||||
log = open("dummylog", "ab") | log = open("dummylog", "ab") | ||||
log.write("Got arguments") | log.write(b"Got arguments") | ||||
for i, arg in enumerate(sys.argv[1:]): | for i, arg in enumerate(sys.argv[1:]): | ||||
log.write(" %d:%s" % (i + 1, arg)) | log.write(b" %d:%s" % (i + 1, arg)) | ||||
log.write("\n") | log.write("\n") | ||||
log.close() | log.close() | ||||
hgcmd = sys.argv[2] | hgcmd = sys.argv[2] | ||||
if os.name == 'nt': | if os.name == 'nt': | ||||
# hack to make simple unix single quote quoting work on windows | # hack to make simple unix single quote quoting work on windows | ||||
hgcmd = hgcmd.replace("'", '"') | hgcmd = hgcmd.replace("'", '"') | ||||
r = os.system(hgcmd) | r = os.system(hgcmd) | ||||
sys.exit(bool(r)) | sys.exit(bool(r)) |
def allsupportedversions(orig, ui): | def allsupportedversions(orig, ui): | ||||
versions = orig(ui) | versions = orig(ui) | ||||
versions.add('03') | versions.add('03') | ||||
return versions | return versions | ||||
def noopaddrevision(orig, self, text, transaction, link, p1, p2, | def noopaddrevision(orig, self, text, transaction, link, p1, p2, | ||||
cachedelta=None, node=None, | cachedelta=None, node=None, | ||||
flags=revlog.REVIDX_DEFAULT_FLAGS): | flags=revlog.REVIDX_DEFAULT_FLAGS): | ||||
if '[NOOP]' in text: | if b'[NOOP]' in text: | ||||
flags |= REVIDX_NOOP | flags |= REVIDX_NOOP | ||||
return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta, | return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta, | ||||
node=node, flags=flags) | node=node, flags=flags) | ||||
def b64addrevision(orig, self, text, transaction, link, p1, p2, | def b64addrevision(orig, self, text, transaction, link, p1, p2, | ||||
cachedelta=None, node=None, | cachedelta=None, node=None, | ||||
flags=revlog.REVIDX_DEFAULT_FLAGS): | flags=revlog.REVIDX_DEFAULT_FLAGS): | ||||
if '[BASE64]' in text: | if b'[BASE64]' in text: | ||||
flags |= REVIDX_BASE64 | flags |= REVIDX_BASE64 | ||||
return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta, | return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta, | ||||
node=node, flags=flags) | node=node, flags=flags) | ||||
def gzipaddrevision(orig, self, text, transaction, link, p1, p2, | def gzipaddrevision(orig, self, text, transaction, link, p1, p2, | ||||
cachedelta=None, node=None, | cachedelta=None, node=None, | ||||
flags=revlog.REVIDX_DEFAULT_FLAGS): | flags=revlog.REVIDX_DEFAULT_FLAGS): | ||||
if '[GZIP]' in text: | if b'[GZIP]' in text: | ||||
flags |= REVIDX_GZIP | flags |= REVIDX_GZIP | ||||
return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta, | return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta, | ||||
node=node, flags=flags) | node=node, flags=flags) | ||||
def failaddrevision(orig, self, text, transaction, link, p1, p2, | def failaddrevision(orig, self, text, transaction, link, p1, p2, | ||||
cachedelta=None, node=None, | cachedelta=None, node=None, | ||||
flags=revlog.REVIDX_DEFAULT_FLAGS): | flags=revlog.REVIDX_DEFAULT_FLAGS): | ||||
# This addrevision wrapper is meant to add a flag we will not have | # This addrevision wrapper is meant to add a flag we will not have | ||||
# transforms registered for, ensuring we handle this error case. | # transforms registered for, ensuring we handle this error case. | ||||
if '[FAIL]' in text: | if b'[FAIL]' in text: | ||||
flags |= REVIDX_FAIL | flags |= REVIDX_FAIL | ||||
return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta, | return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta, | ||||
node=node, flags=flags) | node=node, flags=flags) | ||||
def extsetup(ui): | def extsetup(ui): | ||||
# Enable changegroup3 for flags to be sent over the wire | # Enable changegroup3 for flags to be sent over the wire | ||||
wrapfunction = extensions.wrapfunction | wrapfunction = extensions.wrapfunction | ||||
wrapfunction(changegroup, | wrapfunction(changegroup, |
empty file | empty file | ||||
""" | """ | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
import os | import os | ||||
import sys | import sys | ||||
files = [ | files = [ | ||||
('formatv0/.hg/00changelog.i', | (b'formatv0/.hg/00changelog.i', | ||||
'000000000000004400000000000000000000000000000000000000' | b'000000000000004400000000000000000000000000000000000000' | ||||
'000000000000000000000000000000000000000000000000000000' | b'000000000000000000000000000000000000000000000000000000' | ||||
'0000a1ef0b125355d27765928be600cfe85784284ab3'), | b'0000a1ef0b125355d27765928be600cfe85784284ab3'), | ||||
('formatv0/.hg/00changelog.d', | (b'formatv0/.hg/00changelog.d', | ||||
'756163613935613961356635353036303562366138343738336237' | b'756163613935613961356635353036303562366138343738336237' | ||||
'61623536363738616436356635380a757365720a3020300a656d70' | b'61623536363738616436356635380a757365720a3020300a656d70' | ||||
'74790a0a656d7074792066696c65'), | b'74790a0a656d7074792066696c65'), | ||||
('formatv0/.hg/00manifest.i', | (b'formatv0/.hg/00manifest.i', | ||||
'000000000000003000000000000000000000000000000000000000' | b'000000000000003000000000000000000000000000000000000000' | ||||
'000000000000000000000000000000000000000000000000000000' | b'000000000000000000000000000000000000000000000000000000' | ||||
'0000aca95a9a5f550605b6a84783b7ab56678ad65f58'), | b'0000aca95a9a5f550605b6a84783b7ab56678ad65f58'), | ||||
('formatv0/.hg/00manifest.d', | (b'formatv0/.hg/00manifest.d', | ||||
'75656d707479006238306465356431333837353835343163356630' | b'75656d707479006238306465356431333837353835343163356630' | ||||
'35323635616431343461623966613836643164620a'), | b'35323635616431343461623966613836643164620a'), | ||||
('formatv0/.hg/data/empty.i', | (b'formatv0/.hg/data/empty.i', | ||||
'000000000000000000000000000000000000000000000000000000' | b'000000000000000000000000000000000000000000000000000000' | ||||
'000000000000000000000000000000000000000000000000000000' | b'000000000000000000000000000000000000000000000000000000' | ||||
'0000b80de5d138758541c5f05265ad144ab9fa86d1db'), | b'0000b80de5d138758541c5f05265ad144ab9fa86d1db'), | ||||
('formatv0/.hg/data/empty.d', | (b'formatv0/.hg/data/empty.d', | ||||
''), | b''), | ||||
] | ] | ||||
def makedirs(name): | def makedirs(name): | ||||
"""recursive directory creation""" | """recursive directory creation""" | ||||
parent = os.path.dirname(name) | parent = os.path.dirname(name) | ||||
if parent: | if parent: | ||||
makedirs(parent) | makedirs(parent) | ||||
os.mkdir(name) | os.mkdir(name) |
Create an extension to test bundle2 with multiple changegroups | Create an extension to test bundle2 with multiple changegroups | ||||
$ cat > bundle2.py <<EOF | $ cat > bundle2.py <<EOF | ||||
> """ | > """ | ||||
> """ | > """ | ||||
> from mercurial import changegroup, discovery, exchange | > from mercurial import changegroup, discovery, exchange | ||||
> | > | ||||
> def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, | > def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, | ||||
> b2caps=None, heads=None, common=None, | > b2caps=None, heads=None, common=None, | ||||
> **kwargs): | > **kwargs): | ||||
> # Create two changegroups given the common changesets and heads for the | > # Create two changegroups given the common changesets and heads for the | ||||
> # changegroup part we are being requested. Use the parent of each head | > # changegroup part we are being requested. Use the parent of each head | ||||
> # in 'heads' as intermediate heads for the first changegroup. | > # in 'heads' as intermediate heads for the first changegroup. | ||||
> intermediates = [repo[r].p1().node() for r in heads] | > intermediates = [repo[r].p1().node() for r in heads] | ||||
> outgoing = discovery.outgoing(repo, common, intermediates) | > outgoing = discovery.outgoing(repo, common, intermediates) | ||||
> cg = changegroup.makechangegroup(repo, outgoing, '01', | > cg = changegroup.makechangegroup(repo, outgoing, b'01', | ||||
> source, bundlecaps=bundlecaps) | > source, bundlecaps=bundlecaps) | ||||
> bundler.newpart('output', data='changegroup1') | > bundler.newpart(b'output', data=b'changegroup1') | ||||
> bundler.newpart('changegroup', data=cg.getchunks()) | > bundler.newpart(b'changegroup', data=cg.getchunks()) | ||||
> outgoing = discovery.outgoing(repo, common + intermediates, heads) | > outgoing = discovery.outgoing(repo, common + intermediates, heads) | ||||
> cg = changegroup.makechangegroup(repo, outgoing, '01', | > cg = changegroup.makechangegroup(repo, outgoing, b'01', | ||||
> source, bundlecaps=bundlecaps) | > source, bundlecaps=bundlecaps) | ||||
> bundler.newpart('output', data='changegroup2') | > bundler.newpart(b'output', data=b'changegroup2') | ||||
> bundler.newpart('changegroup', data=cg.getchunks()) | > bundler.newpart(b'changegroup', data=cg.getchunks()) | ||||
> | > | ||||
> def _pull(repo, *args, **kwargs): | > def _pull(repo, *args, **kwargs): | ||||
> pullop = _orig_pull(repo, *args, **kwargs) | > pullop = _orig_pull(repo, *args, **kwargs) | ||||
> repo.ui.write('pullop.cgresult is %d\n' % pullop.cgresult) | > repo.ui.write(b'pullop.cgresult is %d\n' % pullop.cgresult) | ||||
> return pullop | > return pullop | ||||
> | > | ||||
> _orig_pull = exchange.pull | > _orig_pull = exchange.pull | ||||
> exchange.pull = _pull | > exchange.pull = _pull | ||||
> exchange.getbundle2partsmapping['changegroup'] = _getbundlechangegrouppart | > exchange.getbundle2partsmapping[b'changegroup'] = _getbundlechangegrouppart | ||||
> EOF | > EOF | ||||
$ cat >> $HGRCPATH << EOF | $ cat >> $HGRCPATH << EOF | ||||
> [ui] | > [ui] | ||||
> logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline} | > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline} | ||||
> EOF | > EOF | ||||
Start with a simple repository with a single commit | Start with a simple repository with a single commit |
Narrow diffstat: | Narrow diffstat: | ||||
$ hg diff --stat | $ hg diff --stat | ||||
a | 3 +++ | a | 3 +++ | ||||
1 files changed, 3 insertions(+), 0 deletions(-) | 1 files changed, 3 insertions(+), 0 deletions(-) | ||||
$ hg ci -m appenda | $ hg ci -m appenda | ||||
>>> open("c", "wb").write("\0") | >>> open("c", "wb").write(b"\0") | ||||
$ touch d | $ touch d | ||||
$ hg add c d | $ hg add c d | ||||
Binary diffstat: | Binary diffstat: | ||||
$ hg diff --stat | $ hg diff --stat | ||||
c | Bin | c | Bin | ||||
1 files changed, 0 insertions(+), 0 deletions(-) | 1 files changed, 0 insertions(+), 0 deletions(-) | ||||
Binary git diffstat: | Binary git diffstat: | ||||
$ hg diff --stat --git | $ hg diff --stat --git | ||||
c | Bin | c | Bin | ||||
d | 0 | d | 0 | ||||
2 files changed, 0 insertions(+), 0 deletions(-) | 2 files changed, 0 insertions(+), 0 deletions(-) | ||||
$ hg ci -m createb | $ hg ci -m createb | ||||
>>> open("file with spaces", "wb").write("\0") | >>> open("file with spaces", "wb").write(b"\0") | ||||
$ hg add "file with spaces" | $ hg add "file with spaces" | ||||
Filename with spaces diffstat: | Filename with spaces diffstat: | ||||
$ hg diff --stat | $ hg diff --stat | ||||
file with spaces | Bin | file with spaces | Bin | ||||
1 files changed, 0 insertions(+), 0 deletions(-) | 1 files changed, 0 insertions(+), 0 deletions(-) | ||||