Show More
@@ -17,7 +17,6 b' demandload(globals(), "os revlog time ut' | |||||
17 | class localrepository(repo.repository): |
|
17 | class localrepository(repo.repository): | |
18 | capabilities = ('lookup', 'changegroupsubset') |
|
18 | capabilities = ('lookup', 'changegroupsubset') | |
19 | supported = ('revlogv1', 'store') |
|
19 | supported = ('revlogv1', 'store') | |
20 | branchcache_features = ('default',) |
|
|||
21 |
|
20 | |||
22 | def __del__(self): |
|
21 | def __del__(self): | |
23 | self.transhandle = None |
|
22 | self.transhandle = None | |
@@ -374,25 +373,9 b' class localrepository(repo.repository):' | |||||
374 | def _readbranchcache(self): |
|
373 | def _readbranchcache(self): | |
375 | partial = {} |
|
374 | partial = {} | |
376 | try: |
|
375 | try: | |
377 |
f = self.opener("branch |
|
376 | f = self.opener("branch.cache") | |
378 | lines = f.read().split('\n') |
|
377 | lines = f.read().split('\n') | |
379 | f.close() |
|
378 | f.close() | |
380 | features = lines.pop(0).strip() |
|
|||
381 | if not features.startswith('features: '): |
|
|||
382 | raise ValueError(_('branch cache: no features specified')) |
|
|||
383 | features = features.split(' ', 1)[1].split() |
|
|||
384 | missing_features = [] |
|
|||
385 | for feature in self.branchcache_features: |
|
|||
386 | try: |
|
|||
387 | features.remove(feature) |
|
|||
388 | except ValueError, inst: |
|
|||
389 | missing_features.append(feature) |
|
|||
390 | if missing_features: |
|
|||
391 | raise ValueError(_('branch cache: missing features: %s') |
|
|||
392 | % ', '.join(missing_features)) |
|
|||
393 | if features: |
|
|||
394 | raise ValueError(_('branch cache: unknown features: %s') |
|
|||
395 | % ', '.join(features)) |
|
|||
396 | last, lrev = lines.pop(0).split(" ", 1) |
|
379 | last, lrev = lines.pop(0).split(" ", 1) | |
397 | last, lrev = bin(last), int(lrev) |
|
380 | last, lrev = bin(last), int(lrev) | |
398 | if not (lrev < self.changelog.count() and |
|
381 | if not (lrev < self.changelog.count() and | |
@@ -413,8 +396,7 b' class localrepository(repo.repository):' | |||||
413 |
|
396 | |||
414 | def _writebranchcache(self, branches, tip, tiprev): |
|
397 | def _writebranchcache(self, branches, tip, tiprev): | |
415 | try: |
|
398 | try: | |
416 |
f = self.opener("branch |
|
399 | f = self.opener("branch.cache", "w") | |
417 | f.write(" features: %s\n" % ' '.join(self.branchcache_features)) |
|
|||
418 | f.write("%s %s\n" % (hex(tip), tiprev)) |
|
400 | f.write("%s %s\n" % (hex(tip), tiprev)) | |
419 | for label, node in branches.iteritems(): |
|
401 | for label, node in branches.iteritems(): | |
420 | f.write("%s %s\n" % (hex(node), label)) |
|
402 | f.write("%s %s\n" % (hex(node), label)) |
@@ -5,7 +5,7 b" echo 'hgext.mq=' >> $HGRCPATH" | |||||
5 |
|
5 | |||
6 | show_branch_cache() |
|
6 | show_branch_cache() | |
7 | { |
|
7 | { | |
8 |
branches=.hg/branch |
|
8 | branches=.hg/branch.cache | |
9 | # force cache (re)generation |
|
9 | # force cache (re)generation | |
10 | hg log -r does-not-exist 2> /dev/null |
|
10 | hg log -r does-not-exist 2> /dev/null | |
11 | hg log -r tip --template 'tip: #rev#\n' |
|
11 | hg log -r tip --template 'tip: #rev#\n' | |
@@ -61,7 +61,7 b' show_branch_cache 1' | |||||
61 |
|
61 | |||
62 | echo |
|
62 | echo | |
63 | echo '# removing the cache' |
|
63 | echo '# removing the cache' | |
64 |
rm .hg/branch |
|
64 | rm .hg/branch.cache | |
65 | show_branch_cache 1 |
|
65 | show_branch_cache 1 | |
66 |
|
66 | |||
67 | echo |
|
67 | echo |
@@ -1,13 +1,12 b'' | |||||
1 | # mq patch on an empty repo |
|
1 | # mq patch on an empty repo | |
2 | tip: 0 |
|
2 | tip: 0 | |
3 |
No .hg/branch |
|
3 | No .hg/branch.cache | |
4 | tip: 0 |
|
4 | tip: 0 | |
5 |
No .hg/branch |
|
5 | No .hg/branch.cache | |
6 |
|
6 | |||
7 | # some regular revisions |
|
7 | # some regular revisions | |
8 | Patch queue now empty |
|
8 | Patch queue now empty | |
9 | tip: 1 |
|
9 | tip: 1 | |
10 | features: default |
|
|||
11 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 |
|
10 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 | |
12 | 3f910abad313ff802d3a23a7529433872df9b3ae bar |
|
11 | 3f910abad313ff802d3a23a7529433872df9b3ae bar | |
13 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo |
|
12 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo | |
@@ -16,12 +15,10 b' 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff' | |||||
16 | applying p1 |
|
15 | applying p1 | |
17 | Now at: p1 |
|
16 | Now at: p1 | |
18 | tip: 2 |
|
17 | tip: 2 | |
19 | features: default |
|
|||
20 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 |
|
18 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 | |
21 | 3f910abad313ff802d3a23a7529433872df9b3ae bar |
|
19 | 3f910abad313ff802d3a23a7529433872df9b3ae bar | |
22 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo |
|
20 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo | |
23 | tip: 3 |
|
21 | tip: 3 | |
24 | features: default |
|
|||
25 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 |
|
22 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 | |
26 | 3f910abad313ff802d3a23a7529433872df9b3ae bar |
|
23 | 3f910abad313ff802d3a23a7529433872df9b3ae bar | |
27 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo |
|
24 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo | |
@@ -30,7 +27,6 b' branch bar: 2' | |||||
30 |
|
27 | |||
31 | # removing the cache |
|
28 | # removing the cache | |
32 | tip: 3 |
|
29 | tip: 3 | |
33 | features: default |
|
|||
34 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 |
|
30 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 | |
35 | 3f910abad313ff802d3a23a7529433872df9b3ae bar |
|
31 | 3f910abad313ff802d3a23a7529433872df9b3ae bar | |
36 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo |
|
32 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo | |
@@ -39,7 +35,6 b' branch bar: 2' | |||||
39 |
|
35 | |||
40 | # importing rev 1 (the cache now ends in one of the patches) |
|
36 | # importing rev 1 (the cache now ends in one of the patches) | |
41 | tip: 3 |
|
37 | tip: 3 | |
42 | features: default |
|
|||
43 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 |
|
38 | 3f910abad313ff802d3a23a7529433872df9b3ae 1 | |
44 | 3f910abad313ff802d3a23a7529433872df9b3ae bar |
|
39 | 3f910abad313ff802d3a23a7529433872df9b3ae bar | |
45 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo |
|
40 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo | |
@@ -54,6 +49,5 b' applying p1' | |||||
54 | applying p2 |
|
49 | applying p2 | |
55 | Now at: p2 |
|
50 | Now at: p2 | |
56 | tip: 3 |
|
51 | tip: 3 | |
57 | features: default |
|
|||
58 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0 |
|
52 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0 | |
59 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo |
|
53 | 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo |
@@ -30,39 +30,14 b' hg branches -q' | |||||
30 |
|
30 | |||
31 | echo % test for invalid branch cache |
|
31 | echo % test for invalid branch cache | |
32 | hg rollback |
|
32 | hg rollback | |
33 |
cp .hg/branch |
|
33 | cp .hg/branch.cache .hg/bc-invalid | |
34 | hg log -r foo |
|
34 | hg log -r foo | |
35 |
cp .hg/bc-invalid .hg/branch |
|
35 | cp .hg/bc-invalid .hg/branch.cache | |
36 | hg --debug log -r foo |
|
36 | hg --debug log -r foo | |
37 |
rm .hg/branch |
|
37 | rm .hg/branch.cache | |
38 |
echo corrupted > .hg/branch |
|
38 | echo corrupted > .hg/branch.cache | |
39 | hg log -qr foo |
|
39 | hg log -qr foo | |
40 |
cat .hg/branch |
|
40 | cat .hg/branch.cache | |
41 |
|
||||
42 | echo % test for different branch cache features |
|
|||
43 | echo '4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4' > .hg/branches.cache |
|
|||
44 | hg branches --debug |
|
|||
45 | echo ' features: unnamed dummy foo bar' > .hg/branches.cache |
|
|||
46 | hg branches --debug |
|
|||
47 | echo ' features: dummy' > .hg/branches.cache |
|
|||
48 | hg branches --debug |
|
|||
49 |
|
||||
50 | echo % test old hg reading branch cache with feature list |
|
|||
51 | python << EOF |
|
|||
52 | import binascii |
|
|||
53 | f = file('.hg/branches.cache') |
|
|||
54 | lines = f.read().split('\n') |
|
|||
55 | f.close() |
|
|||
56 | firstline = lines[0] |
|
|||
57 | last, lrev = lines.pop(0).rstrip().split(" ", 1) |
|
|||
58 | try: |
|
|||
59 | last, lrev = binascii.unhexlify(last), int(lrev) |
|
|||
60 | except ValueError, inst: |
|
|||
61 | if str(inst) == "invalid literal for int():%s" % firstline: |
|
|||
62 | print "ValueError raised correctly, good." |
|
|||
63 | else: |
|
|||
64 | print "ValueError: %s" % inst |
|
|||
65 | EOF |
|
|||
66 |
|
41 | |||
67 | echo % update with no arguments: tipmost revision of the current branch |
|
42 | echo % update with no arguments: tipmost revision of the current branch | |
68 | hg up -q -C 0 |
|
43 | hg up -q -C 0 |
@@ -74,26 +74,10 b' modify a branch' | |||||
74 |
|
74 | |||
75 |
|
75 | |||
76 | 4:4909a3732169 |
|
76 | 4:4909a3732169 | |
77 | features: default |
|
|||
78 | 4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4 |
|
77 | 4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4 | |
79 | bf1bc2f45e834c75404d0ddab57d53beab56e2f8 default |
|
78 | bf1bc2f45e834c75404d0ddab57d53beab56e2f8 default | |
80 | 4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo |
|
79 | 4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo | |
81 | 67ec16bde7f1575d523313b9bca000f6a6f12dca bar |
|
80 | 67ec16bde7f1575d523313b9bca000f6a6f12dca bar | |
82 | % test for different branch cache features |
|
|||
83 | branch cache: no features specified |
|
|||
84 | foo 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f |
|
|||
85 | default 3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8 |
|
|||
86 | bar 2:67ec16bde7f1575d523313b9bca000f6a6f12dca |
|
|||
87 | branch cache: missing features: default |
|
|||
88 | foo 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f |
|
|||
89 | default 3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8 |
|
|||
90 | bar 2:67ec16bde7f1575d523313b9bca000f6a6f12dca |
|
|||
91 | branch cache: missing features: default |
|
|||
92 | foo 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f |
|
|||
93 | default 3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8 |
|
|||
94 | bar 2:67ec16bde7f1575d523313b9bca000f6a6f12dca |
|
|||
95 | % test old hg reading branch cache with feature list |
|
|||
96 | ValueError raised correctly, good. |
|
|||
97 | % update with no arguments: tipmost revision of the current branch |
|
81 | % update with no arguments: tipmost revision of the current branch | |
98 | bf1bc2f45e83 |
|
82 | bf1bc2f45e83 | |
99 | 4909a3732169 (foo) tip |
|
83 | 4909a3732169 (foo) tip |
General Comments 0
You need to be logged in to leave comments.
Login now