Commits

kankri committed 4668f06

git_handler: raise RepoError() if 'tagtypes' attribute is not found in the repo object

Comments (0)

Files changed (1)

hggit/git_handler.py

                         " attribute in class %s" % self.repo.__class__.__name__
                     )
 
-                if (hgutil.safehasattr(self.repo, '_tagtypes') and
-                    self.repo._tagtypes and
-                    name in self.repo._tagtypes):
+                if hgutil.safehasattr(self.repo, '_tagtypes'):
                     # Mercurial 1.9 and earlier.
-                    del self.repo._tagtypes[name]
+                    if self.repo._tagtypes and name in self.repo._tagtypes:
+                        del self.repo._tagtypes[name]
                 elif (hgutil.safehasattr(self.repo, 'tagscache') and
                       self.repo.tagscache and
-                      hgutil.safehasattr(self.repo.tagscache, '_tagtypes') and
-                      self.repo.tagscache._tagtypes and
-                      name in self.repo.tagscache._tagtypes):
-                    # Mercurial 2.0 and later.
-                    del self.repo.tagscache._tagtypes[name]
+                      hgutil.safehasattr(self.repo.tagscache, '_tagtypes')):
+                      # Mercurial 2.0 and later.
+                      if (self.repo.tagscache._tagtypes and
+                          name in self.repo.tagscache._tagtypes):
+                          del self.repo.tagscache._tagtypes[name]
+                else:
+                    raise RepoError(
+                        "Incompatible Mercurial version: can't find 'tagtypes'"
+                        " attribute in class %s" % self.repo.__class__.__name__
+                    )
 
     def import_git_commit(self, commit):
         self.ui.debug(_("importing: %s\n") % commit.id)