Mercurial > hg
annotate tests/test-revlog-ancestry.py @ 9874:c51494c53841 stable
qseries: don't truncate the patch name (issue1912)
Instead of truncating the entire output line of `qseries', only the
summary is truncated.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Tue, 17 Nov 2009 22:16:41 +0100 |
parents | 3b76321aa0de |
children | a1aad8333864 |
rev | line source |
---|---|
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
1 import os |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
2 from mercurial import hg, ui, merge |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
3 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
4 u = ui.ui() |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
5 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
6 repo = hg.repository(u, 'test1', create=1) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
7 os.chdir('test1') |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
8 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
9 def commit(text, time): |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
10 repo.commit(text=text, date="%d 0" % time) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
11 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
12 def addcommit(name, time): |
9031
3b76321aa0de
compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents:
8656
diff
changeset
|
13 f = open(name, 'w') |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
14 f.write('%s\n' % name) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
15 f.close() |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
16 repo.add([name]) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
17 commit(name, time) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
18 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
19 def update(rev): |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
20 merge.update(repo, rev, False, True, False) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
21 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
22 def merge_(rev): |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
23 merge.update(repo, rev, True, False, False) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
24 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
25 if __name__ == '__main__': |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
26 addcommit("A", 0) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
27 addcommit("B", 1) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
28 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
29 update(0) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
30 addcommit("C", 2) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
31 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
32 merge_(1) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
33 commit("D", 3) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
34 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
35 update(2) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
36 addcommit("E", 4) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
37 addcommit("F", 5) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
38 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
39 update(3) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
40 addcommit("G", 6) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
41 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
42 merge_(5) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
43 commit("H", 7) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
44 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
45 update(5) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
46 addcommit("I", 8) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
47 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
48 # Ancestors |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
49 print 'Ancestors of 5' |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
50 for r in repo.changelog.ancestors(5): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
51 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
52 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
53 print '\nAncestors of 6 and 5' |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
54 for r in repo.changelog.ancestors(6, 5): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
55 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
56 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
57 print '\nAncestors of 5 and 4' |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
58 for r in repo.changelog.ancestors(5, 4): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
59 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
60 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
61 # Descendants |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
62 print '\n\nDescendants of 5' |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
63 for r in repo.changelog.descendants(5): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
64 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
65 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
66 print '\nDescendants of 5 and 3' |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
67 for r in repo.changelog.descendants(5, 3): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
68 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
69 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
70 print '\nDescendants of 5 and 4' |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
71 for r in repo.changelog.descendants(5, 4): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
72 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
73 |