Edgewall Software

Ticket #9235: incrementaltagging-hg16.patch

File incrementaltagging-hg16.patch, 2.9 KB (added by cboos, 22 months ago)

convert: add incremental tagging mode

  • hgext/convert/convcmd.py

    # 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): 
    342342            t = self.toposort(parents, sortmode) 
    343343            num = len(t) 
    344344            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) 
    345348 
    346349            self.ui.status(_("converting...\n")) 
    347350            for i, c in enumerate(t):                 
    class converter(object): 
    357360                self.ui.progress(_('converting'), i, unit=_('revisions'), 
    358361                                 total=len(t)) 
    359362                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}) 
    360368            self.ui.progress(_('converting'), None) 
    361369 
    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) 
    378378 
    379379            self.writeauthormap() 
    380380        finally: 
    381381            self.cleanup() 
    382382 
     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 
    383393    def cleanup(self): 
    384394        try: 
    385395            self.dest.after()