Mercurial > hg > hg-fastimport
diff hgfastimport/hgimport.py @ 58:c370e587f483
Handle commits commands that reference a tag better.
| author | Greg Ward <gward@intelerad.com> |
|---|---|
| date | Mon, 01 Aug 2011 18:35:31 -0400 |
| parents | e827bffa5fc5 |
| children | c82b6a84884f |
line wrap: on
line diff
--- a/hgfastimport/hgimport.py Mon Aug 01 18:18:24 2011 -0400 +++ b/hgfastimport/hgimport.py Mon Aug 01 18:35:31 2011 -0400 @@ -128,6 +128,8 @@ class HgImportProcessor(processor.ImportProcessor): + tagprefix = "refs/tags/" + def __init__(self, ui, repo): super(HgImportProcessor, self).__init__() self.ui = ui @@ -202,13 +204,15 @@ def _getcommit(self, commitref): """Given a mark reference or a branch name, return the - appropriate commit object. Return None if committish is a - branch with no commits. Raises KeyError if anything else is out - of whack. + appropriate commit object. Return None if commitref is a tag + or a branch with no commits. Raises KeyError if anything else + is out of whack. """ if commitref.startswith(":"): # KeyError here indicates the input stream is broken. return self.commitmap[commitref] + elif commitref.startswith(self.tagprefix): + return None else: branch = self._getbranch(commitref) if branch is None: @@ -245,6 +249,10 @@ # of the fixup branch should be configurable! fixup = (cmd.ref == "refs/heads/TAG.FIXUP") + if cmd.ref.startswith(self.tagprefix) and cmd.mark: + tag = cmd.ref[len(self.tagprefix):] + self.tags.append((tag, ':' + cmd.mark)) + if cmd.from_: first_parent = cmd.from_ else: @@ -334,7 +342,6 @@ return "%d %d" % res def reset_handler(self, cmd): - tagprefix = "refs/tags/" branch = self._getbranch(cmd.ref) if branch: # The usual case for 'reset': (re)create the named branch. @@ -350,15 +357,16 @@ #else: # # XXX filename? line number? # self.ui.warn("ignoring branch reset with no 'from'\n") - elif cmd.ref.startswith(tagprefix): + elif cmd.ref.startswith(self.tagprefix): # Create a "lightweight tag" in Git terms. As I understand # it, that's a tag with no description and no history -- # rather like CVS tags. cvs2git turns CVS tags into Git # lightweight tags, so we should make sure they become # Mercurial tags. But we don't have to fake a history for # them; save them up for the end. - tag = cmd.ref[len(tagprefix):] - self.tags.append((tag, cmd.from_)) + if cmd.from_ is not None: + tag = cmd.ref[len(self.tagprefix):] + self.tags.append((tag, cmd.from_)) def tag_handler(self, cmd): pass
