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