Commits

Diego Búrigo Zacarão committed d4ae288

bugfix: make get_rev() raises always the same exception

  • Participants
  • Parent commits 6a14465

Comments (0)

Files changed (7)

File repowatch/__init__.py

 from projects import signals
 from txcommon.log import logger
 from translations.models import POFile
+from vcs.lib.types import BrowserError
 from notification import models as notification
 # Temporary
 from txcommon import notifications as txnotification
                     changes.append((watch.user.all(), watch.path))
                 watch.rev = newrev
                 watch.save()
-        except ValueError:
-            continue    
+        except (ValueError, BrowserError):
+            continue
     if changes:
         changes.sort(key=operator.itemgetter(0))
         for usergroup in itertools.groupby(changes,

File tarball/lib/types/tar.py

         Get the current revision of the repository or a specific
         object
         '''
-        if not obj:
-            return (int(self.codebase.changectx(self.branch).node().
-                encode('hex'), 16),)
-        else:
-            f = self.codebase.changectx(self.branch).filectx(obj)
-            return (int(f.filectx(f.filerev()).node().encode('hex'),
-                16),)
+        try:
+            if not obj:
+                return (int(self.codebase.changectx(self.branch).node().
+                    encode('hex'), 16),)
+            else:
+                f = self.codebase.changectx(self.branch).filectx(obj)
+                return (int(f.filectx(f.filerev()).node().encode('hex'),
+                    16),)
+        except LookupError, e:
+            raise BrowserError(e)
 
     @need_codebase
     def submit(self, files, msg, user):

File vcs/lib/types/bzr.py

         Get the current revision of the repository or a specific
         object.
         """
-        if not obj:
-            return self.repo.last_revision_info()[0:1]
-        else:
-            m = self.repo.get_revision_id_to_revno_map()
-            t = self.repo.repository.revision_tree(
-                self.repo.last_revision())
-            i = t.inventory[t.path2id(obj)]
-            return m[i.revision]
+        try:
+            if not obj:
+                return self.repo.last_revision_info()[0:1]
+            else:
+                m = self.repo.get_revision_id_to_revno_map()
+                t = self.repo.repository.revision_tree(
+                    self.repo.last_revision())
+                i = t.inventory[t.path2id(obj)]
+                return m[i.revision]
+        # TODO: Make it more specific
+        except:
+            raise BrowserError()
 
     @need_repo
     def submit(self, files, msg, user):

File vcs/lib/types/cvs.py

         Commands used:
         none
         """
-        if not obj:
-            raise ValueError('CVS repos do not have a global revision')
-        p = os.path.join(self.path, obj)
-        if not os.path.exists(p):
-            return None
-        if not os.path.isfile(p):
-            raise ValueError('Only files have a revision in CVS')
-        d, b = os.path.split(p)
-        e = os.path.join(d, 'CVS', 'Entries')
         try:
-            ef = open(e, 'r')
-            bs = '/%s/' % b
-            for line in (entry for entry in ef if entry.startswith(bs)):
-                rev = line.split('/')[2]
-                break
-            else:
-                rev = None
-            ef.close()
-        except IOError:
-            return None
-        return tuple(int(p) for p in rev.split('.'))
+            if not obj:
+                raise ValueError('CVS repos do not have a global revision')
+            p = os.path.join(self.path, obj)
+            if not os.path.exists(p):
+                return None
+            if not os.path.isfile(p):
+                raise ValueError('Only files have a revision in CVS')
+            d, b = os.path.split(p)
+            e = os.path.join(d, 'CVS', 'Entries')
+            try:
+                ef = open(e, 'r')
+                bs = '/%s/' % b
+                for line in (entry for entry in ef if entry.startswith(bs)):
+                    rev = line.split('/')[2]
+                    break
+                else:
+                    rev = None
+                ef.close()
+            except IOError:
+                return None
+            return tuple(int(p) for p in rev.split('.'))
+        # TODO: Make it more specific
+        except:
+            raise BrowserError()
 
     @need_repo
     def submit(self, files, msg, user):

File vcs/lib/types/git.py

         git show-ref refs/heads/<branch>
         git log -1 --pretty=format:%H <obj>
         """
-        if not obj:
-            refspec = 'refs/heads/%s' % self.branch
-            rev = self.repo.show_ref(refspec).split()[0]
-        else:
-            rev = self.repo.log('-1', '--pretty=format:%H', obj)
-        return (int(rev, 16),)
+        try:
+            if not obj:
+                refspec = 'refs/heads/%s' % self.branch
+                rev = self.repo.show_ref(refspec).split()[0]
+            else:
+                rev = self.repo.log('-1', '--pretty=format:%H', obj)
+            return (int(rev, 16),)
+        # TODO: Make it more specific
+        except:
+            raise BrowserError()
 
     @need_repo
     def submit(self, files, msg, user):

File vcs/lib/types/hg.py

         Get the current revision of the repository or a specific
         object.
         """
-        if not obj:
-            return (int(self.repo.changectx(self.branch).node().encode('hex'),
-                16),)
-        else:
-            f = self.repo.changectx(self.branch).filectx(obj)
-            return (int(f.filectx(f.filerev()).node().encode('hex'),
-                16),)
+        try:
+            if not obj:
+                return (int(self.repo.changectx(self.branch).node().encode('hex'),
+                    16),)
+            else:
+                f = self.repo.changectx(self.branch).filectx(obj)
+                return (int(f.filectx(f.filerev()).node().encode('hex'),
+                    16),)
+        except LookupError, e:
+            raise BrowserError(e)
 
     @need_repo
     def submit(self, files, msg, user):

File vcs/lib/types/svn.py

         Commands used:
         svn info
         """
-        if not obj:
-            entry = self.client.info(self.path)
-        else:
-            entry = self.client.info(os.path.join(self.path, obj))
-        return (entry.commit_revision.number,)
+        try:
+            if not obj:
+                entry = self.client.info(self.path)
+            else:
+                entry = self.client.info(os.path.join(self.path, obj))
+            return (entry.commit_revision.number,)
+        # TODO: Make it more specific
+        except:
+            raise BrowserError()
 
     @need_repo
     def submit(self, files, msg, user):