##// END OF EJS Templates
py3: make sure we open the file in bytes mode...
Pulkit Goyal -
r36501:5a029f04 default
parent child Browse files
Show More
@@ -1,88 +1,88 b''
1 from __future__ import absolute_import, print_function
1 from __future__ import absolute_import, print_function
2 import os
2 import os
3 from mercurial import (
3 from mercurial import (
4 hg,
4 hg,
5 merge,
5 merge,
6 ui as uimod,
6 ui as uimod,
7 )
7 )
8
8
9 u = uimod.ui.load()
9 u = uimod.ui.load()
10
10
11 repo = hg.repository(u, b'test1', create=1)
11 repo = hg.repository(u, b'test1', create=1)
12 os.chdir('test1')
12 os.chdir('test1')
13
13
14 def commit(text, time):
14 def commit(text, time):
15 repo.commit(text=text, date=b"%d 0" % time)
15 repo.commit(text=text, date=b"%d 0" % time)
16
16
17 def addcommit(name, time):
17 def addcommit(name, time):
18 f = open(name, 'w')
18 f = open(name, 'wb')
19 f.write(b'%s\n' % name)
19 f.write(b'%s\n' % name)
20 f.close()
20 f.close()
21 repo[None].add([name])
21 repo[None].add([name])
22 commit(name, time)
22 commit(name, time)
23
23
24 def update(rev):
24 def update(rev):
25 merge.update(repo, rev, False, True)
25 merge.update(repo, rev, False, True)
26
26
27 def merge_(rev):
27 def merge_(rev):
28 merge.update(repo, rev, True, False)
28 merge.update(repo, rev, True, False)
29
29
30 if __name__ == '__main__':
30 if __name__ == '__main__':
31 addcommit(b"A", 0)
31 addcommit(b"A", 0)
32 addcommit(b"B", 1)
32 addcommit(b"B", 1)
33
33
34 update(0)
34 update(0)
35 addcommit(b"C", 2)
35 addcommit(b"C", 2)
36
36
37 merge_(1)
37 merge_(1)
38 commit(b"D", 3)
38 commit(b"D", 3)
39
39
40 update(2)
40 update(2)
41 addcommit(b"E", 4)
41 addcommit(b"E", 4)
42 addcommit(b"F", 5)
42 addcommit(b"F", 5)
43
43
44 update(3)
44 update(3)
45 addcommit(b"G", 6)
45 addcommit(b"G", 6)
46
46
47 merge_(5)
47 merge_(5)
48 commit(b"H", 7)
48 commit(b"H", 7)
49
49
50 update(5)
50 update(5)
51 addcommit(b"I", 8)
51 addcommit(b"I", 8)
52
52
53 # Ancestors
53 # Ancestors
54 print('Ancestors of 5')
54 print('Ancestors of 5')
55 for r in repo.changelog.ancestors([5]):
55 for r in repo.changelog.ancestors([5]):
56 print(r, end=' ')
56 print(r, end=' ')
57
57
58 print('\nAncestors of 6 and 5')
58 print('\nAncestors of 6 and 5')
59 for r in repo.changelog.ancestors([6, 5]):
59 for r in repo.changelog.ancestors([6, 5]):
60 print(r, end=' ')
60 print(r, end=' ')
61
61
62 print('\nAncestors of 5 and 4')
62 print('\nAncestors of 5 and 4')
63 for r in repo.changelog.ancestors([5, 4]):
63 for r in repo.changelog.ancestors([5, 4]):
64 print(r, end=' ')
64 print(r, end=' ')
65
65
66 print('\nAncestors of 7, stop at 6')
66 print('\nAncestors of 7, stop at 6')
67 for r in repo.changelog.ancestors([7], 6):
67 for r in repo.changelog.ancestors([7], 6):
68 print(r, end=' ')
68 print(r, end=' ')
69
69
70 print('\nAncestors of 7, including revs')
70 print('\nAncestors of 7, including revs')
71 for r in repo.changelog.ancestors([7], inclusive=True):
71 for r in repo.changelog.ancestors([7], inclusive=True):
72 print(r, end=' ')
72 print(r, end=' ')
73
73
74 print('\nAncestors of 7, 5 and 3, including revs')
74 print('\nAncestors of 7, 5 and 3, including revs')
75 for r in repo.changelog.ancestors([7, 5, 3], inclusive=True):
75 for r in repo.changelog.ancestors([7, 5, 3], inclusive=True):
76 print(r, end=' ')
76 print(r, end=' ')
77
77
78 # Descendants
78 # Descendants
79 print('\n\nDescendants of 5')
79 print('\n\nDescendants of 5')
80 for r in repo.changelog.descendants([5]):
80 for r in repo.changelog.descendants([5]):
81 print(r, end=' ')
81 print(r, end=' ')
82
82
83 print('\nDescendants of 5 and 3')
83 print('\nDescendants of 5 and 3')
84 for r in repo.changelog.descendants([5, 3]):
84 for r in repo.changelog.descendants([5, 3]):
85 print(r, end=' ')
85 print(r, end=' ')
86
86
87 print('\nDescendants of 5 and 4')
87 print('\nDescendants of 5 and 4')
88 print(*repo.changelog.descendants([5, 4]), sep=' ')
88 print(*repo.changelog.descendants([5, 4]), sep=' ')
General Comments 0
You need to be logged in to leave comments. Login now