Show More
@@ -258,63 +258,67 b' class localrepository(repo.repository):' | |||
|
258 | 258 | # be one tagtype for all such "virtual" tags? Or is the status |
|
259 | 259 | # quo fine? |
|
260 | 260 | |
|
261 | globaltags = {} | |
|
261 | alltags = {} # map tag name to (node, hist) | |
|
262 | 262 | tagtypes = {} |
|
263 | 263 | |
|
264 | 264 | def readtags(lines, fn, tagtype): |
|
265 | filetags = {} | |
|
265 | filetags = {} # map tag name to (node, hist) | |
|
266 | 266 | count = 0 |
|
267 | 267 | |
|
268 | 268 | def warn(msg): |
|
269 | 269 | self.ui.warn(_("%s, line %s: %s\n") % (fn, count, msg)) |
|
270 | 270 | |
|
271 | for l in lines: | |
|
271 | for line in lines: | |
|
272 | 272 | count += 1 |
|
273 | if not l: | |
|
273 | if not line: | |
|
274 | 274 | continue |
|
275 |
|
|
|
276 | if len(s) != 2: | |
|
275 | try: | |
|
276 | (nodehex, name) = line.split(" ", 1) | |
|
277 | except ValueError: | |
|
277 | 278 | warn(_("cannot parse entry")) |
|
278 | 279 | continue |
|
279 | node, key = s | |
|
280 | key = encoding.tolocal(key.strip()) # stored in UTF-8 | |
|
280 | name = encoding.tolocal(name.strip()) # stored in UTF-8 | |
|
281 | 281 | try: |
|
282 |
bin |
|
|
282 | nodebin = bin(nodehex) | |
|
283 | 283 | except TypeError: |
|
284 | warn(_("node '%s' is not well formed") % node) | |
|
284 | warn(_("node '%s' is not well formed") % nodehex) | |
|
285 | 285 | continue |
|
286 |
if bin |
|
|
286 | if nodebin not in self.changelog.nodemap: | |
|
287 | 287 | # silently ignore as pull -r might cause this |
|
288 | 288 | continue |
|
289 | 289 | |
|
290 | h = [] | |
|
291 | if key in filetags: | |
|
292 | n, h = filetags[key] | |
|
293 | h.append(n) | |
|
294 |
|
|
|
290 | # update filetags: map tag name to (node, hist) where | |
|
291 | # node is the node from the latest line read with | |
|
292 | # 'name', and hist is the list of nodes previously | |
|
293 | # associated with 'name' | |
|
294 | hist = [] | |
|
295 | if name in filetags: | |
|
296 | n, hist = filetags[name] | |
|
297 | hist.append(n) | |
|
298 | filetags[name] = (nodebin, hist) | |
|
295 | 299 | |
|
296 |
for |
|
|
297 |
if |
|
|
298 |
|
|
|
299 |
tagtypes[ |
|
|
300 | for name, nodehist in filetags.iteritems(): | |
|
301 | if name not in alltags: | |
|
302 | alltags[name] = nodehist | |
|
303 | tagtypes[name] = tagtype | |
|
300 | 304 | continue |
|
301 | 305 | |
|
302 |
# we prefer |
|
|
306 | # we prefer alltags[name] if: | |
|
303 | 307 | # it supercedes us OR |
|
304 | 308 | # mutual supercedes and it has a higher rank |
|
305 | 309 | # otherwise we win because we're tip-most |
|
306 | an, ah = nh | |
|
307 |
bn, bh = |
|
|
308 | if (bn != an and an in bh and | |
|
309 | (bn not in ah or len(bh) > len(ah))): | |
|
310 | an = bn | |
|
311 | ah.extend([n for n in bh if n not in ah]) | |
|
312 |
|
|
|
313 |
tagtypes[ |
|
|
310 | anode, ahist = nodehist | |
|
311 | bnode, bhist = alltags[name] | |
|
312 | if (bnode != anode and anode in bhist and | |
|
313 | (bnode not in ahist or len(bhist) > len(ahist))): | |
|
314 | anode = bnode | |
|
315 | ahist.extend([n for n in bhist if n not in ahist]) | |
|
316 | alltags[name] = anode, ahist | |
|
317 | tagtypes[name] = tagtype | |
|
314 | 318 | |
|
315 | 319 | seen = set() |
|
316 | f = None | |
|
317 | ctxs = [] | |
|
320 | fctx = None | |
|
321 | ctxs = [] # list of filectx | |
|
318 | 322 | for node in self.heads(): |
|
319 | 323 | try: |
|
320 | 324 | fnode = self[node].filenode('.hgtags') |
@@ -322,15 +326,15 b' class localrepository(repo.repository):' | |||
|
322 | 326 | continue |
|
323 | 327 | if fnode not in seen: |
|
324 | 328 | seen.add(fnode) |
|
325 | if not f: | |
|
326 | f = self.filectx('.hgtags', fileid=fnode) | |
|
329 | if not fctx: | |
|
330 | fctx = self.filectx('.hgtags', fileid=fnode) | |
|
327 | 331 | else: |
|
328 | f = f.filectx(fnode) | |
|
329 | ctxs.append(f) | |
|
332 | fctx = fctx.filectx(fnode) | |
|
333 | ctxs.append(fctx) | |
|
330 | 334 | |
|
331 | 335 | # read the tags file from each head, ending with the tip |
|
332 | for f in reversed(ctxs): | |
|
333 | readtags(f.data().splitlines(), f, "global") | |
|
336 | for fctx in reversed(ctxs): | |
|
337 | readtags(fctx.data().splitlines(), fctx, "global") | |
|
334 | 338 | |
|
335 | 339 | try: |
|
336 | 340 | data = encoding.fromlocal(self.opener("localtags").read()) |
@@ -341,10 +345,9 b' class localrepository(repo.repository):' | |||
|
341 | 345 | pass |
|
342 | 346 | |
|
343 | 347 | tags = {} |
|
344 |
for |
|
|
345 |
|
|
|
346 |
|
|
|
347 | tags[k] = n | |
|
348 | for (name, (node, hist)) in alltags.iteritems(): | |
|
349 | if node != nullid: | |
|
350 | tags[name] = node | |
|
348 | 351 | tags['tip'] = self.changelog.tip() |
|
349 | 352 | return (tags, tagtypes) |
|
350 | 353 |
General Comments 0
You need to be logged in to leave comments.
Login now