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