Show More
@@ -0,0 +1,76 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | echo '[extensions]' >> $HGRCPATH | |||
|
4 | echo 'hgext.mq=' >> $HGRCPATH | |||
|
5 | ||||
|
6 | show_branch_cache() | |||
|
7 | { | |||
|
8 | branches=.hg/branches.cache | |||
|
9 | hg log -r tip --template 'tip: #rev#\n' | |||
|
10 | if [ -f $branches ]; then | |||
|
11 | sort $branches | |||
|
12 | else | |||
|
13 | echo No $branches | |||
|
14 | fi | |||
|
15 | if [ "$1" = 1 ]; then | |||
|
16 | for b in foo bar; do | |||
|
17 | hg log -r $b --template "branch $b: "'#rev#\n' | |||
|
18 | done | |||
|
19 | fi | |||
|
20 | } | |||
|
21 | ||||
|
22 | hg init a | |||
|
23 | cd a | |||
|
24 | hg qinit -c | |||
|
25 | ||||
|
26 | echo '# mq patch on an empty repo' | |||
|
27 | hg qnew p1 | |||
|
28 | show_branch_cache | |||
|
29 | ||||
|
30 | echo > pfile | |||
|
31 | hg add pfile | |||
|
32 | hg qrefresh -m 'patch 1' | |||
|
33 | show_branch_cache | |||
|
34 | ||||
|
35 | echo | |||
|
36 | echo '# some regular revisions' | |||
|
37 | hg qpop | |||
|
38 | echo foo > foo | |||
|
39 | hg add foo | |||
|
40 | echo foo > .hg/branch | |||
|
41 | hg ci -m 'branch foo' -d '1000000 0' | |||
|
42 | ||||
|
43 | echo bar > bar | |||
|
44 | hg add bar | |||
|
45 | echo bar > .hg/branch | |||
|
46 | hg ci -m 'branch bar' -d '1000000 0' | |||
|
47 | show_branch_cache | |||
|
48 | ||||
|
49 | echo | |||
|
50 | echo '# add some mq patches' | |||
|
51 | hg qpush | |||
|
52 | show_branch_cache | |||
|
53 | ||||
|
54 | hg qnew p2 | |||
|
55 | echo foo > .hg/branch | |||
|
56 | echo foo2 >> foo | |||
|
57 | hg qrefresh -m 'patch 2' | |||
|
58 | show_branch_cache 1 | |||
|
59 | ||||
|
60 | echo | |||
|
61 | echo '# removing the cache' | |||
|
62 | rm -f .hg/branches.cache | |||
|
63 | show_branch_cache 1 | |||
|
64 | ||||
|
65 | echo | |||
|
66 | echo '# importing rev 1 (the cache now ends in one of the patches)' | |||
|
67 | hg qimport -r 1 -n p0 | |||
|
68 | show_branch_cache 1 | |||
|
69 | hg log -r qbase --template 'qbase: #rev#\n' | |||
|
70 | ||||
|
71 | echo | |||
|
72 | echo '# detect an invalid cache' | |||
|
73 | hg qpop -a | |||
|
74 | hg qpush -a | |||
|
75 | show_branch_cache | |||
|
76 |
@@ -0,0 +1,53 b'' | |||||
|
1 | # mq patch on an empty repo | |||
|
2 | tip: 0 | |||
|
3 | No .hg/branches.cache | |||
|
4 | tip: 0 | |||
|
5 | No .hg/branches.cache | |||
|
6 | ||||
|
7 | # some regular revisions | |||
|
8 | Patch queue now empty | |||
|
9 | tip: 1 | |||
|
10 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 | |||
|
11 | 3f910abad313ff802d3a23a7529433872df9b3ae bar | |||
|
12 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo | |||
|
13 | ||||
|
14 | # add some mq patches | |||
|
15 | applying p1 | |||
|
16 | Now at: p1 | |||
|
17 | tip: 2 | |||
|
18 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 | |||
|
19 | 3f910abad313ff802d3a23a7529433872df9b3ae bar | |||
|
20 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo | |||
|
21 | tip: 3 | |||
|
22 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 | |||
|
23 | 3f910abad313ff802d3a23a7529433872df9b3ae bar | |||
|
24 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo | |||
|
25 | branch foo: 3 | |||
|
26 | branch bar: 2 | |||
|
27 | ||||
|
28 | # removing the cache | |||
|
29 | tip: 3 | |||
|
30 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 | |||
|
31 | 3f910abad313ff802d3a23a7529433872df9b3ae bar | |||
|
32 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo | |||
|
33 | branch foo: 3 | |||
|
34 | branch bar: 2 | |||
|
35 | ||||
|
36 | # importing rev 1 (the cache now ends in one of the patches) | |||
|
37 | tip: 3 | |||
|
38 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 | |||
|
39 | 3f910abad313ff802d3a23a7529433872df9b3ae bar | |||
|
40 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo | |||
|
41 | branch foo: 3 | |||
|
42 | branch bar: 2 | |||
|
43 | qbase: 1 | |||
|
44 | ||||
|
45 | # detect an invalid cache | |||
|
46 | Patch queue now empty | |||
|
47 | applying p0 | |||
|
48 | applying p1 | |||
|
49 | applying p2 | |||
|
50 | Now at: p2 | |||
|
51 | tip: 3 | |||
|
52 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0 | |||
|
53 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo |
@@ -2003,6 +2003,35 b' def reposetup(ui, repo):' | |||||
2003 |
|
2003 | |||
2004 | return tagscache |
|
2004 | return tagscache | |
2005 |
|
2005 | |||
|
2006 | def branchtags(self): | |||
|
2007 | if self.branchcache != None: | |||
|
2008 | return self.branchcache | |||
|
2009 | ||||
|
2010 | q = self.mq | |||
|
2011 | if not q.applied: | |||
|
2012 | return super(mqrepo, self).branchtags() | |||
|
2013 | ||||
|
2014 | self.branchcache = {} # avoid recursion in changectx | |||
|
2015 | cl = self.changelog | |||
|
2016 | partial, last, lrev = self._readbranchcache() | |||
|
2017 | ||||
|
2018 | qbase = cl.rev(revlog.bin(q.applied[0].rev)) | |||
|
2019 | start = lrev + 1 | |||
|
2020 | if start < qbase: | |||
|
2021 | # update the cache (excluding the patches) and save it | |||
|
2022 | self._updatebranchcache(partial, lrev+1, qbase) | |||
|
2023 | self._writebranchcache(partial, cl.node(qbase-1), qbase-1) | |||
|
2024 | start = qbase | |||
|
2025 | # if start = qbase, the cache is as updated as it should be. | |||
|
2026 | # if start > qbase, the cache includes (part of) the patches. | |||
|
2027 | # we might as well use it, but we won't save it. | |||
|
2028 | ||||
|
2029 | # update the cache up to the tip | |||
|
2030 | self._updatebranchcache(partial, start, cl.count()) | |||
|
2031 | ||||
|
2032 | self.branchcache = partial | |||
|
2033 | return self.branchcache | |||
|
2034 | ||||
2006 | if repo.local(): |
|
2035 | if repo.local(): | |
2007 | repo.__class__ = mqrepo |
|
2036 | repo.__class__ = mqrepo | |
2008 | repo.mq = queue(ui, repo.join("")) |
|
2037 | repo.mq = queue(ui, repo.join("")) |
General Comments 0
You need to be logged in to leave comments.
Login now