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