Changeset 1005 in tailor for vcpx/hglib.py


Ignore:
Timestamp:
11/16/05 06:26:26 (8 years ago)
Author:
Brendan Cully <brendan@…>
Hash name:
20051116052626-0ae3a-850fe3bd8a422ae4410d898d5ad2c2498207bd03
Message:

Don't apply duplicate tags to mercurial targets

I just noticed that a CVS source will replay all of the tags that apply
to HEAD on every run. This teaches mercurial to filter out equivalent tags
(by checking whether they already exist in the commit history up to the last
non-tag commit).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/hglib.py

    r1004 r1005  
    199199 
    200200    def _tag(self, tag): 
     201        """ Tag the tip with a given identifier """ 
     202        # TODO: keep a handle on the changeset holding this tag? Then 
     203        # we can extract author, log, date from it. 
    201204        opts = self._defaultOpts('tag') 
    202         commands.tag(self._getUI(), self._getRepo(), str(tag), **opts) 
     205 
     206        # This seems gross. I don't get why I'm getting a unicode tag when 
     207        # it's just ascii underneath. Something weird is happening in CVS. 
     208        tag = tag.encode(self.repository.encoding) 
     209        # CVS can't tell when a tag was applied so it tends to pass around 
     210        # too many. We want to support retagging so we can't just ignore 
     211        # duplicates. But we can safely ignore a tag if it is contained 
     212        # in the commit history from tip back to the last non-tag commit. 
     213        repo = self._getRepo() 
     214        tagnodes = repo.tags().values() 
     215        try: 
     216            tagnode = repo.tags()[tag] 
     217            # tag commit can't be merge, right? 
     218            parent = repo.changelog.parents(repo.changelog.tip())[0] 
     219            while parent in tagnodes: 
     220                if tagnode == parent: 
     221                    return 
     222                parent = repo.changelog.parents(parent)[0] 
     223        except KeyError: 
     224            pass 
     225        commands.tag(self._getUI(), repo, tag, **opts) 
    203226 
    204227    def _defaultOpts(self, cmd): 
Note: See TracChangeset for help on using the changeset viewer.