Mercurial > public > mercurial-scm > hg
comparison mercurial/changelog.py @ 18379:e0c4f4ba624c
tests: fix doctest stability over Python versions
pprint ain't pretty in Python 2.4:
Changed in version 2.5: Dictionaries are sorted by key before the display is
computed; before 2.5, a dictionary was sorted only if its display required more
than one line, although that wasn?t documented.
Fixes issue introduced in 404feac78b8a.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 15 Jan 2013 18:42:04 +0100 |
parents | 404feac78b8a |
children | cbf5f3eb9d13 |
comparison
equal
deleted
inserted
replaced
18378:404feac78b8a | 18379:e0c4f4ba624c |
---|---|
25 text = text.replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r') | 25 text = text.replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r') |
26 return text.replace('\0', '\\0') | 26 return text.replace('\0', '\\0') |
27 | 27 |
28 def decodeextra(text): | 28 def decodeextra(text): |
29 """ | 29 """ |
30 >>> from pprint import pprint as pp | 30 >>> sorted(decodeextra(encodeextra({'foo': 'bar', 'baz': chr(0) + '2'}) |
31 >>> pp(decodeextra(encodeextra({'foo': 'bar', 'baz': chr(0) + '2'}))) | 31 ... ).iteritems()) |
32 {'baz': '\\x002', 'branch': 'default', 'foo': 'bar'} | 32 [('baz', '\\x002'), ('branch', 'default'), ('foo', 'bar')] |
33 >>> pp(decodeextra(encodeextra({'foo': 'bar', | 33 >>> sorted(decodeextra(encodeextra({'foo': 'bar', |
34 ... 'baz': chr(92) + chr(0) + '2'}))) | 34 ... 'baz': chr(92) + chr(0) + '2'}) |
35 {'baz': '\\\\\\x002', 'branch': 'default', 'foo': 'bar'} | 35 ... ).iteritems()) |
36 [('baz', '\\\\\\x002'), ('branch', 'default'), ('foo', 'bar')] | |
36 """ | 37 """ |
37 extra = _defaultextra.copy() | 38 extra = _defaultextra.copy() |
38 for l in text.split('\0'): | 39 for l in text.split('\0'): |
39 if l: | 40 if l: |
40 if '\\0' in l: | 41 if '\\0' in l: |