# HG changeset patch
# Parent f786fc4b8764cd2a5526d259cf2f94d8a66924d9
convert: add incremental tagging mode
Instead of performing a whole conversion, then adding all the tags,
we propose to add a tag as soon as its parent was converted.
The old behavior is kept by default and the new one is used
if 'convert.incrementaltagging' is True.
diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
|
a
|
b
|
class converter(object): |
| 342 | 342 | t = self.toposort(parents, sortmode) |
| 343 | 343 | num = len(t) |
| 344 | 344 | c = None |
| | 345 | tags = self.source.gettags() |
| | 346 | rtags = dict((v, k) for k, v in tags.items()) |
| | 347 | incr = self.ui.configbool('convert', 'incrementaltagging', False) |
| 345 | 348 | |
| 346 | 349 | self.ui.status(_("converting...\n")) |
| 347 | 350 | for i, c in enumerate(t): |
| … |
… |
class converter(object): |
| 357 | 360 | self.ui.progress(_('converting'), i, unit=_('revisions'), |
| 358 | 361 | total=len(t)) |
| 359 | 362 | self.copy(c) |
| | 363 | tag = rtags.get(c) |
| | 364 | if incr and tag: |
| | 365 | ctag = self.map.get(c, SKIPREV) |
| | 366 | if ctag != SKIPREV: |
| | 367 | self.maketags({tag: ctag}) |
| 360 | 368 | self.ui.progress(_('converting'), None) |
| 361 | 369 | |
| 362 | | tags = self.source.gettags() |
| 363 | | ctags = {} |
| 364 | | for k in tags: |
| 365 | | v = tags[k] |
| 366 | | if self.map.get(v, SKIPREV) != SKIPREV: |
| 367 | | ctags[k] = self.map[v] |
| 368 | | |
| 369 | | if c and ctags: |
| 370 | | nrev, tagsparent = self.dest.puttags(ctags) |
| 371 | | if nrev and tagsparent: |
| 372 | | # write another hash correspondence to override the previous |
| 373 | | # one so we don't end up with extra tag heads |
| 374 | | tagsparents = [e for e in self.map.iteritems() |
| 375 | | if e[1] == tagsparent] |
| 376 | | if tagsparents: |
| 377 | | self.map[tagsparents[0][0]] = nrev |
| | 370 | if not incr: |
| | 371 | ctags = {} |
| | 372 | for k in tags: |
| | 373 | v = tags[k] |
| | 374 | if self.map.get(v, SKIPREV) != SKIPREV: |
| | 375 | ctags[k] = self.map[v] |
| | 376 | if c and ctags: |
| | 377 | self.maketags(ctags) |
| 378 | 378 | |
| 379 | 379 | self.writeauthormap() |
| 380 | 380 | finally: |
| 381 | 381 | self.cleanup() |
| 382 | 382 | |
| | 383 | def maketags(self, ctags): |
| | 384 | nrev, tagsparent = self.dest.puttags(ctags) |
| | 385 | if nrev and tagsparent: |
| | 386 | # write another hash correspondence to override the previous |
| | 387 | # one so we don't end up with extra tag heads |
| | 388 | tagsparents = [e for e in self.map.iteritems() |
| | 389 | if e[1] == tagsparent] |
| | 390 | if tagsparents: |
| | 391 | self.map[tagsparents[0][0]] = nrev |
| | 392 | |
| 383 | 393 | def cleanup(self): |
| 384 | 394 | try: |
| 385 | 395 | self.dest.after() |