Mercurial > hg
comparison tests/testlib/ext-phase-report.py @ 36044:3b4d14beac3d
py3: port ext-phase-report.py extension
The custom module importer doesn't run on Python files in the
tests directory. So we need the source to be compatible with
both Python 2 and 3.
Differential Revision: https://phab.mercurial-scm.org/D2145
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 11 Feb 2018 13:32:18 -0800 |
parents | 67a3204c83c1 |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
36043:223ed0b53f08 | 36044:3b4d14beac3d |
---|---|
3 from __future__ import absolute_import | 3 from __future__ import absolute_import |
4 | 4 |
5 def reposetup(ui, repo): | 5 def reposetup(ui, repo): |
6 | 6 |
7 def reportphasemove(tr): | 7 def reportphasemove(tr): |
8 for rev, move in sorted(tr.changes['phases'].iteritems()): | 8 for rev, move in sorted(tr.changes[b'phases'].items()): |
9 if move[0] is None: | 9 if move[0] is None: |
10 ui.write(('test-debug-phase: new rev %d: x -> %d\n' | 10 ui.write((b'test-debug-phase: new rev %d: x -> %d\n' |
11 % (rev, move[1]))) | 11 % (rev, move[1]))) |
12 else: | 12 else: |
13 ui.write(('test-debug-phase: move rev %d: %s -> %d\n' | 13 ui.write((b'test-debug-phase: move rev %d: %d -> %d\n' |
14 % (rev, move[0], move[1]))) | 14 % (rev, move[0], move[1]))) |
15 | 15 |
16 class reportphaserepo(repo.__class__): | 16 class reportphaserepo(repo.__class__): |
17 def transaction(self, *args, **kwargs): | 17 def transaction(self, *args, **kwargs): |
18 tr = super(reportphaserepo, self).transaction(*args, **kwargs) | 18 tr = super(reportphaserepo, self).transaction(*args, **kwargs) |
19 tr.addpostclose('report-phase', reportphasemove) | 19 tr.addpostclose(b'report-phase', reportphasemove) |
20 return tr | 20 return tr |
21 | 21 |
22 repo.__class__ = reportphaserepo | 22 repo.__class__ = reportphaserepo |