Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG9954d0e2ad00: py3: use pycompat.bytestr() intsead of str
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/journal.py (2 lines) | |||
M | tests/test-arbitraryfilectx.t (4 lines) |
oldhashes = tuple(node.bin(hash) for hash in oldhashes.split(',')) | oldhashes = tuple(node.bin(hash) for hash in oldhashes.split(',')) | ||||
newhashes = tuple(node.bin(hash) for hash in newhashes.split(',')) | newhashes = tuple(node.bin(hash) for hash in newhashes.split(',')) | ||||
return cls( | return cls( | ||||
(timestamp, tz), user, command, namespace, name, | (timestamp, tz), user, command, namespace, name, | ||||
oldhashes, newhashes) | oldhashes, newhashes) | ||||
def __bytes__(self): | def __bytes__(self): | ||||
"""bytes representation for storage""" | """bytes representation for storage""" | ||||
time = ' '.join(map(str, self.timestamp)) | time = ' '.join(map(pycompat.bytestr, self.timestamp)) | ||||
oldhashes = ','.join([node.hex(hash) for hash in self.oldhashes]) | oldhashes = ','.join([node.hex(hash) for hash in self.oldhashes]) | ||||
newhashes = ','.join([node.hex(hash) for hash in self.newhashes]) | newhashes = ','.join([node.hex(hash) for hash in self.newhashes]) | ||||
return '\n'.join(( | return '\n'.join(( | ||||
time, self.user, self.command, self.namespace, self.name, | time, self.user, self.command, self.namespace, self.name, | ||||
oldhashes, newhashes)) | oldhashes, newhashes)) | ||||
__str__ = encoding.strmethod(__bytes__) | __str__ = encoding.strmethod(__bytes__) | ||||
Setup: | Setup: | ||||
$ cat > eval.py <<EOF | $ cat > eval.py <<EOF | ||||
> from __future__ import absolute_import | > from __future__ import absolute_import | ||||
> import filecmp | > import filecmp | ||||
> from mercurial import commands, context, registrar | > from mercurial import commands, context, pycompat, registrar | ||||
> cmdtable = {} | > cmdtable = {} | ||||
> command = registrar.command(cmdtable) | > command = registrar.command(cmdtable) | ||||
> @command(b'eval', [], b'hg eval CMD') | > @command(b'eval', [], b'hg eval CMD') | ||||
> def eval_(ui, repo, *cmds, **opts): | > def eval_(ui, repo, *cmds, **opts): | ||||
> cmd = b" ".join(cmds) | > cmd = b" ".join(cmds) | ||||
> res = str(eval(cmd, globals(), locals())) | > res = pycompat.bytestr(eval(cmd, globals(), locals())) | ||||
> ui.warn(b"%s" % res) | > ui.warn(b"%s" % res) | ||||
> EOF | > EOF | ||||
$ echo "[extensions]" >> $HGRCPATH | $ echo "[extensions]" >> $HGRCPATH | ||||
$ echo "eval=`pwd`/eval.py" >> $HGRCPATH | $ echo "eval=`pwd`/eval.py" >> $HGRCPATH | ||||
Arbitraryfilectx.cmp does not follow symlinks: | Arbitraryfilectx.cmp does not follow symlinks: | ||||
$ mkdir case1 | $ mkdir case1 |