Show More
@@ -1,523 +1,532 | |||||
1 | # branchmap.py - logic to computes, maintain and stores branchmap for local repo |
|
1 | # branchmap.py - logic to computes, maintain and stores branchmap for local repo | |
2 | # |
|
2 | # | |
3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from __future__ import absolute_import |
|
8 | from __future__ import absolute_import | |
9 |
|
9 | |||
10 | import array |
|
10 | import array | |
11 | import struct |
|
11 | import struct | |
12 | import time |
|
12 | import time | |
13 |
|
13 | |||
14 | from .node import ( |
|
14 | from .node import ( | |
15 | bin, |
|
15 | bin, | |
16 | hex, |
|
16 | hex, | |
17 | nullid, |
|
17 | nullid, | |
18 | nullrev, |
|
18 | nullrev, | |
19 | ) |
|
19 | ) | |
20 | from . import ( |
|
20 | from . import ( | |
21 | encoding, |
|
21 | encoding, | |
22 | error, |
|
22 | error, | |
23 | scmutil, |
|
23 | scmutil, | |
24 | ) |
|
24 | ) | |
25 |
|
25 | |||
26 | array = array.array |
|
26 | array = array.array | |
27 | calcsize = struct.calcsize |
|
27 | calcsize = struct.calcsize | |
28 | pack = struct.pack |
|
28 | pack = struct.pack | |
29 | unpack = struct.unpack |
|
29 | unpack = struct.unpack | |
30 |
|
30 | |||
31 | def _filename(repo): |
|
31 | def _filename(repo): | |
32 | """name of a branchcache file for a given repo or repoview""" |
|
32 | """name of a branchcache file for a given repo or repoview""" | |
33 | filename = "cache/branch2" |
|
33 | filename = "cache/branch2" | |
34 | if repo.filtername: |
|
34 | if repo.filtername: | |
35 | filename = '%s-%s' % (filename, repo.filtername) |
|
35 | filename = '%s-%s' % (filename, repo.filtername) | |
36 | return filename |
|
36 | return filename | |
37 |
|
37 | |||
38 | def read(repo): |
|
38 | def read(repo): | |
39 | try: |
|
39 | try: | |
40 | f = repo.vfs(_filename(repo)) |
|
40 | f = repo.vfs(_filename(repo)) | |
41 | lines = f.read().split('\n') |
|
41 | lines = f.read().split('\n') | |
42 | f.close() |
|
42 | f.close() | |
43 | except (IOError, OSError): |
|
43 | except (IOError, OSError): | |
44 | return None |
|
44 | return None | |
45 |
|
45 | |||
46 | try: |
|
46 | try: | |
47 | cachekey = lines.pop(0).split(" ", 2) |
|
47 | cachekey = lines.pop(0).split(" ", 2) | |
48 | last, lrev = cachekey[:2] |
|
48 | last, lrev = cachekey[:2] | |
49 | last, lrev = bin(last), int(lrev) |
|
49 | last, lrev = bin(last), int(lrev) | |
50 | filteredhash = None |
|
50 | filteredhash = None | |
51 | if len(cachekey) > 2: |
|
51 | if len(cachekey) > 2: | |
52 | filteredhash = bin(cachekey[2]) |
|
52 | filteredhash = bin(cachekey[2]) | |
53 | partial = branchcache(tipnode=last, tiprev=lrev, |
|
53 | partial = branchcache(tipnode=last, tiprev=lrev, | |
54 | filteredhash=filteredhash) |
|
54 | filteredhash=filteredhash) | |
55 | if not partial.validfor(repo): |
|
55 | if not partial.validfor(repo): | |
56 | # invalidate the cache |
|
56 | # invalidate the cache | |
57 | raise ValueError('tip differs') |
|
57 | raise ValueError('tip differs') | |
58 | cl = repo.changelog |
|
58 | cl = repo.changelog | |
59 | for l in lines: |
|
59 | for l in lines: | |
60 | if not l: |
|
60 | if not l: | |
61 | continue |
|
61 | continue | |
62 | node, state, label = l.split(" ", 2) |
|
62 | node, state, label = l.split(" ", 2) | |
63 | if state not in 'oc': |
|
63 | if state not in 'oc': | |
64 | raise ValueError('invalid branch state') |
|
64 | raise ValueError('invalid branch state') | |
65 | label = encoding.tolocal(label.strip()) |
|
65 | label = encoding.tolocal(label.strip()) | |
66 | node = bin(node) |
|
66 | node = bin(node) | |
67 | if not cl.hasnode(node): |
|
67 | if not cl.hasnode(node): | |
68 | raise ValueError('node %s does not exist' % hex(node)) |
|
68 | raise ValueError('node %s does not exist' % hex(node)) | |
69 | partial.setdefault(label, []).append(node) |
|
69 | partial.setdefault(label, []).append(node) | |
70 | if state == 'c': |
|
70 | if state == 'c': | |
71 | partial._closednodes.add(node) |
|
71 | partial._closednodes.add(node) | |
72 | except KeyboardInterrupt: |
|
72 | except KeyboardInterrupt: | |
73 | raise |
|
73 | raise | |
74 | except Exception as inst: |
|
74 | except Exception as inst: | |
75 | if repo.ui.debugflag: |
|
75 | if repo.ui.debugflag: | |
76 | msg = 'invalid branchheads cache' |
|
76 | msg = 'invalid branchheads cache' | |
77 | if repo.filtername is not None: |
|
77 | if repo.filtername is not None: | |
78 | msg += ' (%s)' % repo.filtername |
|
78 | msg += ' (%s)' % repo.filtername | |
79 | msg += ': %s\n' |
|
79 | msg += ': %s\n' | |
80 | repo.ui.debug(msg % inst) |
|
80 | repo.ui.debug(msg % inst) | |
81 | partial = None |
|
81 | partial = None | |
82 | return partial |
|
82 | return partial | |
83 |
|
83 | |||
84 | ### Nearest subset relation |
|
84 | ### Nearest subset relation | |
85 | # Nearest subset of filter X is a filter Y so that: |
|
85 | # Nearest subset of filter X is a filter Y so that: | |
86 | # * Y is included in X, |
|
86 | # * Y is included in X, | |
87 | # * X - Y is as small as possible. |
|
87 | # * X - Y is as small as possible. | |
88 | # This create and ordering used for branchmap purpose. |
|
88 | # This create and ordering used for branchmap purpose. | |
89 | # the ordering may be partial |
|
89 | # the ordering may be partial | |
90 | subsettable = {None: 'visible', |
|
90 | subsettable = {None: 'visible', | |
91 | 'visible': 'served', |
|
91 | 'visible': 'served', | |
92 | 'served': 'immutable', |
|
92 | 'served': 'immutable', | |
93 | 'immutable': 'base'} |
|
93 | 'immutable': 'base'} | |
94 |
|
94 | |||
95 | def updatecache(repo): |
|
95 | def updatecache(repo): | |
96 | cl = repo.changelog |
|
96 | cl = repo.changelog | |
97 | filtername = repo.filtername |
|
97 | filtername = repo.filtername | |
98 | partial = repo._branchcaches.get(filtername) |
|
98 | partial = repo._branchcaches.get(filtername) | |
99 |
|
99 | |||
100 | revs = [] |
|
100 | revs = [] | |
101 | if partial is None or not partial.validfor(repo): |
|
101 | if partial is None or not partial.validfor(repo): | |
102 | partial = read(repo) |
|
102 | partial = read(repo) | |
103 | if partial is None: |
|
103 | if partial is None: | |
104 | subsetname = subsettable.get(filtername) |
|
104 | subsetname = subsettable.get(filtername) | |
105 | if subsetname is None: |
|
105 | if subsetname is None: | |
106 | partial = branchcache() |
|
106 | partial = branchcache() | |
107 | else: |
|
107 | else: | |
108 | subset = repo.filtered(subsetname) |
|
108 | subset = repo.filtered(subsetname) | |
109 | partial = subset.branchmap().copy() |
|
109 | partial = subset.branchmap().copy() | |
110 | extrarevs = subset.changelog.filteredrevs - cl.filteredrevs |
|
110 | extrarevs = subset.changelog.filteredrevs - cl.filteredrevs | |
111 | revs.extend(r for r in extrarevs if r <= partial.tiprev) |
|
111 | revs.extend(r for r in extrarevs if r <= partial.tiprev) | |
112 | revs.extend(cl.revs(start=partial.tiprev + 1)) |
|
112 | revs.extend(cl.revs(start=partial.tiprev + 1)) | |
113 | if revs: |
|
113 | if revs: | |
114 | partial.update(repo, revs) |
|
114 | partial.update(repo, revs) | |
115 | partial.write(repo) |
|
115 | partial.write(repo) | |
116 |
|
116 | |||
117 | assert partial.validfor(repo), filtername |
|
117 | assert partial.validfor(repo), filtername | |
118 | repo._branchcaches[repo.filtername] = partial |
|
118 | repo._branchcaches[repo.filtername] = partial | |
119 |
|
119 | |||
120 | def replacecache(repo, bm): |
|
120 | def replacecache(repo, bm): | |
121 | """Replace the branchmap cache for a repo with a branch mapping. |
|
121 | """Replace the branchmap cache for a repo with a branch mapping. | |
122 |
|
122 | |||
123 | This is likely only called during clone with a branch map from a remote. |
|
123 | This is likely only called during clone with a branch map from a remote. | |
124 | """ |
|
124 | """ | |
125 | rbheads = [] |
|
125 | rbheads = [] | |
126 | closed = [] |
|
126 | closed = [] | |
127 | for bheads in bm.itervalues(): |
|
127 | for bheads in bm.itervalues(): | |
128 | rbheads.extend(bheads) |
|
128 | rbheads.extend(bheads) | |
129 | for h in bheads: |
|
129 | for h in bheads: | |
130 | r = repo.changelog.rev(h) |
|
130 | r = repo.changelog.rev(h) | |
131 | b, c = repo.changelog.branchinfo(r) |
|
131 | b, c = repo.changelog.branchinfo(r) | |
132 | if c: |
|
132 | if c: | |
133 | closed.append(h) |
|
133 | closed.append(h) | |
134 |
|
134 | |||
135 | if rbheads: |
|
135 | if rbheads: | |
136 | rtiprev = max((int(repo.changelog.rev(node)) |
|
136 | rtiprev = max((int(repo.changelog.rev(node)) | |
137 | for node in rbheads)) |
|
137 | for node in rbheads)) | |
138 | cache = branchcache(bm, |
|
138 | cache = branchcache(bm, | |
139 | repo[rtiprev].node(), |
|
139 | repo[rtiprev].node(), | |
140 | rtiprev, |
|
140 | rtiprev, | |
141 | closednodes=closed) |
|
141 | closednodes=closed) | |
142 |
|
142 | |||
143 | # Try to stick it as low as possible |
|
143 | # Try to stick it as low as possible | |
144 | # filter above served are unlikely to be fetch from a clone |
|
144 | # filter above served are unlikely to be fetch from a clone | |
145 | for candidate in ('base', 'immutable', 'served'): |
|
145 | for candidate in ('base', 'immutable', 'served'): | |
146 | rview = repo.filtered(candidate) |
|
146 | rview = repo.filtered(candidate) | |
147 | if cache.validfor(rview): |
|
147 | if cache.validfor(rview): | |
148 | repo._branchcaches[candidate] = cache |
|
148 | repo._branchcaches[candidate] = cache | |
149 | cache.write(rview) |
|
149 | cache.write(rview) | |
150 | break |
|
150 | break | |
151 |
|
151 | |||
152 | class branchcache(dict): |
|
152 | class branchcache(dict): | |
153 | """A dict like object that hold branches heads cache. |
|
153 | """A dict like object that hold branches heads cache. | |
154 |
|
154 | |||
155 | This cache is used to avoid costly computations to determine all the |
|
155 | This cache is used to avoid costly computations to determine all the | |
156 | branch heads of a repo. |
|
156 | branch heads of a repo. | |
157 |
|
157 | |||
158 | The cache is serialized on disk in the following format: |
|
158 | The cache is serialized on disk in the following format: | |
159 |
|
159 | |||
160 | <tip hex node> <tip rev number> [optional filtered repo hex hash] |
|
160 | <tip hex node> <tip rev number> [optional filtered repo hex hash] | |
161 | <branch head hex node> <open/closed state> <branch name> |
|
161 | <branch head hex node> <open/closed state> <branch name> | |
162 | <branch head hex node> <open/closed state> <branch name> |
|
162 | <branch head hex node> <open/closed state> <branch name> | |
163 | ... |
|
163 | ... | |
164 |
|
164 | |||
165 | The first line is used to check if the cache is still valid. If the |
|
165 | The first line is used to check if the cache is still valid. If the | |
166 | branch cache is for a filtered repo view, an optional third hash is |
|
166 | branch cache is for a filtered repo view, an optional third hash is | |
167 | included that hashes the hashes of all filtered revisions. |
|
167 | included that hashes the hashes of all filtered revisions. | |
168 |
|
168 | |||
169 | The open/closed state is represented by a single letter 'o' or 'c'. |
|
169 | The open/closed state is represented by a single letter 'o' or 'c'. | |
170 | This field can be used to avoid changelog reads when determining if a |
|
170 | This field can be used to avoid changelog reads when determining if a | |
171 | branch head closes a branch or not. |
|
171 | branch head closes a branch or not. | |
172 | """ |
|
172 | """ | |
173 |
|
173 | |||
174 | def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev, |
|
174 | def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev, | |
175 | filteredhash=None, closednodes=None): |
|
175 | filteredhash=None, closednodes=None): | |
176 | super(branchcache, self).__init__(entries) |
|
176 | super(branchcache, self).__init__(entries) | |
177 | self.tipnode = tipnode |
|
177 | self.tipnode = tipnode | |
178 | self.tiprev = tiprev |
|
178 | self.tiprev = tiprev | |
179 | self.filteredhash = filteredhash |
|
179 | self.filteredhash = filteredhash | |
180 | # closednodes is a set of nodes that close their branch. If the branch |
|
180 | # closednodes is a set of nodes that close their branch. If the branch | |
181 | # cache has been updated, it may contain nodes that are no longer |
|
181 | # cache has been updated, it may contain nodes that are no longer | |
182 | # heads. |
|
182 | # heads. | |
183 | if closednodes is None: |
|
183 | if closednodes is None: | |
184 | self._closednodes = set() |
|
184 | self._closednodes = set() | |
185 | else: |
|
185 | else: | |
186 | self._closednodes = closednodes |
|
186 | self._closednodes = closednodes | |
187 |
|
187 | |||
188 | def validfor(self, repo): |
|
188 | def validfor(self, repo): | |
189 | """Is the cache content valid regarding a repo |
|
189 | """Is the cache content valid regarding a repo | |
190 |
|
190 | |||
191 | - False when cached tipnode is unknown or if we detect a strip. |
|
191 | - False when cached tipnode is unknown or if we detect a strip. | |
192 | - True when cache is up to date or a subset of current repo.""" |
|
192 | - True when cache is up to date or a subset of current repo.""" | |
193 | try: |
|
193 | try: | |
194 | return ((self.tipnode == repo.changelog.node(self.tiprev)) |
|
194 | return ((self.tipnode == repo.changelog.node(self.tiprev)) | |
195 | and (self.filteredhash == \ |
|
195 | and (self.filteredhash == \ | |
196 | scmutil.filteredhash(repo, self.tiprev))) |
|
196 | scmutil.filteredhash(repo, self.tiprev))) | |
197 | except IndexError: |
|
197 | except IndexError: | |
198 | return False |
|
198 | return False | |
199 |
|
199 | |||
200 | def _branchtip(self, heads): |
|
200 | def _branchtip(self, heads): | |
201 | '''Return tuple with last open head in heads and false, |
|
201 | '''Return tuple with last open head in heads and false, | |
202 | otherwise return last closed head and true.''' |
|
202 | otherwise return last closed head and true.''' | |
203 | tip = heads[-1] |
|
203 | tip = heads[-1] | |
204 | closed = True |
|
204 | closed = True | |
205 | for h in reversed(heads): |
|
205 | for h in reversed(heads): | |
206 | if h not in self._closednodes: |
|
206 | if h not in self._closednodes: | |
207 | tip = h |
|
207 | tip = h | |
208 | closed = False |
|
208 | closed = False | |
209 | break |
|
209 | break | |
210 | return tip, closed |
|
210 | return tip, closed | |
211 |
|
211 | |||
212 | def branchtip(self, branch): |
|
212 | def branchtip(self, branch): | |
213 | '''Return the tipmost open head on branch head, otherwise return the |
|
213 | '''Return the tipmost open head on branch head, otherwise return the | |
214 | tipmost closed head on branch. |
|
214 | tipmost closed head on branch. | |
215 | Raise KeyError for unknown branch.''' |
|
215 | Raise KeyError for unknown branch.''' | |
216 | return self._branchtip(self[branch])[0] |
|
216 | return self._branchtip(self[branch])[0] | |
217 |
|
217 | |||
218 | def branchheads(self, branch, closed=False): |
|
218 | def branchheads(self, branch, closed=False): | |
219 | heads = self[branch] |
|
219 | heads = self[branch] | |
220 | if not closed: |
|
220 | if not closed: | |
221 | heads = [h for h in heads if h not in self._closednodes] |
|
221 | heads = [h for h in heads if h not in self._closednodes] | |
222 | return heads |
|
222 | return heads | |
223 |
|
223 | |||
224 | def iterbranches(self): |
|
224 | def iterbranches(self): | |
225 | for bn, heads in self.iteritems(): |
|
225 | for bn, heads in self.iteritems(): | |
226 | yield (bn, heads) + self._branchtip(heads) |
|
226 | yield (bn, heads) + self._branchtip(heads) | |
227 |
|
227 | |||
228 | def copy(self): |
|
228 | def copy(self): | |
229 | """return an deep copy of the branchcache object""" |
|
229 | """return an deep copy of the branchcache object""" | |
230 | return branchcache(self, self.tipnode, self.tiprev, self.filteredhash, |
|
230 | return branchcache(self, self.tipnode, self.tiprev, self.filteredhash, | |
231 | self._closednodes) |
|
231 | self._closednodes) | |
232 |
|
232 | |||
233 | def write(self, repo): |
|
233 | def write(self, repo): | |
234 | try: |
|
234 | try: | |
235 | f = repo.vfs(_filename(repo), "w", atomictemp=True) |
|
235 | f = repo.vfs(_filename(repo), "w", atomictemp=True) | |
236 | cachekey = [hex(self.tipnode), str(self.tiprev)] |
|
236 | cachekey = [hex(self.tipnode), str(self.tiprev)] | |
237 | if self.filteredhash is not None: |
|
237 | if self.filteredhash is not None: | |
238 | cachekey.append(hex(self.filteredhash)) |
|
238 | cachekey.append(hex(self.filteredhash)) | |
239 | f.write(" ".join(cachekey) + '\n') |
|
239 | f.write(" ".join(cachekey) + '\n') | |
240 | nodecount = 0 |
|
240 | nodecount = 0 | |
241 | for label, nodes in sorted(self.iteritems()): |
|
241 | for label, nodes in sorted(self.iteritems()): | |
242 | for node in nodes: |
|
242 | for node in nodes: | |
243 | nodecount += 1 |
|
243 | nodecount += 1 | |
244 | if node in self._closednodes: |
|
244 | if node in self._closednodes: | |
245 | state = 'c' |
|
245 | state = 'c' | |
246 | else: |
|
246 | else: | |
247 | state = 'o' |
|
247 | state = 'o' | |
248 | f.write("%s %s %s\n" % (hex(node), state, |
|
248 | f.write("%s %s %s\n" % (hex(node), state, | |
249 | encoding.fromlocal(label))) |
|
249 | encoding.fromlocal(label))) | |
250 | f.close() |
|
250 | f.close() | |
251 | repo.ui.log('branchcache', |
|
251 | repo.ui.log('branchcache', | |
252 | 'wrote %s branch cache with %d labels and %d nodes\n', |
|
252 | 'wrote %s branch cache with %d labels and %d nodes\n', | |
253 | repo.filtername, len(self), nodecount) |
|
253 | repo.filtername, len(self), nodecount) | |
254 | except (IOError, OSError, error.Abort) as inst: |
|
254 | except (IOError, OSError, error.Abort) as inst: | |
255 | repo.ui.debug("couldn't write branch cache: %s\n" % inst) |
|
255 | repo.ui.debug("couldn't write branch cache: %s\n" % inst) | |
256 | # Abort may be raise by read only opener |
|
256 | # Abort may be raise by read only opener | |
257 | pass |
|
257 | pass | |
258 |
|
258 | |||
259 | def update(self, repo, revgen): |
|
259 | def update(self, repo, revgen): | |
260 | """Given a branchhead cache, self, that may have extra nodes or be |
|
260 | """Given a branchhead cache, self, that may have extra nodes or be | |
261 | missing heads, and a generator of nodes that are strictly a superset of |
|
261 | missing heads, and a generator of nodes that are strictly a superset of | |
262 | heads missing, this function updates self to be correct. |
|
262 | heads missing, this function updates self to be correct. | |
263 | """ |
|
263 | """ | |
264 | starttime = time.time() |
|
264 | starttime = time.time() | |
265 | cl = repo.changelog |
|
265 | cl = repo.changelog | |
266 | # collect new branch entries |
|
266 | # collect new branch entries | |
267 | newbranches = {} |
|
267 | newbranches = {} | |
268 | getbranchinfo = repo.revbranchcache().branchinfo |
|
268 | getbranchinfo = repo.revbranchcache().branchinfo | |
269 | for r in revgen: |
|
269 | for r in revgen: | |
270 | branch, closesbranch = getbranchinfo(r) |
|
270 | branch, closesbranch = getbranchinfo(r) | |
271 | newbranches.setdefault(branch, []).append(r) |
|
271 | newbranches.setdefault(branch, []).append(r) | |
272 | if closesbranch: |
|
272 | if closesbranch: | |
273 | self._closednodes.add(cl.node(r)) |
|
273 | self._closednodes.add(cl.node(r)) | |
274 |
|
274 | |||
275 | # fetch current topological heads to speed up filtering |
|
275 | # fetch current topological heads to speed up filtering | |
276 | topoheads = set(cl.headrevs()) |
|
276 | topoheads = set(cl.headrevs()) | |
277 |
|
277 | |||
278 | # if older branchheads are reachable from new ones, they aren't |
|
278 | # if older branchheads are reachable from new ones, they aren't | |
279 | # really branchheads. Note checking parents is insufficient: |
|
279 | # really branchheads. Note checking parents is insufficient: | |
280 | # 1 (branch a) -> 2 (branch b) -> 3 (branch a) |
|
280 | # 1 (branch a) -> 2 (branch b) -> 3 (branch a) | |
281 | for branch, newheadrevs in newbranches.iteritems(): |
|
281 | for branch, newheadrevs in newbranches.iteritems(): | |
282 | bheads = self.setdefault(branch, []) |
|
282 | bheads = self.setdefault(branch, []) | |
283 | bheadset = set(cl.rev(node) for node in bheads) |
|
283 | bheadset = set(cl.rev(node) for node in bheads) | |
284 |
|
284 | |||
285 | # This have been tested True on all internal usage of this function. |
|
285 | # This have been tested True on all internal usage of this function. | |
286 | # run it again in case of doubt |
|
286 | # run it again in case of doubt | |
287 | # assert not (set(bheadrevs) & set(newheadrevs)) |
|
287 | # assert not (set(bheadrevs) & set(newheadrevs)) | |
288 | newheadrevs.sort() |
|
288 | newheadrevs.sort() | |
289 | bheadset.update(newheadrevs) |
|
289 | bheadset.update(newheadrevs) | |
290 |
|
290 | |||
291 | # This prunes out two kinds of heads - heads that are superseded by |
|
291 | # This prunes out two kinds of heads - heads that are superseded by | |
292 | # a head in newheadrevs, and newheadrevs that are not heads because |
|
292 | # a head in newheadrevs, and newheadrevs that are not heads because | |
293 | # an existing head is their descendant. |
|
293 | # an existing head is their descendant. | |
294 | uncertain = bheadset - topoheads |
|
294 | uncertain = bheadset - topoheads | |
295 | if uncertain: |
|
295 | if uncertain: | |
296 | floorrev = min(uncertain) |
|
296 | floorrev = min(uncertain) | |
297 | ancestors = set(cl.ancestors(newheadrevs, floorrev)) |
|
297 | ancestors = set(cl.ancestors(newheadrevs, floorrev)) | |
298 | bheadset -= ancestors |
|
298 | bheadset -= ancestors | |
299 | bheadrevs = sorted(bheadset) |
|
299 | bheadrevs = sorted(bheadset) | |
300 | self[branch] = [cl.node(rev) for rev in bheadrevs] |
|
300 | self[branch] = [cl.node(rev) for rev in bheadrevs] | |
301 | tiprev = bheadrevs[-1] |
|
301 | tiprev = bheadrevs[-1] | |
302 | if tiprev > self.tiprev: |
|
302 | if tiprev > self.tiprev: | |
303 | self.tipnode = cl.node(tiprev) |
|
303 | self.tipnode = cl.node(tiprev) | |
304 | self.tiprev = tiprev |
|
304 | self.tiprev = tiprev | |
305 |
|
305 | |||
306 | if not self.validfor(repo): |
|
306 | if not self.validfor(repo): | |
307 | # cache key are not valid anymore |
|
307 | # cache key are not valid anymore | |
308 | self.tipnode = nullid |
|
308 | self.tipnode = nullid | |
309 | self.tiprev = nullrev |
|
309 | self.tiprev = nullrev | |
310 | for heads in self.values(): |
|
310 | for heads in self.values(): | |
311 | tiprev = max(cl.rev(node) for node in heads) |
|
311 | tiprev = max(cl.rev(node) for node in heads) | |
312 | if tiprev > self.tiprev: |
|
312 | if tiprev > self.tiprev: | |
313 | self.tipnode = cl.node(tiprev) |
|
313 | self.tipnode = cl.node(tiprev) | |
314 | self.tiprev = tiprev |
|
314 | self.tiprev = tiprev | |
315 | self.filteredhash = scmutil.filteredhash(repo, self.tiprev) |
|
315 | self.filteredhash = scmutil.filteredhash(repo, self.tiprev) | |
316 |
|
316 | |||
317 | duration = time.time() - starttime |
|
317 | duration = time.time() - starttime | |
318 | repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n', |
|
318 | repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n', | |
319 | repo.filtername, duration) |
|
319 | repo.filtername, duration) | |
320 |
|
320 | |||
321 | # Revision branch info cache |
|
321 | # Revision branch info cache | |
322 |
|
322 | |||
323 | _rbcversion = '-v1' |
|
323 | _rbcversion = '-v1' | |
324 | _rbcnames = 'cache/rbc-names' + _rbcversion |
|
324 | _rbcnames = 'cache/rbc-names' + _rbcversion | |
325 | _rbcrevs = 'cache/rbc-revs' + _rbcversion |
|
325 | _rbcrevs = 'cache/rbc-revs' + _rbcversion | |
326 | # [4 byte hash prefix][4 byte branch name number with sign bit indicating open] |
|
326 | # [4 byte hash prefix][4 byte branch name number with sign bit indicating open] | |
327 | _rbcrecfmt = '>4sI' |
|
327 | _rbcrecfmt = '>4sI' | |
328 | _rbcrecsize = calcsize(_rbcrecfmt) |
|
328 | _rbcrecsize = calcsize(_rbcrecfmt) | |
329 | _rbcnodelen = 4 |
|
329 | _rbcnodelen = 4 | |
330 | _rbcbranchidxmask = 0x7fffffff |
|
330 | _rbcbranchidxmask = 0x7fffffff | |
331 | _rbccloseflag = 0x80000000 |
|
331 | _rbccloseflag = 0x80000000 | |
332 |
|
332 | |||
333 | class revbranchcache(object): |
|
333 | class revbranchcache(object): | |
334 | """Persistent cache, mapping from revision number to branch name and close. |
|
334 | """Persistent cache, mapping from revision number to branch name and close. | |
335 | This is a low level cache, independent of filtering. |
|
335 | This is a low level cache, independent of filtering. | |
336 |
|
336 | |||
337 | Branch names are stored in rbc-names in internal encoding separated by 0. |
|
337 | Branch names are stored in rbc-names in internal encoding separated by 0. | |
338 | rbc-names is append-only, and each branch name is only stored once and will |
|
338 | rbc-names is append-only, and each branch name is only stored once and will | |
339 | thus have a unique index. |
|
339 | thus have a unique index. | |
340 |
|
340 | |||
341 | The branch info for each revision is stored in rbc-revs as constant size |
|
341 | The branch info for each revision is stored in rbc-revs as constant size | |
342 | records. The whole file is read into memory, but it is only 'parsed' on |
|
342 | records. The whole file is read into memory, but it is only 'parsed' on | |
343 | demand. The file is usually append-only but will be truncated if repo |
|
343 | demand. The file is usually append-only but will be truncated if repo | |
344 | modification is detected. |
|
344 | modification is detected. | |
345 | The record for each revision contains the first 4 bytes of the |
|
345 | The record for each revision contains the first 4 bytes of the | |
346 | corresponding node hash, and the record is only used if it still matches. |
|
346 | corresponding node hash, and the record is only used if it still matches. | |
347 | Even a completely trashed rbc-revs fill thus still give the right result |
|
347 | Even a completely trashed rbc-revs fill thus still give the right result | |
348 | while converging towards full recovery ... assuming no incorrectly matching |
|
348 | while converging towards full recovery ... assuming no incorrectly matching | |
349 | node hashes. |
|
349 | node hashes. | |
350 | The record also contains 4 bytes where 31 bits contains the index of the |
|
350 | The record also contains 4 bytes where 31 bits contains the index of the | |
351 | branch and the last bit indicate that it is a branch close commit. |
|
351 | branch and the last bit indicate that it is a branch close commit. | |
352 | The usage pattern for rbc-revs is thus somewhat similar to 00changelog.i |
|
352 | The usage pattern for rbc-revs is thus somewhat similar to 00changelog.i | |
353 | and will grow with it but be 1/8th of its size. |
|
353 | and will grow with it but be 1/8th of its size. | |
354 | """ |
|
354 | """ | |
355 |
|
355 | |||
356 | def __init__(self, repo, readonly=True): |
|
356 | def __init__(self, repo, readonly=True): | |
357 | assert repo.filtername is None |
|
357 | assert repo.filtername is None | |
358 | self._repo = repo |
|
358 | self._repo = repo | |
359 | self._names = [] # branch names in local encoding with static index |
|
359 | self._names = [] # branch names in local encoding with static index | |
360 | self._rbcrevs = array('c') # structs of type _rbcrecfmt |
|
360 | self._rbcrevs = array('c') # structs of type _rbcrecfmt | |
361 | self._rbcsnameslen = 0 # length of names read at _rbcsnameslen |
|
361 | self._rbcsnameslen = 0 # length of names read at _rbcsnameslen | |
362 | try: |
|
362 | try: | |
363 | bndata = repo.vfs.read(_rbcnames) |
|
363 | bndata = repo.vfs.read(_rbcnames) | |
364 | self._rbcsnameslen = len(bndata) # for verification before writing |
|
364 | self._rbcsnameslen = len(bndata) # for verification before writing | |
365 | self._names = [encoding.tolocal(bn) for bn in bndata.split('\0')] |
|
365 | self._names = [encoding.tolocal(bn) for bn in bndata.split('\0')] | |
366 | except (IOError, OSError): |
|
366 | except (IOError, OSError): | |
367 | if readonly: |
|
367 | if readonly: | |
368 | # don't try to use cache - fall back to the slow path |
|
368 | # don't try to use cache - fall back to the slow path | |
369 | self.branchinfo = self._branchinfo |
|
369 | self.branchinfo = self._branchinfo | |
370 |
|
370 | |||
371 | if self._names: |
|
371 | if self._names: | |
372 | try: |
|
372 | try: | |
373 | data = repo.vfs.read(_rbcrevs) |
|
373 | data = repo.vfs.read(_rbcrevs) | |
374 | self._rbcrevs.fromstring(data) |
|
374 | self._rbcrevs.fromstring(data) | |
375 | except (IOError, OSError) as inst: |
|
375 | except (IOError, OSError) as inst: | |
376 | repo.ui.debug("couldn't read revision branch cache: %s\n" % |
|
376 | repo.ui.debug("couldn't read revision branch cache: %s\n" % | |
377 | inst) |
|
377 | inst) | |
378 | # remember number of good records on disk |
|
378 | # remember number of good records on disk | |
379 | self._rbcrevslen = min(len(self._rbcrevs) // _rbcrecsize, |
|
379 | self._rbcrevslen = min(len(self._rbcrevs) // _rbcrecsize, | |
380 | len(repo.changelog)) |
|
380 | len(repo.changelog)) | |
381 | if self._rbcrevslen == 0: |
|
381 | if self._rbcrevslen == 0: | |
382 | self._names = [] |
|
382 | self._names = [] | |
383 | self._rbcnamescount = len(self._names) # number of names read at |
|
383 | self._rbcnamescount = len(self._names) # number of names read at | |
384 | # _rbcsnameslen |
|
384 | # _rbcsnameslen | |
385 | self._namesreverse = dict((b, r) for r, b in enumerate(self._names)) |
|
385 | self._namesreverse = dict((b, r) for r, b in enumerate(self._names)) | |
386 |
|
386 | |||
387 | def _clear(self): |
|
387 | def _clear(self): | |
388 | self._rbcsnameslen = 0 |
|
388 | self._rbcsnameslen = 0 | |
389 | del self._names[:] |
|
389 | del self._names[:] | |
390 | self._rbcnamescount = 0 |
|
390 | self._rbcnamescount = 0 | |
391 | self._namesreverse.clear() |
|
391 | self._namesreverse.clear() | |
392 | self._rbcrevslen = len(self._repo.changelog) |
|
392 | self._rbcrevslen = len(self._repo.changelog) | |
393 | self._rbcrevs = array('c') |
|
393 | self._rbcrevs = array('c') | |
394 | self._rbcrevs.fromstring('\0' * (self._rbcrevslen * _rbcrecsize)) |
|
394 | self._rbcrevs.fromstring('\0' * (self._rbcrevslen * _rbcrecsize)) | |
395 |
|
395 | |||
396 | def branchinfo(self, rev): |
|
396 | def branchinfo(self, rev): | |
397 | """Return branch name and close flag for rev, using and updating |
|
397 | """Return branch name and close flag for rev, using and updating | |
398 | persistent cache.""" |
|
398 | persistent cache.""" | |
399 | changelog = self._repo.changelog |
|
399 | changelog = self._repo.changelog | |
400 | rbcrevidx = rev * _rbcrecsize |
|
400 | rbcrevidx = rev * _rbcrecsize | |
401 |
|
401 | |||
402 | # avoid negative index, changelog.read(nullrev) is fast without cache |
|
402 | # avoid negative index, changelog.read(nullrev) is fast without cache | |
403 | if rev == nullrev: |
|
403 | if rev == nullrev: | |
404 | return changelog.branchinfo(rev) |
|
404 | return changelog.branchinfo(rev) | |
405 |
|
405 | |||
406 | # if requested rev isn't allocated, grow and cache the rev info |
|
406 | # if requested rev isn't allocated, grow and cache the rev info | |
407 | if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: |
|
407 | if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: | |
408 | return self._branchinfo(rev) |
|
408 | return self._branchinfo(rev) | |
409 |
|
409 | |||
410 | # fast path: extract data from cache, use it if node is matching |
|
410 | # fast path: extract data from cache, use it if node is matching | |
411 | reponode = changelog.node(rev)[:_rbcnodelen] |
|
411 | reponode = changelog.node(rev)[:_rbcnodelen] | |
412 | cachenode, branchidx = unpack( |
|
412 | cachenode, branchidx = unpack( | |
413 | _rbcrecfmt, buffer(self._rbcrevs, rbcrevidx, _rbcrecsize)) |
|
413 | _rbcrecfmt, buffer(self._rbcrevs, rbcrevidx, _rbcrecsize)) | |
414 | close = bool(branchidx & _rbccloseflag) |
|
414 | close = bool(branchidx & _rbccloseflag) | |
415 | if close: |
|
415 | if close: | |
416 | branchidx &= _rbcbranchidxmask |
|
416 | branchidx &= _rbcbranchidxmask | |
417 | if cachenode == '\0\0\0\0': |
|
417 | if cachenode == '\0\0\0\0': | |
418 | pass |
|
418 | pass | |
419 | elif cachenode == reponode: |
|
419 | elif cachenode == reponode: | |
420 | try: |
|
420 | try: | |
421 | return self._names[branchidx], close |
|
421 | return self._names[branchidx], close | |
422 | except IndexError: |
|
422 | except IndexError: | |
423 | # recover from invalid reference to unknown branch |
|
423 | # recover from invalid reference to unknown branch | |
424 | self._repo.ui.debug("referenced branch names not found" |
|
424 | self._repo.ui.debug("referenced branch names not found" | |
425 | " - rebuilding revision branch cache from scratch\n") |
|
425 | " - rebuilding revision branch cache from scratch\n") | |
426 | self._clear() |
|
426 | self._clear() | |
427 | else: |
|
427 | else: | |
428 | # rev/node map has changed, invalidate the cache from here up |
|
428 | # rev/node map has changed, invalidate the cache from here up | |
429 | self._repo.ui.debug("history modification detected - truncating " |
|
429 | self._repo.ui.debug("history modification detected - truncating " | |
430 | "revision branch cache to revision %s\n" % rev) |
|
430 | "revision branch cache to revision %s\n" % rev) | |
431 | truncate = rbcrevidx + _rbcrecsize |
|
431 | truncate = rbcrevidx + _rbcrecsize | |
432 | del self._rbcrevs[truncate:] |
|
432 | del self._rbcrevs[truncate:] | |
433 | self._rbcrevslen = min(self._rbcrevslen, truncate) |
|
433 | self._rbcrevslen = min(self._rbcrevslen, truncate) | |
434 |
|
434 | |||
435 | # fall back to slow path and make sure it will be written to disk |
|
435 | # fall back to slow path and make sure it will be written to disk | |
436 | return self._branchinfo(rev) |
|
436 | return self._branchinfo(rev) | |
437 |
|
437 | |||
438 | def _branchinfo(self, rev): |
|
438 | def _branchinfo(self, rev): | |
439 | """Retrieve branch info from changelog and update _rbcrevs""" |
|
439 | """Retrieve branch info from changelog and update _rbcrevs""" | |
440 | changelog = self._repo.changelog |
|
440 | changelog = self._repo.changelog | |
441 | b, close = changelog.branchinfo(rev) |
|
441 | b, close = changelog.branchinfo(rev) | |
442 | if b in self._namesreverse: |
|
442 | if b in self._namesreverse: | |
443 | branchidx = self._namesreverse[b] |
|
443 | branchidx = self._namesreverse[b] | |
444 | else: |
|
444 | else: | |
445 | branchidx = len(self._names) |
|
445 | branchidx = len(self._names) | |
446 | self._names.append(b) |
|
446 | self._names.append(b) | |
447 | self._namesreverse[b] = branchidx |
|
447 | self._namesreverse[b] = branchidx | |
448 | reponode = changelog.node(rev) |
|
448 | reponode = changelog.node(rev) | |
449 | if close: |
|
449 | if close: | |
450 | branchidx |= _rbccloseflag |
|
450 | branchidx |= _rbccloseflag | |
451 | self._setcachedata(rev, reponode, branchidx) |
|
451 | self._setcachedata(rev, reponode, branchidx) | |
452 | return b, close |
|
452 | return b, close | |
453 |
|
453 | |||
454 | def _setcachedata(self, rev, node, branchidx): |
|
454 | def _setcachedata(self, rev, node, branchidx): | |
455 | """Writes the node's branch data to the in-memory cache data.""" |
|
455 | """Writes the node's branch data to the in-memory cache data.""" | |
456 | rbcrevidx = rev * _rbcrecsize |
|
456 | rbcrevidx = rev * _rbcrecsize | |
457 | rec = array('c') |
|
457 | rec = array('c') | |
458 | rec.fromstring(pack(_rbcrecfmt, node, branchidx)) |
|
458 | rec.fromstring(pack(_rbcrecfmt, node, branchidx)) | |
459 | if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: |
|
459 | if len(self._rbcrevs) < rbcrevidx + _rbcrecsize: | |
460 | self._rbcrevs.extend('\0' * |
|
460 | self._rbcrevs.extend('\0' * | |
461 | (len(self._repo.changelog) * _rbcrecsize - |
|
461 | (len(self._repo.changelog) * _rbcrecsize - | |
462 | len(self._rbcrevs))) |
|
462 | len(self._rbcrevs))) | |
463 | self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec |
|
463 | self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec | |
464 | self._rbcrevslen = min(self._rbcrevslen, rev) |
|
464 | self._rbcrevslen = min(self._rbcrevslen, rev) | |
465 |
|
465 | |||
466 | tr = self._repo.currenttransaction() |
|
466 | tr = self._repo.currenttransaction() | |
467 | if tr: |
|
467 | if tr: | |
468 | tr.addfinalize('write-revbranchcache', self.write) |
|
468 | tr.addfinalize('write-revbranchcache', self.write) | |
469 |
|
469 | |||
470 | def write(self, tr=None): |
|
470 | def write(self, tr=None): | |
471 | """Save branch cache if it is dirty.""" |
|
471 | """Save branch cache if it is dirty.""" | |
472 | repo = self._repo |
|
472 | repo = self._repo | |
473 | if True: |
|
473 | wlock = None | |
|
474 | try: | |||
474 | if self._rbcnamescount < len(self._names): |
|
475 | if self._rbcnamescount < len(self._names): | |
|
476 | wlock = repo.wlock(wait=False) | |||
475 | try: |
|
477 | try: | |
476 | if self._rbcnamescount != 0: |
|
478 | if self._rbcnamescount != 0: | |
477 | f = repo.vfs.open(_rbcnames, 'ab') |
|
479 | f = repo.vfs.open(_rbcnames, 'ab') | |
478 | if f.tell() == self._rbcsnameslen: |
|
480 | if f.tell() == self._rbcsnameslen: | |
479 | f.write('\0') |
|
481 | f.write('\0') | |
480 | else: |
|
482 | else: | |
481 | f.close() |
|
483 | f.close() | |
482 | repo.ui.debug("%s changed - rewriting it\n" |
|
484 | repo.ui.debug("%s changed - rewriting it\n" | |
483 | % _rbcnames) |
|
485 | % _rbcnames) | |
484 | self._rbcnamescount = 0 |
|
486 | self._rbcnamescount = 0 | |
485 | self._rbcrevslen = 0 |
|
487 | self._rbcrevslen = 0 | |
486 | if self._rbcnamescount == 0: |
|
488 | if self._rbcnamescount == 0: | |
487 | # before rewriting names, make sure references are |
|
489 | # before rewriting names, make sure references are | |
488 | # removed |
|
490 | # removed | |
489 | repo.vfs.unlinkpath(_rbcrevs, ignoremissing=True) |
|
491 | repo.vfs.unlinkpath(_rbcrevs, ignoremissing=True) | |
490 | f = repo.vfs.open(_rbcnames, 'wb') |
|
492 | f = repo.vfs.open(_rbcnames, 'wb') | |
491 | f.write('\0'.join(encoding.fromlocal(b) |
|
493 | f.write('\0'.join(encoding.fromlocal(b) | |
492 | for b in self._names[self._rbcnamescount:] |
|
494 | for b in self._names[self._rbcnamescount:] | |
493 | )) |
|
495 | )) | |
494 | self._rbcsnameslen = f.tell() |
|
496 | self._rbcsnameslen = f.tell() | |
495 | f.close() |
|
497 | f.close() | |
496 | except (IOError, OSError, error.Abort) as inst: |
|
498 | except (IOError, OSError, error.Abort) as inst: | |
497 | repo.ui.debug("couldn't write revision branch cache names: " |
|
499 | repo.ui.debug("couldn't write revision branch cache names: " | |
498 | "%s\n" % inst) |
|
500 | "%s\n" % inst) | |
499 | return |
|
501 | return | |
500 | self._rbcnamescount = len(self._names) |
|
502 | self._rbcnamescount = len(self._names) | |
501 |
|
503 | |||
502 | start = self._rbcrevslen * _rbcrecsize |
|
504 | start = self._rbcrevslen * _rbcrecsize | |
503 | if start != len(self._rbcrevs): |
|
505 | if start != len(self._rbcrevs): | |
|
506 | if wlock is None: | |||
|
507 | wlock = repo.wlock(wait=False) | |||
504 | revs = min(len(repo.changelog), |
|
508 | revs = min(len(repo.changelog), | |
505 | len(self._rbcrevs) // _rbcrecsize) |
|
509 | len(self._rbcrevs) // _rbcrecsize) | |
506 | try: |
|
510 | try: | |
507 | f = repo.vfs.open(_rbcrevs, 'ab') |
|
511 | f = repo.vfs.open(_rbcrevs, 'ab') | |
508 | if f.tell() != start: |
|
512 | if f.tell() != start: | |
509 | repo.ui.debug("truncating %s to %s\n" |
|
513 | repo.ui.debug("truncating %s to %s\n" | |
510 | % (_rbcrevs, start)) |
|
514 | % (_rbcrevs, start)) | |
511 | f.seek(start) |
|
515 | f.seek(start) | |
512 | if f.tell() != start: |
|
516 | if f.tell() != start: | |
513 | start = 0 |
|
517 | start = 0 | |
514 | f.seek(start) |
|
518 | f.seek(start) | |
515 | f.truncate() |
|
519 | f.truncate() | |
516 | end = revs * _rbcrecsize |
|
520 | end = revs * _rbcrecsize | |
517 | f.write(self._rbcrevs[start:end]) |
|
521 | f.write(self._rbcrevs[start:end]) | |
518 | f.close() |
|
522 | f.close() | |
519 | except (IOError, OSError, error.Abort) as inst: |
|
523 | except (IOError, OSError, error.Abort) as inst: | |
520 | repo.ui.debug("couldn't write revision branch cache: %s\n" % |
|
524 | repo.ui.debug("couldn't write revision branch cache: %s\n" % | |
521 | inst) |
|
525 | inst) | |
522 | return |
|
526 | return | |
523 | self._rbcrevslen = revs |
|
527 | self._rbcrevslen = revs | |
|
528 | except error.LockError as inst: | |||
|
529 | repo.ui.debug("couldn't write revision branch cache: %s\n" % inst) | |||
|
530 | finally: | |||
|
531 | if wlock is not None: | |||
|
532 | wlock.release() |
@@ -1,702 +1,714 | |||||
1 | $ hg init a |
|
1 | $ hg init a | |
2 | $ cd a |
|
2 | $ cd a | |
3 | $ echo 'root' >root |
|
3 | $ echo 'root' >root | |
4 | $ hg add root |
|
4 | $ hg add root | |
5 | $ hg commit -d '0 0' -m "Adding root node" |
|
5 | $ hg commit -d '0 0' -m "Adding root node" | |
6 |
|
6 | |||
7 | $ echo 'a' >a |
|
7 | $ echo 'a' >a | |
8 | $ hg add a |
|
8 | $ hg add a | |
9 | $ hg branch a |
|
9 | $ hg branch a | |
10 | marked working directory as branch a |
|
10 | marked working directory as branch a | |
11 | (branches are permanent and global, did you want a bookmark?) |
|
11 | (branches are permanent and global, did you want a bookmark?) | |
12 | $ hg commit -d '1 0' -m "Adding a branch" |
|
12 | $ hg commit -d '1 0' -m "Adding a branch" | |
13 |
|
13 | |||
14 | $ hg branch q |
|
14 | $ hg branch q | |
15 | marked working directory as branch q |
|
15 | marked working directory as branch q | |
16 | $ echo 'aa' >a |
|
16 | $ echo 'aa' >a | |
17 | $ hg branch -C |
|
17 | $ hg branch -C | |
18 | reset working directory to branch a |
|
18 | reset working directory to branch a | |
19 | $ hg commit -d '2 0' -m "Adding to a branch" |
|
19 | $ hg commit -d '2 0' -m "Adding to a branch" | |
20 |
|
20 | |||
21 | $ hg update -C 0 |
|
21 | $ hg update -C 0 | |
22 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
22 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
23 | $ echo 'b' >b |
|
23 | $ echo 'b' >b | |
24 | $ hg add b |
|
24 | $ hg add b | |
25 | $ hg branch b |
|
25 | $ hg branch b | |
26 | marked working directory as branch b |
|
26 | marked working directory as branch b | |
27 | $ hg commit -d '2 0' -m "Adding b branch" |
|
27 | $ hg commit -d '2 0' -m "Adding b branch" | |
28 |
|
28 | |||
29 | $ echo 'bh1' >bh1 |
|
29 | $ echo 'bh1' >bh1 | |
30 | $ hg add bh1 |
|
30 | $ hg add bh1 | |
31 | $ hg commit -d '3 0' -m "Adding b branch head 1" |
|
31 | $ hg commit -d '3 0' -m "Adding b branch head 1" | |
32 |
|
32 | |||
33 | $ hg update -C 2 |
|
33 | $ hg update -C 2 | |
34 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
34 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
35 | $ echo 'bh2' >bh2 |
|
35 | $ echo 'bh2' >bh2 | |
36 | $ hg add bh2 |
|
36 | $ hg add bh2 | |
37 | $ hg commit -d '4 0' -m "Adding b branch head 2" |
|
37 | $ hg commit -d '4 0' -m "Adding b branch head 2" | |
38 |
|
38 | |||
39 | $ echo 'c' >c |
|
39 | $ echo 'c' >c | |
40 | $ hg add c |
|
40 | $ hg add c | |
41 | $ hg branch c |
|
41 | $ hg branch c | |
42 | marked working directory as branch c |
|
42 | marked working directory as branch c | |
43 | $ hg commit -d '5 0' -m "Adding c branch" |
|
43 | $ hg commit -d '5 0' -m "Adding c branch" | |
44 |
|
44 | |||
45 | reserved names |
|
45 | reserved names | |
46 |
|
46 | |||
47 | $ hg branch tip |
|
47 | $ hg branch tip | |
48 | abort: the name 'tip' is reserved |
|
48 | abort: the name 'tip' is reserved | |
49 | [255] |
|
49 | [255] | |
50 | $ hg branch null |
|
50 | $ hg branch null | |
51 | abort: the name 'null' is reserved |
|
51 | abort: the name 'null' is reserved | |
52 | [255] |
|
52 | [255] | |
53 | $ hg branch . |
|
53 | $ hg branch . | |
54 | abort: the name '.' is reserved |
|
54 | abort: the name '.' is reserved | |
55 | [255] |
|
55 | [255] | |
56 |
|
56 | |||
57 | invalid characters |
|
57 | invalid characters | |
58 |
|
58 | |||
59 | $ hg branch 'foo:bar' |
|
59 | $ hg branch 'foo:bar' | |
60 | abort: ':' cannot be used in a name |
|
60 | abort: ':' cannot be used in a name | |
61 | [255] |
|
61 | [255] | |
62 |
|
62 | |||
63 | $ hg branch 'foo |
|
63 | $ hg branch 'foo | |
64 | > bar' |
|
64 | > bar' | |
65 | abort: '\n' cannot be used in a name |
|
65 | abort: '\n' cannot be used in a name | |
66 | [255] |
|
66 | [255] | |
67 |
|
67 | |||
68 | trailing or leading spaces should be stripped before testing duplicates |
|
68 | trailing or leading spaces should be stripped before testing duplicates | |
69 |
|
69 | |||
70 | $ hg branch 'b ' |
|
70 | $ hg branch 'b ' | |
71 | abort: a branch of the same name already exists |
|
71 | abort: a branch of the same name already exists | |
72 | (use 'hg update' to switch to it) |
|
72 | (use 'hg update' to switch to it) | |
73 | [255] |
|
73 | [255] | |
74 |
|
74 | |||
75 | $ hg branch ' b' |
|
75 | $ hg branch ' b' | |
76 | abort: a branch of the same name already exists |
|
76 | abort: a branch of the same name already exists | |
77 | (use 'hg update' to switch to it) |
|
77 | (use 'hg update' to switch to it) | |
78 | [255] |
|
78 | [255] | |
79 |
|
79 | |||
80 | verify update will accept invalid legacy branch names |
|
80 | verify update will accept invalid legacy branch names | |
81 |
|
81 | |||
82 | $ hg init test-invalid-branch-name |
|
82 | $ hg init test-invalid-branch-name | |
83 | $ cd test-invalid-branch-name |
|
83 | $ cd test-invalid-branch-name | |
84 | $ hg pull -u "$TESTDIR"/bundles/test-invalid-branch-name.hg |
|
84 | $ hg pull -u "$TESTDIR"/bundles/test-invalid-branch-name.hg | |
85 | pulling from *test-invalid-branch-name.hg (glob) |
|
85 | pulling from *test-invalid-branch-name.hg (glob) | |
86 | requesting all changes |
|
86 | requesting all changes | |
87 | adding changesets |
|
87 | adding changesets | |
88 | adding manifests |
|
88 | adding manifests | |
89 | adding file changes |
|
89 | adding file changes | |
90 | added 3 changesets with 3 changes to 2 files |
|
90 | added 3 changesets with 3 changes to 2 files | |
91 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
91 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
92 |
|
92 | |||
93 | $ hg update '"colon:test"' |
|
93 | $ hg update '"colon:test"' | |
94 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
94 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
95 | $ cd .. |
|
95 | $ cd .. | |
96 |
|
96 | |||
97 | $ echo 'd' >d |
|
97 | $ echo 'd' >d | |
98 | $ hg add d |
|
98 | $ hg add d | |
99 | $ hg branch 'a branch name much longer than the default justification used by branches' |
|
99 | $ hg branch 'a branch name much longer than the default justification used by branches' | |
100 | marked working directory as branch a branch name much longer than the default justification used by branches |
|
100 | marked working directory as branch a branch name much longer than the default justification used by branches | |
101 | $ hg commit -d '6 0' -m "Adding d branch" |
|
101 | $ hg commit -d '6 0' -m "Adding d branch" | |
102 |
|
102 | |||
103 | $ hg branches |
|
103 | $ hg branches | |
104 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 |
|
104 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 | |
105 | b 4:aee39cd168d0 |
|
105 | b 4:aee39cd168d0 | |
106 | c 6:589736a22561 (inactive) |
|
106 | c 6:589736a22561 (inactive) | |
107 | a 5:d8cbc61dbaa6 (inactive) |
|
107 | a 5:d8cbc61dbaa6 (inactive) | |
108 | default 0:19709c5a4e75 (inactive) |
|
108 | default 0:19709c5a4e75 (inactive) | |
109 |
|
109 | |||
110 | ------- |
|
110 | ------- | |
111 |
|
111 | |||
112 | $ hg branches -a |
|
112 | $ hg branches -a | |
113 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 |
|
113 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 | |
114 | b 4:aee39cd168d0 |
|
114 | b 4:aee39cd168d0 | |
115 |
|
115 | |||
116 | --- Branch a |
|
116 | --- Branch a | |
117 |
|
117 | |||
118 | $ hg log -b a |
|
118 | $ hg log -b a | |
119 | changeset: 5:d8cbc61dbaa6 |
|
119 | changeset: 5:d8cbc61dbaa6 | |
120 | branch: a |
|
120 | branch: a | |
121 | parent: 2:881fe2b92ad0 |
|
121 | parent: 2:881fe2b92ad0 | |
122 | user: test |
|
122 | user: test | |
123 | date: Thu Jan 01 00:00:04 1970 +0000 |
|
123 | date: Thu Jan 01 00:00:04 1970 +0000 | |
124 | summary: Adding b branch head 2 |
|
124 | summary: Adding b branch head 2 | |
125 |
|
125 | |||
126 | changeset: 2:881fe2b92ad0 |
|
126 | changeset: 2:881fe2b92ad0 | |
127 | branch: a |
|
127 | branch: a | |
128 | user: test |
|
128 | user: test | |
129 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
129 | date: Thu Jan 01 00:00:02 1970 +0000 | |
130 | summary: Adding to a branch |
|
130 | summary: Adding to a branch | |
131 |
|
131 | |||
132 | changeset: 1:dd6b440dd85a |
|
132 | changeset: 1:dd6b440dd85a | |
133 | branch: a |
|
133 | branch: a | |
134 | user: test |
|
134 | user: test | |
135 | date: Thu Jan 01 00:00:01 1970 +0000 |
|
135 | date: Thu Jan 01 00:00:01 1970 +0000 | |
136 | summary: Adding a branch |
|
136 | summary: Adding a branch | |
137 |
|
137 | |||
138 |
|
138 | |||
139 | ---- Branch b |
|
139 | ---- Branch b | |
140 |
|
140 | |||
141 | $ hg log -b b |
|
141 | $ hg log -b b | |
142 | changeset: 4:aee39cd168d0 |
|
142 | changeset: 4:aee39cd168d0 | |
143 | branch: b |
|
143 | branch: b | |
144 | user: test |
|
144 | user: test | |
145 | date: Thu Jan 01 00:00:03 1970 +0000 |
|
145 | date: Thu Jan 01 00:00:03 1970 +0000 | |
146 | summary: Adding b branch head 1 |
|
146 | summary: Adding b branch head 1 | |
147 |
|
147 | |||
148 | changeset: 3:ac22033332d1 |
|
148 | changeset: 3:ac22033332d1 | |
149 | branch: b |
|
149 | branch: b | |
150 | parent: 0:19709c5a4e75 |
|
150 | parent: 0:19709c5a4e75 | |
151 | user: test |
|
151 | user: test | |
152 | date: Thu Jan 01 00:00:02 1970 +0000 |
|
152 | date: Thu Jan 01 00:00:02 1970 +0000 | |
153 | summary: Adding b branch |
|
153 | summary: Adding b branch | |
154 |
|
154 | |||
155 |
|
155 | |||
156 | ---- going to test branch closing |
|
156 | ---- going to test branch closing | |
157 |
|
157 | |||
158 | $ hg branches |
|
158 | $ hg branches | |
159 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 |
|
159 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 | |
160 | b 4:aee39cd168d0 |
|
160 | b 4:aee39cd168d0 | |
161 | c 6:589736a22561 (inactive) |
|
161 | c 6:589736a22561 (inactive) | |
162 | a 5:d8cbc61dbaa6 (inactive) |
|
162 | a 5:d8cbc61dbaa6 (inactive) | |
163 | default 0:19709c5a4e75 (inactive) |
|
163 | default 0:19709c5a4e75 (inactive) | |
164 | $ hg up -C b |
|
164 | $ hg up -C b | |
165 | 2 files updated, 0 files merged, 4 files removed, 0 files unresolved |
|
165 | 2 files updated, 0 files merged, 4 files removed, 0 files unresolved | |
166 | $ echo 'xxx1' >> b |
|
166 | $ echo 'xxx1' >> b | |
167 | $ hg commit -d '7 0' -m 'adding cset to branch b' |
|
167 | $ hg commit -d '7 0' -m 'adding cset to branch b' | |
168 | $ hg up -C aee39cd168d0 |
|
168 | $ hg up -C aee39cd168d0 | |
169 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
169 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
170 | $ echo 'xxx2' >> b |
|
170 | $ echo 'xxx2' >> b | |
171 | $ hg commit -d '8 0' -m 'adding head to branch b' |
|
171 | $ hg commit -d '8 0' -m 'adding head to branch b' | |
172 | created new head |
|
172 | created new head | |
173 | $ echo 'xxx3' >> b |
|
173 | $ echo 'xxx3' >> b | |
174 | $ hg commit -d '9 0' -m 'adding another cset to branch b' |
|
174 | $ hg commit -d '9 0' -m 'adding another cset to branch b' | |
175 | $ hg branches |
|
175 | $ hg branches | |
176 | b 10:bfbe841b666e |
|
176 | b 10:bfbe841b666e | |
177 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 |
|
177 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 | |
178 | c 6:589736a22561 (inactive) |
|
178 | c 6:589736a22561 (inactive) | |
179 | a 5:d8cbc61dbaa6 (inactive) |
|
179 | a 5:d8cbc61dbaa6 (inactive) | |
180 | default 0:19709c5a4e75 (inactive) |
|
180 | default 0:19709c5a4e75 (inactive) | |
181 | $ hg heads --closed |
|
181 | $ hg heads --closed | |
182 | changeset: 10:bfbe841b666e |
|
182 | changeset: 10:bfbe841b666e | |
183 | branch: b |
|
183 | branch: b | |
184 | tag: tip |
|
184 | tag: tip | |
185 | user: test |
|
185 | user: test | |
186 | date: Thu Jan 01 00:00:09 1970 +0000 |
|
186 | date: Thu Jan 01 00:00:09 1970 +0000 | |
187 | summary: adding another cset to branch b |
|
187 | summary: adding another cset to branch b | |
188 |
|
188 | |||
189 | changeset: 8:eebb944467c9 |
|
189 | changeset: 8:eebb944467c9 | |
190 | branch: b |
|
190 | branch: b | |
191 | parent: 4:aee39cd168d0 |
|
191 | parent: 4:aee39cd168d0 | |
192 | user: test |
|
192 | user: test | |
193 | date: Thu Jan 01 00:00:07 1970 +0000 |
|
193 | date: Thu Jan 01 00:00:07 1970 +0000 | |
194 | summary: adding cset to branch b |
|
194 | summary: adding cset to branch b | |
195 |
|
195 | |||
196 | changeset: 7:10ff5895aa57 |
|
196 | changeset: 7:10ff5895aa57 | |
197 | branch: a branch name much longer than the default justification used by branches |
|
197 | branch: a branch name much longer than the default justification used by branches | |
198 | user: test |
|
198 | user: test | |
199 | date: Thu Jan 01 00:00:06 1970 +0000 |
|
199 | date: Thu Jan 01 00:00:06 1970 +0000 | |
200 | summary: Adding d branch |
|
200 | summary: Adding d branch | |
201 |
|
201 | |||
202 | changeset: 6:589736a22561 |
|
202 | changeset: 6:589736a22561 | |
203 | branch: c |
|
203 | branch: c | |
204 | user: test |
|
204 | user: test | |
205 | date: Thu Jan 01 00:00:05 1970 +0000 |
|
205 | date: Thu Jan 01 00:00:05 1970 +0000 | |
206 | summary: Adding c branch |
|
206 | summary: Adding c branch | |
207 |
|
207 | |||
208 | changeset: 5:d8cbc61dbaa6 |
|
208 | changeset: 5:d8cbc61dbaa6 | |
209 | branch: a |
|
209 | branch: a | |
210 | parent: 2:881fe2b92ad0 |
|
210 | parent: 2:881fe2b92ad0 | |
211 | user: test |
|
211 | user: test | |
212 | date: Thu Jan 01 00:00:04 1970 +0000 |
|
212 | date: Thu Jan 01 00:00:04 1970 +0000 | |
213 | summary: Adding b branch head 2 |
|
213 | summary: Adding b branch head 2 | |
214 |
|
214 | |||
215 | changeset: 0:19709c5a4e75 |
|
215 | changeset: 0:19709c5a4e75 | |
216 | user: test |
|
216 | user: test | |
217 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
217 | date: Thu Jan 01 00:00:00 1970 +0000 | |
218 | summary: Adding root node |
|
218 | summary: Adding root node | |
219 |
|
219 | |||
220 | $ hg heads |
|
220 | $ hg heads | |
221 | changeset: 10:bfbe841b666e |
|
221 | changeset: 10:bfbe841b666e | |
222 | branch: b |
|
222 | branch: b | |
223 | tag: tip |
|
223 | tag: tip | |
224 | user: test |
|
224 | user: test | |
225 | date: Thu Jan 01 00:00:09 1970 +0000 |
|
225 | date: Thu Jan 01 00:00:09 1970 +0000 | |
226 | summary: adding another cset to branch b |
|
226 | summary: adding another cset to branch b | |
227 |
|
227 | |||
228 | changeset: 8:eebb944467c9 |
|
228 | changeset: 8:eebb944467c9 | |
229 | branch: b |
|
229 | branch: b | |
230 | parent: 4:aee39cd168d0 |
|
230 | parent: 4:aee39cd168d0 | |
231 | user: test |
|
231 | user: test | |
232 | date: Thu Jan 01 00:00:07 1970 +0000 |
|
232 | date: Thu Jan 01 00:00:07 1970 +0000 | |
233 | summary: adding cset to branch b |
|
233 | summary: adding cset to branch b | |
234 |
|
234 | |||
235 | changeset: 7:10ff5895aa57 |
|
235 | changeset: 7:10ff5895aa57 | |
236 | branch: a branch name much longer than the default justification used by branches |
|
236 | branch: a branch name much longer than the default justification used by branches | |
237 | user: test |
|
237 | user: test | |
238 | date: Thu Jan 01 00:00:06 1970 +0000 |
|
238 | date: Thu Jan 01 00:00:06 1970 +0000 | |
239 | summary: Adding d branch |
|
239 | summary: Adding d branch | |
240 |
|
240 | |||
241 | changeset: 6:589736a22561 |
|
241 | changeset: 6:589736a22561 | |
242 | branch: c |
|
242 | branch: c | |
243 | user: test |
|
243 | user: test | |
244 | date: Thu Jan 01 00:00:05 1970 +0000 |
|
244 | date: Thu Jan 01 00:00:05 1970 +0000 | |
245 | summary: Adding c branch |
|
245 | summary: Adding c branch | |
246 |
|
246 | |||
247 | changeset: 5:d8cbc61dbaa6 |
|
247 | changeset: 5:d8cbc61dbaa6 | |
248 | branch: a |
|
248 | branch: a | |
249 | parent: 2:881fe2b92ad0 |
|
249 | parent: 2:881fe2b92ad0 | |
250 | user: test |
|
250 | user: test | |
251 | date: Thu Jan 01 00:00:04 1970 +0000 |
|
251 | date: Thu Jan 01 00:00:04 1970 +0000 | |
252 | summary: Adding b branch head 2 |
|
252 | summary: Adding b branch head 2 | |
253 |
|
253 | |||
254 | changeset: 0:19709c5a4e75 |
|
254 | changeset: 0:19709c5a4e75 | |
255 | user: test |
|
255 | user: test | |
256 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
256 | date: Thu Jan 01 00:00:00 1970 +0000 | |
257 | summary: Adding root node |
|
257 | summary: Adding root node | |
258 |
|
258 | |||
259 | $ hg commit -d '9 0' --close-branch -m 'prune bad branch' |
|
259 | $ hg commit -d '9 0' --close-branch -m 'prune bad branch' | |
260 | $ hg branches -a |
|
260 | $ hg branches -a | |
261 | b 8:eebb944467c9 |
|
261 | b 8:eebb944467c9 | |
262 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 |
|
262 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 | |
263 | $ hg up -C b |
|
263 | $ hg up -C b | |
264 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
264 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
265 | $ hg commit -d '9 0' --close-branch -m 'close this part branch too' |
|
265 | $ hg commit -d '9 0' --close-branch -m 'close this part branch too' | |
266 | $ hg commit -d '9 0' --close-branch -m 're-closing this branch' |
|
266 | $ hg commit -d '9 0' --close-branch -m 're-closing this branch' | |
267 | abort: can only close branch heads |
|
267 | abort: can only close branch heads | |
268 | [255] |
|
268 | [255] | |
269 |
|
269 | |||
270 | $ hg log -r tip --debug |
|
270 | $ hg log -r tip --debug | |
271 | changeset: 12:e3d49c0575d8fc2cb1cd6859c747c14f5f6d499f |
|
271 | changeset: 12:e3d49c0575d8fc2cb1cd6859c747c14f5f6d499f | |
272 | branch: b |
|
272 | branch: b | |
273 | tag: tip |
|
273 | tag: tip | |
274 | phase: draft |
|
274 | phase: draft | |
275 | parent: 8:eebb944467c9fb9651ed232aeaf31b3c0a7fc6c1 |
|
275 | parent: 8:eebb944467c9fb9651ed232aeaf31b3c0a7fc6c1 | |
276 | parent: -1:0000000000000000000000000000000000000000 |
|
276 | parent: -1:0000000000000000000000000000000000000000 | |
277 | manifest: 8:6f9ed32d2b310e391a4f107d5f0f071df785bfee |
|
277 | manifest: 8:6f9ed32d2b310e391a4f107d5f0f071df785bfee | |
278 | user: test |
|
278 | user: test | |
279 | date: Thu Jan 01 00:00:09 1970 +0000 |
|
279 | date: Thu Jan 01 00:00:09 1970 +0000 | |
280 | extra: branch=b |
|
280 | extra: branch=b | |
281 | extra: close=1 |
|
281 | extra: close=1 | |
282 | description: |
|
282 | description: | |
283 | close this part branch too |
|
283 | close this part branch too | |
284 |
|
284 | |||
285 |
|
285 | |||
286 | --- b branch should be inactive |
|
286 | --- b branch should be inactive | |
287 |
|
287 | |||
288 | $ hg branches |
|
288 | $ hg branches | |
289 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 |
|
289 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 | |
290 | c 6:589736a22561 (inactive) |
|
290 | c 6:589736a22561 (inactive) | |
291 | a 5:d8cbc61dbaa6 (inactive) |
|
291 | a 5:d8cbc61dbaa6 (inactive) | |
292 | default 0:19709c5a4e75 (inactive) |
|
292 | default 0:19709c5a4e75 (inactive) | |
293 | $ hg branches -c |
|
293 | $ hg branches -c | |
294 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 |
|
294 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 | |
295 | b 12:e3d49c0575d8 (closed) |
|
295 | b 12:e3d49c0575d8 (closed) | |
296 | c 6:589736a22561 (inactive) |
|
296 | c 6:589736a22561 (inactive) | |
297 | a 5:d8cbc61dbaa6 (inactive) |
|
297 | a 5:d8cbc61dbaa6 (inactive) | |
298 | default 0:19709c5a4e75 (inactive) |
|
298 | default 0:19709c5a4e75 (inactive) | |
299 | $ hg branches -a |
|
299 | $ hg branches -a | |
300 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 |
|
300 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 | |
301 | $ hg branches -q |
|
301 | $ hg branches -q | |
302 | a branch name much longer than the default justification used by branches |
|
302 | a branch name much longer than the default justification used by branches | |
303 | c |
|
303 | c | |
304 | a |
|
304 | a | |
305 | default |
|
305 | default | |
306 | $ hg heads b |
|
306 | $ hg heads b | |
307 | no open branch heads found on branches b |
|
307 | no open branch heads found on branches b | |
308 | [1] |
|
308 | [1] | |
309 | $ hg heads --closed b |
|
309 | $ hg heads --closed b | |
310 | changeset: 12:e3d49c0575d8 |
|
310 | changeset: 12:e3d49c0575d8 | |
311 | branch: b |
|
311 | branch: b | |
312 | tag: tip |
|
312 | tag: tip | |
313 | parent: 8:eebb944467c9 |
|
313 | parent: 8:eebb944467c9 | |
314 | user: test |
|
314 | user: test | |
315 | date: Thu Jan 01 00:00:09 1970 +0000 |
|
315 | date: Thu Jan 01 00:00:09 1970 +0000 | |
316 | summary: close this part branch too |
|
316 | summary: close this part branch too | |
317 |
|
317 | |||
318 | changeset: 11:d3f163457ebf |
|
318 | changeset: 11:d3f163457ebf | |
319 | branch: b |
|
319 | branch: b | |
320 | user: test |
|
320 | user: test | |
321 | date: Thu Jan 01 00:00:09 1970 +0000 |
|
321 | date: Thu Jan 01 00:00:09 1970 +0000 | |
322 | summary: prune bad branch |
|
322 | summary: prune bad branch | |
323 |
|
323 | |||
324 | $ echo 'xxx4' >> b |
|
324 | $ echo 'xxx4' >> b | |
325 | $ hg commit -d '9 0' -m 'reopen branch with a change' |
|
325 | $ hg commit -d '9 0' -m 'reopen branch with a change' | |
326 | reopening closed branch head 12 |
|
326 | reopening closed branch head 12 | |
327 |
|
327 | |||
328 | --- branch b is back in action |
|
328 | --- branch b is back in action | |
329 |
|
329 | |||
330 | $ hg branches -a |
|
330 | $ hg branches -a | |
331 | b 13:e23b5505d1ad |
|
331 | b 13:e23b5505d1ad | |
332 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 |
|
332 | a branch name much longer than the default justification used by branches 7:10ff5895aa57 | |
333 |
|
333 | |||
334 | ---- test heads listings |
|
334 | ---- test heads listings | |
335 |
|
335 | |||
336 | $ hg heads |
|
336 | $ hg heads | |
337 | changeset: 13:e23b5505d1ad |
|
337 | changeset: 13:e23b5505d1ad | |
338 | branch: b |
|
338 | branch: b | |
339 | tag: tip |
|
339 | tag: tip | |
340 | user: test |
|
340 | user: test | |
341 | date: Thu Jan 01 00:00:09 1970 +0000 |
|
341 | date: Thu Jan 01 00:00:09 1970 +0000 | |
342 | summary: reopen branch with a change |
|
342 | summary: reopen branch with a change | |
343 |
|
343 | |||
344 | changeset: 7:10ff5895aa57 |
|
344 | changeset: 7:10ff5895aa57 | |
345 | branch: a branch name much longer than the default justification used by branches |
|
345 | branch: a branch name much longer than the default justification used by branches | |
346 | user: test |
|
346 | user: test | |
347 | date: Thu Jan 01 00:00:06 1970 +0000 |
|
347 | date: Thu Jan 01 00:00:06 1970 +0000 | |
348 | summary: Adding d branch |
|
348 | summary: Adding d branch | |
349 |
|
349 | |||
350 | changeset: 6:589736a22561 |
|
350 | changeset: 6:589736a22561 | |
351 | branch: c |
|
351 | branch: c | |
352 | user: test |
|
352 | user: test | |
353 | date: Thu Jan 01 00:00:05 1970 +0000 |
|
353 | date: Thu Jan 01 00:00:05 1970 +0000 | |
354 | summary: Adding c branch |
|
354 | summary: Adding c branch | |
355 |
|
355 | |||
356 | changeset: 5:d8cbc61dbaa6 |
|
356 | changeset: 5:d8cbc61dbaa6 | |
357 | branch: a |
|
357 | branch: a | |
358 | parent: 2:881fe2b92ad0 |
|
358 | parent: 2:881fe2b92ad0 | |
359 | user: test |
|
359 | user: test | |
360 | date: Thu Jan 01 00:00:04 1970 +0000 |
|
360 | date: Thu Jan 01 00:00:04 1970 +0000 | |
361 | summary: Adding b branch head 2 |
|
361 | summary: Adding b branch head 2 | |
362 |
|
362 | |||
363 | changeset: 0:19709c5a4e75 |
|
363 | changeset: 0:19709c5a4e75 | |
364 | user: test |
|
364 | user: test | |
365 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
365 | date: Thu Jan 01 00:00:00 1970 +0000 | |
366 | summary: Adding root node |
|
366 | summary: Adding root node | |
367 |
|
367 | |||
368 |
|
368 | |||
369 | branch default |
|
369 | branch default | |
370 |
|
370 | |||
371 | $ hg heads default |
|
371 | $ hg heads default | |
372 | changeset: 0:19709c5a4e75 |
|
372 | changeset: 0:19709c5a4e75 | |
373 | user: test |
|
373 | user: test | |
374 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
374 | date: Thu Jan 01 00:00:00 1970 +0000 | |
375 | summary: Adding root node |
|
375 | summary: Adding root node | |
376 |
|
376 | |||
377 |
|
377 | |||
378 | branch a |
|
378 | branch a | |
379 |
|
379 | |||
380 | $ hg heads a |
|
380 | $ hg heads a | |
381 | changeset: 5:d8cbc61dbaa6 |
|
381 | changeset: 5:d8cbc61dbaa6 | |
382 | branch: a |
|
382 | branch: a | |
383 | parent: 2:881fe2b92ad0 |
|
383 | parent: 2:881fe2b92ad0 | |
384 | user: test |
|
384 | user: test | |
385 | date: Thu Jan 01 00:00:04 1970 +0000 |
|
385 | date: Thu Jan 01 00:00:04 1970 +0000 | |
386 | summary: Adding b branch head 2 |
|
386 | summary: Adding b branch head 2 | |
387 |
|
387 | |||
388 | $ hg heads --active a |
|
388 | $ hg heads --active a | |
389 | no open branch heads found on branches a |
|
389 | no open branch heads found on branches a | |
390 | [1] |
|
390 | [1] | |
391 |
|
391 | |||
392 | branch b |
|
392 | branch b | |
393 |
|
393 | |||
394 | $ hg heads b |
|
394 | $ hg heads b | |
395 | changeset: 13:e23b5505d1ad |
|
395 | changeset: 13:e23b5505d1ad | |
396 | branch: b |
|
396 | branch: b | |
397 | tag: tip |
|
397 | tag: tip | |
398 | user: test |
|
398 | user: test | |
399 | date: Thu Jan 01 00:00:09 1970 +0000 |
|
399 | date: Thu Jan 01 00:00:09 1970 +0000 | |
400 | summary: reopen branch with a change |
|
400 | summary: reopen branch with a change | |
401 |
|
401 | |||
402 | $ hg heads --closed b |
|
402 | $ hg heads --closed b | |
403 | changeset: 13:e23b5505d1ad |
|
403 | changeset: 13:e23b5505d1ad | |
404 | branch: b |
|
404 | branch: b | |
405 | tag: tip |
|
405 | tag: tip | |
406 | user: test |
|
406 | user: test | |
407 | date: Thu Jan 01 00:00:09 1970 +0000 |
|
407 | date: Thu Jan 01 00:00:09 1970 +0000 | |
408 | summary: reopen branch with a change |
|
408 | summary: reopen branch with a change | |
409 |
|
409 | |||
410 | changeset: 11:d3f163457ebf |
|
410 | changeset: 11:d3f163457ebf | |
411 | branch: b |
|
411 | branch: b | |
412 | user: test |
|
412 | user: test | |
413 | date: Thu Jan 01 00:00:09 1970 +0000 |
|
413 | date: Thu Jan 01 00:00:09 1970 +0000 | |
414 | summary: prune bad branch |
|
414 | summary: prune bad branch | |
415 |
|
415 | |||
416 | default branch colors: |
|
416 | default branch colors: | |
417 |
|
417 | |||
418 | $ cat <<EOF >> $HGRCPATH |
|
418 | $ cat <<EOF >> $HGRCPATH | |
419 | > [extensions] |
|
419 | > [extensions] | |
420 | > color = |
|
420 | > color = | |
421 | > [color] |
|
421 | > [color] | |
422 | > mode = ansi |
|
422 | > mode = ansi | |
423 | > EOF |
|
423 | > EOF | |
424 |
|
424 | |||
425 | $ hg up -C c |
|
425 | $ hg up -C c | |
426 | 3 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
426 | 3 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
427 | $ hg commit -d '9 0' --close-branch -m 'reclosing this branch' |
|
427 | $ hg commit -d '9 0' --close-branch -m 'reclosing this branch' | |
428 | $ hg up -C b |
|
428 | $ hg up -C b | |
429 | 2 files updated, 0 files merged, 3 files removed, 0 files unresolved |
|
429 | 2 files updated, 0 files merged, 3 files removed, 0 files unresolved | |
430 | $ hg branches --color=always |
|
430 | $ hg branches --color=always | |
431 | \x1b[0;32mb\x1b[0m\x1b[0;33m 13:e23b5505d1ad\x1b[0m (esc) |
|
431 | \x1b[0;32mb\x1b[0m\x1b[0;33m 13:e23b5505d1ad\x1b[0m (esc) | |
432 | \x1b[0;0ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;33m 7:10ff5895aa57\x1b[0m (esc) |
|
432 | \x1b[0;0ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;33m 7:10ff5895aa57\x1b[0m (esc) | |
433 | \x1b[0;0ma\x1b[0m\x1b[0;33m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) |
|
433 | \x1b[0;0ma\x1b[0m\x1b[0;33m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) | |
434 | \x1b[0;0mdefault\x1b[0m\x1b[0;33m 0:19709c5a4e75\x1b[0m (inactive) (esc) |
|
434 | \x1b[0;0mdefault\x1b[0m\x1b[0;33m 0:19709c5a4e75\x1b[0m (inactive) (esc) | |
435 |
|
435 | |||
436 | default closed branch color: |
|
436 | default closed branch color: | |
437 |
|
437 | |||
438 | $ hg branches --color=always --closed |
|
438 | $ hg branches --color=always --closed | |
439 | \x1b[0;32mb\x1b[0m\x1b[0;33m 13:e23b5505d1ad\x1b[0m (esc) |
|
439 | \x1b[0;32mb\x1b[0m\x1b[0;33m 13:e23b5505d1ad\x1b[0m (esc) | |
440 | \x1b[0;0ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;33m 7:10ff5895aa57\x1b[0m (esc) |
|
440 | \x1b[0;0ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;33m 7:10ff5895aa57\x1b[0m (esc) | |
441 | \x1b[0;30;1mc\x1b[0m\x1b[0;33m 14:f894c25619d3\x1b[0m (closed) (esc) |
|
441 | \x1b[0;30;1mc\x1b[0m\x1b[0;33m 14:f894c25619d3\x1b[0m (closed) (esc) | |
442 | \x1b[0;0ma\x1b[0m\x1b[0;33m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) |
|
442 | \x1b[0;0ma\x1b[0m\x1b[0;33m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) | |
443 | \x1b[0;0mdefault\x1b[0m\x1b[0;33m 0:19709c5a4e75\x1b[0m (inactive) (esc) |
|
443 | \x1b[0;0mdefault\x1b[0m\x1b[0;33m 0:19709c5a4e75\x1b[0m (inactive) (esc) | |
444 |
|
444 | |||
445 | $ cat <<EOF >> $HGRCPATH |
|
445 | $ cat <<EOF >> $HGRCPATH | |
446 | > [extensions] |
|
446 | > [extensions] | |
447 | > color = |
|
447 | > color = | |
448 | > [color] |
|
448 | > [color] | |
449 | > branches.active = green |
|
449 | > branches.active = green | |
450 | > branches.closed = blue |
|
450 | > branches.closed = blue | |
451 | > branches.current = red |
|
451 | > branches.current = red | |
452 | > branches.inactive = magenta |
|
452 | > branches.inactive = magenta | |
453 | > log.changeset = cyan |
|
453 | > log.changeset = cyan | |
454 | > EOF |
|
454 | > EOF | |
455 |
|
455 | |||
456 | custom branch colors: |
|
456 | custom branch colors: | |
457 |
|
457 | |||
458 | $ hg branches --color=always |
|
458 | $ hg branches --color=always | |
459 | \x1b[0;31mb\x1b[0m\x1b[0;36m 13:e23b5505d1ad\x1b[0m (esc) |
|
459 | \x1b[0;31mb\x1b[0m\x1b[0;36m 13:e23b5505d1ad\x1b[0m (esc) | |
460 | \x1b[0;32ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;36m 7:10ff5895aa57\x1b[0m (esc) |
|
460 | \x1b[0;32ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;36m 7:10ff5895aa57\x1b[0m (esc) | |
461 | \x1b[0;35ma\x1b[0m\x1b[0;36m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) |
|
461 | \x1b[0;35ma\x1b[0m\x1b[0;36m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) | |
462 | \x1b[0;35mdefault\x1b[0m\x1b[0;36m 0:19709c5a4e75\x1b[0m (inactive) (esc) |
|
462 | \x1b[0;35mdefault\x1b[0m\x1b[0;36m 0:19709c5a4e75\x1b[0m (inactive) (esc) | |
463 |
|
463 | |||
464 | custom closed branch color: |
|
464 | custom closed branch color: | |
465 |
|
465 | |||
466 | $ hg branches --color=always --closed |
|
466 | $ hg branches --color=always --closed | |
467 | \x1b[0;31mb\x1b[0m\x1b[0;36m 13:e23b5505d1ad\x1b[0m (esc) |
|
467 | \x1b[0;31mb\x1b[0m\x1b[0;36m 13:e23b5505d1ad\x1b[0m (esc) | |
468 | \x1b[0;32ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;36m 7:10ff5895aa57\x1b[0m (esc) |
|
468 | \x1b[0;32ma branch name much longer than the default justification used by branches\x1b[0m\x1b[0;36m 7:10ff5895aa57\x1b[0m (esc) | |
469 | \x1b[0;34mc\x1b[0m\x1b[0;36m 14:f894c25619d3\x1b[0m (closed) (esc) |
|
469 | \x1b[0;34mc\x1b[0m\x1b[0;36m 14:f894c25619d3\x1b[0m (closed) (esc) | |
470 | \x1b[0;35ma\x1b[0m\x1b[0;36m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) |
|
470 | \x1b[0;35ma\x1b[0m\x1b[0;36m 5:d8cbc61dbaa6\x1b[0m (inactive) (esc) | |
471 | \x1b[0;35mdefault\x1b[0m\x1b[0;36m 0:19709c5a4e75\x1b[0m (inactive) (esc) |
|
471 | \x1b[0;35mdefault\x1b[0m\x1b[0;36m 0:19709c5a4e75\x1b[0m (inactive) (esc) | |
472 |
|
472 | |||
473 | template output: |
|
473 | template output: | |
474 |
|
474 | |||
475 | $ hg branches -Tjson --closed |
|
475 | $ hg branches -Tjson --closed | |
476 | [ |
|
476 | [ | |
477 | { |
|
477 | { | |
478 | "active": true, |
|
478 | "active": true, | |
479 | "branch": "b", |
|
479 | "branch": "b", | |
480 | "closed": false, |
|
480 | "closed": false, | |
481 | "current": true, |
|
481 | "current": true, | |
482 | "node": "e23b5505d1ad24aab6f84fd8c7cb8cd8e5e93be0", |
|
482 | "node": "e23b5505d1ad24aab6f84fd8c7cb8cd8e5e93be0", | |
483 | "rev": 13 |
|
483 | "rev": 13 | |
484 | }, |
|
484 | }, | |
485 | { |
|
485 | { | |
486 | "active": true, |
|
486 | "active": true, | |
487 | "branch": "a branch name much longer than the default justification used by branches", |
|
487 | "branch": "a branch name much longer than the default justification used by branches", | |
488 | "closed": false, |
|
488 | "closed": false, | |
489 | "current": false, |
|
489 | "current": false, | |
490 | "node": "10ff5895aa5793bd378da574af8cec8ea408d831", |
|
490 | "node": "10ff5895aa5793bd378da574af8cec8ea408d831", | |
491 | "rev": 7 |
|
491 | "rev": 7 | |
492 | }, |
|
492 | }, | |
493 | { |
|
493 | { | |
494 | "active": false, |
|
494 | "active": false, | |
495 | "branch": "c", |
|
495 | "branch": "c", | |
496 | "closed": true, |
|
496 | "closed": true, | |
497 | "current": false, |
|
497 | "current": false, | |
498 | "node": "f894c25619d3f1484639d81be950e0a07bc6f1f6", |
|
498 | "node": "f894c25619d3f1484639d81be950e0a07bc6f1f6", | |
499 | "rev": 14 |
|
499 | "rev": 14 | |
500 | }, |
|
500 | }, | |
501 | { |
|
501 | { | |
502 | "active": false, |
|
502 | "active": false, | |
503 | "branch": "a", |
|
503 | "branch": "a", | |
504 | "closed": false, |
|
504 | "closed": false, | |
505 | "current": false, |
|
505 | "current": false, | |
506 | "node": "d8cbc61dbaa6dc817175d1e301eecb863f280832", |
|
506 | "node": "d8cbc61dbaa6dc817175d1e301eecb863f280832", | |
507 | "rev": 5 |
|
507 | "rev": 5 | |
508 | }, |
|
508 | }, | |
509 | { |
|
509 | { | |
510 | "active": false, |
|
510 | "active": false, | |
511 | "branch": "default", |
|
511 | "branch": "default", | |
512 | "closed": false, |
|
512 | "closed": false, | |
513 | "current": false, |
|
513 | "current": false, | |
514 | "node": "19709c5a4e75bf938f8e349aff97438539bb729e", |
|
514 | "node": "19709c5a4e75bf938f8e349aff97438539bb729e", | |
515 | "rev": 0 |
|
515 | "rev": 0 | |
516 | } |
|
516 | } | |
517 | ] |
|
517 | ] | |
518 |
|
518 | |||
519 |
|
519 | |||
520 | Tests of revision branch name caching |
|
520 | Tests of revision branch name caching | |
521 |
|
521 | |||
522 | We rev branch cache is updated automatically. In these tests we use a trick to |
|
522 | We rev branch cache is updated automatically. In these tests we use a trick to | |
523 | trigger rebuilds. We remove the branch head cache and run 'hg head' to cause a |
|
523 | trigger rebuilds. We remove the branch head cache and run 'hg head' to cause a | |
524 | rebuild that also will populate the rev branch cache. |
|
524 | rebuild that also will populate the rev branch cache. | |
525 |
|
525 | |||
526 | revision branch cache is created when building the branch head cache |
|
526 | revision branch cache is created when building the branch head cache | |
527 | $ rm -rf .hg/cache; hg head a -T '{rev}\n' |
|
527 | $ rm -rf .hg/cache; hg head a -T '{rev}\n' | |
528 | 5 |
|
528 | 5 | |
529 | $ f --hexdump --size .hg/cache/rbc-* |
|
529 | $ f --hexdump --size .hg/cache/rbc-* | |
530 | .hg/cache/rbc-names-v1: size=87 |
|
530 | .hg/cache/rbc-names-v1: size=87 | |
531 | 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a | |
|
531 | 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a | | |
532 | 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much| |
|
532 | 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much| | |
533 | 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the| |
|
533 | 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the| | |
534 | 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi| |
|
534 | 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi| | |
535 | 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b| |
|
535 | 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b| | |
536 | 0050: 72 61 6e 63 68 65 73 |ranches| |
|
536 | 0050: 72 61 6e 63 68 65 73 |ranches| | |
537 | .hg/cache/rbc-revs-v1: size=120 |
|
537 | .hg/cache/rbc-revs-v1: size=120 | |
538 | 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| |
|
538 | 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| | |
539 | 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....| |
|
539 | 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....| | |
540 | 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................| |
|
540 | 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................| | |
541 | 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....| |
|
541 | 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....| | |
542 | 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....| |
|
542 | 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....| | |
543 | 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....| |
|
543 | 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....| | |
544 | 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....| |
|
544 | 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....| | |
545 | 0070: f8 94 c2 56 80 00 00 03 |...V....| |
|
545 | 0070: f8 94 c2 56 80 00 00 03 |...V....| | |
546 |
|
546 | |||
547 | no errors when revbranchcache is not writable |
|
547 | no errors when revbranchcache is not writable | |
548 |
|
548 | |||
549 | $ echo >> .hg/cache/rbc-revs-v1 |
|
549 | $ echo >> .hg/cache/rbc-revs-v1 | |
550 | $ mv .hg/cache/rbc-revs-v1 .hg/cache/rbc-revs-v1_ |
|
550 | $ mv .hg/cache/rbc-revs-v1 .hg/cache/rbc-revs-v1_ | |
551 | $ mkdir .hg/cache/rbc-revs-v1 |
|
551 | $ mkdir .hg/cache/rbc-revs-v1 | |
552 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' |
|
552 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' | |
553 | 5 |
|
553 | 5 | |
554 | $ rmdir .hg/cache/rbc-revs-v1 |
|
554 | $ rmdir .hg/cache/rbc-revs-v1 | |
555 | $ mv .hg/cache/rbc-revs-v1_ .hg/cache/rbc-revs-v1 |
|
555 | $ mv .hg/cache/rbc-revs-v1_ .hg/cache/rbc-revs-v1 | |
556 |
|
556 | |||
|
557 | no errors when wlock cannot be acquired | |||
|
558 | ||||
|
559 | #if unix-permissions | |||
|
560 | $ mv .hg/cache/rbc-revs-v1 .hg/cache/rbc-revs-v1_ | |||
|
561 | $ rm -f .hg/cache/branch* | |||
|
562 | $ chmod 555 .hg | |||
|
563 | $ hg head a -T '{rev}\n' | |||
|
564 | 5 | |||
|
565 | $ chmod 755 .hg | |||
|
566 | $ mv .hg/cache/rbc-revs-v1_ .hg/cache/rbc-revs-v1 | |||
|
567 | #endif | |||
|
568 | ||||
557 | recovery from invalid cache revs file with trailing data |
|
569 | recovery from invalid cache revs file with trailing data | |
558 | $ echo >> .hg/cache/rbc-revs-v1 |
|
570 | $ echo >> .hg/cache/rbc-revs-v1 | |
559 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug |
|
571 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug | |
560 | 5 |
|
572 | 5 | |
561 | truncating cache/rbc-revs-v1 to 120 |
|
573 | truncating cache/rbc-revs-v1 to 120 | |
562 | $ f --size .hg/cache/rbc-revs* |
|
574 | $ f --size .hg/cache/rbc-revs* | |
563 | .hg/cache/rbc-revs-v1: size=120 |
|
575 | .hg/cache/rbc-revs-v1: size=120 | |
564 | recovery from invalid cache file with partial last record |
|
576 | recovery from invalid cache file with partial last record | |
565 | $ mv .hg/cache/rbc-revs-v1 . |
|
577 | $ mv .hg/cache/rbc-revs-v1 . | |
566 | $ f -qDB 119 rbc-revs-v1 > .hg/cache/rbc-revs-v1 |
|
578 | $ f -qDB 119 rbc-revs-v1 > .hg/cache/rbc-revs-v1 | |
567 | $ f --size .hg/cache/rbc-revs* |
|
579 | $ f --size .hg/cache/rbc-revs* | |
568 | .hg/cache/rbc-revs-v1: size=119 |
|
580 | .hg/cache/rbc-revs-v1: size=119 | |
569 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug |
|
581 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug | |
570 | 5 |
|
582 | 5 | |
571 | truncating cache/rbc-revs-v1 to 112 |
|
583 | truncating cache/rbc-revs-v1 to 112 | |
572 | $ f --size .hg/cache/rbc-revs* |
|
584 | $ f --size .hg/cache/rbc-revs* | |
573 | .hg/cache/rbc-revs-v1: size=120 |
|
585 | .hg/cache/rbc-revs-v1: size=120 | |
574 | recovery from invalid cache file with missing record - no truncation |
|
586 | recovery from invalid cache file with missing record - no truncation | |
575 | $ mv .hg/cache/rbc-revs-v1 . |
|
587 | $ mv .hg/cache/rbc-revs-v1 . | |
576 | $ f -qDB 112 rbc-revs-v1 > .hg/cache/rbc-revs-v1 |
|
588 | $ f -qDB 112 rbc-revs-v1 > .hg/cache/rbc-revs-v1 | |
577 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug |
|
589 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug | |
578 | 5 |
|
590 | 5 | |
579 | $ f --size .hg/cache/rbc-revs* |
|
591 | $ f --size .hg/cache/rbc-revs* | |
580 | .hg/cache/rbc-revs-v1: size=120 |
|
592 | .hg/cache/rbc-revs-v1: size=120 | |
581 | recovery from invalid cache file with some bad records |
|
593 | recovery from invalid cache file with some bad records | |
582 | $ mv .hg/cache/rbc-revs-v1 . |
|
594 | $ mv .hg/cache/rbc-revs-v1 . | |
583 | $ f -qDB 8 rbc-revs-v1 > .hg/cache/rbc-revs-v1 |
|
595 | $ f -qDB 8 rbc-revs-v1 > .hg/cache/rbc-revs-v1 | |
584 | $ f --size .hg/cache/rbc-revs* |
|
596 | $ f --size .hg/cache/rbc-revs* | |
585 | .hg/cache/rbc-revs-v1: size=8 |
|
597 | .hg/cache/rbc-revs-v1: size=8 | |
586 | $ f -qDB 112 rbc-revs-v1 >> .hg/cache/rbc-revs-v1 |
|
598 | $ f -qDB 112 rbc-revs-v1 >> .hg/cache/rbc-revs-v1 | |
587 | $ f --size .hg/cache/rbc-revs* |
|
599 | $ f --size .hg/cache/rbc-revs* | |
588 | .hg/cache/rbc-revs-v1: size=120 |
|
600 | .hg/cache/rbc-revs-v1: size=120 | |
589 | $ hg log -r 'branch(.)' -T '{rev} ' --debug |
|
601 | $ hg log -r 'branch(.)' -T '{rev} ' --debug | |
590 | history modification detected - truncating revision branch cache to revision 13 |
|
602 | history modification detected - truncating revision branch cache to revision 13 | |
591 | history modification detected - truncating revision branch cache to revision 1 |
|
603 | history modification detected - truncating revision branch cache to revision 1 | |
592 | 3 4 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 8 |
|
604 | 3 4 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 8 | |
593 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug |
|
605 | $ rm -f .hg/cache/branch* && hg head a -T '{rev}\n' --debug | |
594 | 5 |
|
606 | 5 | |
595 | truncating cache/rbc-revs-v1 to 104 |
|
607 | truncating cache/rbc-revs-v1 to 104 | |
596 | $ f --size --hexdump --bytes=16 .hg/cache/rbc-revs* |
|
608 | $ f --size --hexdump --bytes=16 .hg/cache/rbc-revs* | |
597 | .hg/cache/rbc-revs-v1: size=120 |
|
609 | .hg/cache/rbc-revs-v1: size=120 | |
598 | 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| |
|
610 | 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| | |
599 | cache is updated when committing |
|
611 | cache is updated when committing | |
600 | $ hg branch i-will-regret-this |
|
612 | $ hg branch i-will-regret-this | |
601 | marked working directory as branch i-will-regret-this |
|
613 | marked working directory as branch i-will-regret-this | |
602 | $ hg ci -m regrets |
|
614 | $ hg ci -m regrets | |
603 | $ f --size .hg/cache/rbc-* |
|
615 | $ f --size .hg/cache/rbc-* | |
604 | .hg/cache/rbc-names-v1: size=106 |
|
616 | .hg/cache/rbc-names-v1: size=106 | |
605 | .hg/cache/rbc-revs-v1: size=128 |
|
617 | .hg/cache/rbc-revs-v1: size=128 | |
606 | update after rollback - the cache will be correct but rbc-names will will still |
|
618 | update after rollback - the cache will be correct but rbc-names will will still | |
607 | contain the branch name even though it no longer is used |
|
619 | contain the branch name even though it no longer is used | |
608 | $ hg up -qr '.^' |
|
620 | $ hg up -qr '.^' | |
609 | $ hg rollback -qf |
|
621 | $ hg rollback -qf | |
610 | $ f --size --hexdump .hg/cache/rbc-* |
|
622 | $ f --size --hexdump .hg/cache/rbc-* | |
611 | .hg/cache/rbc-names-v1: size=106 |
|
623 | .hg/cache/rbc-names-v1: size=106 | |
612 | 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a | |
|
624 | 0000: 64 65 66 61 75 6c 74 00 61 00 62 00 63 00 61 20 |default.a.b.c.a | | |
613 | 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much| |
|
625 | 0010: 62 72 61 6e 63 68 20 6e 61 6d 65 20 6d 75 63 68 |branch name much| | |
614 | 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the| |
|
626 | 0020: 20 6c 6f 6e 67 65 72 20 74 68 61 6e 20 74 68 65 | longer than the| | |
615 | 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi| |
|
627 | 0030: 20 64 65 66 61 75 6c 74 20 6a 75 73 74 69 66 69 | default justifi| | |
616 | 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b| |
|
628 | 0040: 63 61 74 69 6f 6e 20 75 73 65 64 20 62 79 20 62 |cation used by b| | |
617 | 0050: 72 61 6e 63 68 65 73 00 69 2d 77 69 6c 6c 2d 72 |ranches.i-will-r| |
|
629 | 0050: 72 61 6e 63 68 65 73 00 69 2d 77 69 6c 6c 2d 72 |ranches.i-will-r| | |
618 | 0060: 65 67 72 65 74 2d 74 68 69 73 |egret-this| |
|
630 | 0060: 65 67 72 65 74 2d 74 68 69 73 |egret-this| | |
619 | .hg/cache/rbc-revs-v1: size=120 |
|
631 | .hg/cache/rbc-revs-v1: size=120 | |
620 | 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| |
|
632 | 0000: 19 70 9c 5a 00 00 00 00 dd 6b 44 0d 00 00 00 01 |.p.Z.....kD.....| | |
621 | 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....| |
|
633 | 0010: 88 1f e2 b9 00 00 00 01 ac 22 03 33 00 00 00 02 |.........".3....| | |
622 | 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................| |
|
634 | 0020: ae e3 9c d1 00 00 00 02 d8 cb c6 1d 00 00 00 01 |................| | |
623 | 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....| |
|
635 | 0030: 58 97 36 a2 00 00 00 03 10 ff 58 95 00 00 00 04 |X.6.......X.....| | |
624 | 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....| |
|
636 | 0040: ee bb 94 44 00 00 00 02 5f 40 61 bb 00 00 00 02 |...D...._@a.....| | |
625 | 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....| |
|
637 | 0050: bf be 84 1b 00 00 00 02 d3 f1 63 45 80 00 00 02 |..........cE....| | |
626 | 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....| |
|
638 | 0060: e3 d4 9c 05 80 00 00 02 e2 3b 55 05 00 00 00 02 |.........;U.....| | |
627 | 0070: f8 94 c2 56 80 00 00 03 |...V....| |
|
639 | 0070: f8 94 c2 56 80 00 00 03 |...V....| | |
628 | cache is updated/truncated when stripping - it is thus very hard to get in a |
|
640 | cache is updated/truncated when stripping - it is thus very hard to get in a | |
629 | situation where the cache is out of sync and the hash check detects it |
|
641 | situation where the cache is out of sync and the hash check detects it | |
630 | $ hg --config extensions.strip= strip -r tip --nob |
|
642 | $ hg --config extensions.strip= strip -r tip --nob | |
631 | $ f --size .hg/cache/rbc-revs* |
|
643 | $ f --size .hg/cache/rbc-revs* | |
632 | .hg/cache/rbc-revs-v1: size=112 |
|
644 | .hg/cache/rbc-revs-v1: size=112 | |
633 |
|
645 | |||
634 | cache is rebuilt when corruption is detected |
|
646 | cache is rebuilt when corruption is detected | |
635 | $ echo > .hg/cache/rbc-names-v1 |
|
647 | $ echo > .hg/cache/rbc-names-v1 | |
636 | $ hg log -r '5:&branch(.)' -T '{rev} ' --debug |
|
648 | $ hg log -r '5:&branch(.)' -T '{rev} ' --debug | |
637 | referenced branch names not found - rebuilding revision branch cache from scratch |
|
649 | referenced branch names not found - rebuilding revision branch cache from scratch | |
638 | 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 40 |
|
650 | 8 9 10 11 12 13 truncating cache/rbc-revs-v1 to 40 | |
639 | $ f --size --hexdump .hg/cache/rbc-* |
|
651 | $ f --size --hexdump .hg/cache/rbc-* | |
640 | .hg/cache/rbc-names-v1: size=79 |
|
652 | .hg/cache/rbc-names-v1: size=79 | |
641 | 0000: 62 00 61 00 63 00 61 20 62 72 61 6e 63 68 20 6e |b.a.c.a branch n| |
|
653 | 0000: 62 00 61 00 63 00 61 20 62 72 61 6e 63 68 20 6e |b.a.c.a branch n| | |
642 | 0010: 61 6d 65 20 6d 75 63 68 20 6c 6f 6e 67 65 72 20 |ame much longer | |
|
654 | 0010: 61 6d 65 20 6d 75 63 68 20 6c 6f 6e 67 65 72 20 |ame much longer | | |
643 | 0020: 74 68 61 6e 20 74 68 65 20 64 65 66 61 75 6c 74 |than the default| |
|
655 | 0020: 74 68 61 6e 20 74 68 65 20 64 65 66 61 75 6c 74 |than the default| | |
644 | 0030: 20 6a 75 73 74 69 66 69 63 61 74 69 6f 6e 20 75 | justification u| |
|
656 | 0030: 20 6a 75 73 74 69 66 69 63 61 74 69 6f 6e 20 75 | justification u| | |
645 | 0040: 73 65 64 20 62 79 20 62 72 61 6e 63 68 65 73 |sed by branches| |
|
657 | 0040: 73 65 64 20 62 79 20 62 72 61 6e 63 68 65 73 |sed by branches| | |
646 | .hg/cache/rbc-revs-v1: size=112 |
|
658 | .hg/cache/rbc-revs-v1: size=112 | |
647 | 0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
|
659 | 0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
648 | 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
|
660 | 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
649 | 0020: 00 00 00 00 00 00 00 00 d8 cb c6 1d 00 00 00 01 |................| |
|
661 | 0020: 00 00 00 00 00 00 00 00 d8 cb c6 1d 00 00 00 01 |................| | |
650 | 0030: 58 97 36 a2 00 00 00 02 10 ff 58 95 00 00 00 03 |X.6.......X.....| |
|
662 | 0030: 58 97 36 a2 00 00 00 02 10 ff 58 95 00 00 00 03 |X.6.......X.....| | |
651 | 0040: ee bb 94 44 00 00 00 00 5f 40 61 bb 00 00 00 00 |...D...._@a.....| |
|
663 | 0040: ee bb 94 44 00 00 00 00 5f 40 61 bb 00 00 00 00 |...D...._@a.....| | |
652 | 0050: bf be 84 1b 00 00 00 00 d3 f1 63 45 80 00 00 00 |..........cE....| |
|
664 | 0050: bf be 84 1b 00 00 00 00 d3 f1 63 45 80 00 00 00 |..........cE....| | |
653 | 0060: e3 d4 9c 05 80 00 00 00 e2 3b 55 05 00 00 00 00 |.........;U.....| |
|
665 | 0060: e3 d4 9c 05 80 00 00 00 e2 3b 55 05 00 00 00 00 |.........;U.....| | |
654 |
|
666 | |||
655 | Test that cache files are created and grows correctly: |
|
667 | Test that cache files are created and grows correctly: | |
656 |
|
668 | |||
657 | $ rm .hg/cache/rbc* |
|
669 | $ rm .hg/cache/rbc* | |
658 | $ hg log -r "5 & branch(5)" -T "{rev}\n" |
|
670 | $ hg log -r "5 & branch(5)" -T "{rev}\n" | |
659 | 5 |
|
671 | 5 | |
660 | $ f --size --hexdump .hg/cache/rbc-* |
|
672 | $ f --size --hexdump .hg/cache/rbc-* | |
661 | .hg/cache/rbc-names-v1: size=1 |
|
673 | .hg/cache/rbc-names-v1: size=1 | |
662 | 0000: 61 |a| |
|
674 | 0000: 61 |a| | |
663 | .hg/cache/rbc-revs-v1: size=112 |
|
675 | .hg/cache/rbc-revs-v1: size=112 | |
664 | 0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
|
676 | 0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
665 | 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
|
677 | 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
666 | 0020: 00 00 00 00 00 00 00 00 d8 cb c6 1d 00 00 00 00 |................| |
|
678 | 0020: 00 00 00 00 00 00 00 00 d8 cb c6 1d 00 00 00 00 |................| | |
667 | 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
|
679 | 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
668 | 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
|
680 | 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
669 | 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
|
681 | 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
670 | 0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |
|
682 | 0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
671 |
|
683 | |||
672 | $ cd .. |
|
684 | $ cd .. | |
673 |
|
685 | |||
674 | Test for multiple incorrect branch cache entries: |
|
686 | Test for multiple incorrect branch cache entries: | |
675 |
|
687 | |||
676 | $ hg init b |
|
688 | $ hg init b | |
677 | $ cd b |
|
689 | $ cd b | |
678 | $ touch f |
|
690 | $ touch f | |
679 | $ hg ci -Aqmf |
|
691 | $ hg ci -Aqmf | |
680 | $ echo >> f |
|
692 | $ echo >> f | |
681 | $ hg ci -Amf |
|
693 | $ hg ci -Amf | |
682 | $ hg branch -q branch |
|
694 | $ hg branch -q branch | |
683 | $ hg ci -Amf |
|
695 | $ hg ci -Amf | |
684 |
|
696 | |||
685 | $ f --size --hexdump .hg/cache/rbc-* |
|
697 | $ f --size --hexdump .hg/cache/rbc-* | |
686 | .hg/cache/rbc-names-v1: size=14 |
|
698 | .hg/cache/rbc-names-v1: size=14 | |
687 | 0000: 64 65 66 61 75 6c 74 00 62 72 61 6e 63 68 |default.branch| |
|
699 | 0000: 64 65 66 61 75 6c 74 00 62 72 61 6e 63 68 |default.branch| | |
688 | .hg/cache/rbc-revs-v1: size=24 |
|
700 | .hg/cache/rbc-revs-v1: size=24 | |
689 | 0000: 66 e5 f5 aa 00 00 00 00 fa 4c 04 e5 00 00 00 00 |f........L......| |
|
701 | 0000: 66 e5 f5 aa 00 00 00 00 fa 4c 04 e5 00 00 00 00 |f........L......| | |
690 | 0010: 56 46 78 69 00 00 00 01 |VFxi....| |
|
702 | 0010: 56 46 78 69 00 00 00 01 |VFxi....| | |
691 | $ : > .hg/cache/rbc-revs-v1 |
|
703 | $ : > .hg/cache/rbc-revs-v1 | |
692 |
|
704 | |||
693 | No superfluous rebuilding of cache: |
|
705 | No superfluous rebuilding of cache: | |
694 | $ hg log -r "branch(null)&branch(branch)" --debug |
|
706 | $ hg log -r "branch(null)&branch(branch)" --debug | |
695 | $ f --size --hexdump .hg/cache/rbc-* |
|
707 | $ f --size --hexdump .hg/cache/rbc-* | |
696 | .hg/cache/rbc-names-v1: size=14 |
|
708 | .hg/cache/rbc-names-v1: size=14 | |
697 | 0000: 64 65 66 61 75 6c 74 00 62 72 61 6e 63 68 |default.branch| |
|
709 | 0000: 64 65 66 61 75 6c 74 00 62 72 61 6e 63 68 |default.branch| | |
698 | .hg/cache/rbc-revs-v1: size=24 |
|
710 | .hg/cache/rbc-revs-v1: size=24 | |
699 | 0000: 66 e5 f5 aa 00 00 00 00 fa 4c 04 e5 00 00 00 00 |f........L......| |
|
711 | 0000: 66 e5 f5 aa 00 00 00 00 fa 4c 04 e5 00 00 00 00 |f........L......| | |
700 | 0010: 56 46 78 69 00 00 00 01 |VFxi....| |
|
712 | 0010: 56 46 78 69 00 00 00 01 |VFxi....| | |
701 |
|
713 | |||
702 | $ cd .. |
|
714 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now