Changeset - 000653f7cdf9
[Not reviewed]
beta
0 3 0
Mads Kiilerich - 13 years ago 2013-03-21 11:17:01
madski@unity3d.com
Transplanted from: 078d1badf39b
avoid displaying repr of internal classes in user facing messages

The context of the message will tell where the problem was and there is no reason to show
... does not exist for this repository <MercurialRepository at /home/marcink/repos/rhodecode>
3 files changed with 6 insertions and 8 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/vcs/backends/git/repository.py
Show inline comments
 
@@ -259,40 +259,40 @@ class GitRepository(BaseRepository):
 
        if len(self.revisions) == 0:
 
            raise EmptyRepositoryError("There are no changesets yet")
 

	
 
        if revision in (None, '', 'tip', 'HEAD', 'head', -1):
 
            revision = self.revisions[-1]
 

	
 
        if ((is_bstr(revision) and revision.isdigit() and len(revision) < 12)
 
            or isinstance(revision, int) or is_null(revision)):
 
            try:
 
                revision = self.revisions[int(revision)]
 
            except:
 
                raise ChangesetDoesNotExistError("Revision %r does not exist "
 
                    "for this repository %s" % (revision, self))
 
                    "for this repository" % (revision))
 

	
 
        elif is_bstr(revision):
 
            # get by branch/tag name
 
            _ref_revision = self._parsed_refs.get(revision)
 
            _tags_shas = self.tags.values()
 
            if _ref_revision:  # and _ref_revision[1] in ['H', 'RH', 'T']:
 
                return _ref_revision[0]
 

	
 
            # maybe it's a tag ? we don't have them in self.revisions
 
            elif revision in _tags_shas:
 
                return _tags_shas[_tags_shas.index(revision)]
 

	
 
            elif not pattern.match(revision) or revision not in self.revisions:
 
                raise ChangesetDoesNotExistError("Revision %r does not exist "
 
                    "for this repository %s" % (revision, self))
 
                    "for this repository" % (revision))
 

	
 
        # Ensure we return full id
 
        if not pattern.match(str(revision)):
 
            raise ChangesetDoesNotExistError("Given revision %r not recognized"
 
                % revision)
 
        return revision
 

	
 
    def _get_archives(self, archive_name='tip'):
 

	
 
        for i in [('zip', '.zip'), ('gz', '.tar.gz'), ('bz2', '.tar.bz2')]:
 
                yield {"type": i[0], "extension": i[1], "node": archive_name}
 

	
rhodecode/lib/vcs/backends/hg/repository.py
Show inline comments
 
@@ -396,26 +396,26 @@ class MercurialRepository(BaseRepository
 
        """
 

	
 
        if self._empty:
 
            raise EmptyRepositoryError("There are no changesets yet")
 

	
 
        if revision in [-1, 'tip', None]:
 
            revision = 'tip'
 

	
 
        try:
 
            revision = hex(self._repo.lookup(revision))
 
        except (IndexError, ValueError, RepoLookupError, TypeError):
 
            raise ChangesetDoesNotExistError("Revision %r does not "
 
                                    "exist for this repository %s" \
 
                                    % (revision, self))
 
                                    "exist for this repository"
 
                                    % (revision))
 
        return revision
 

	
 
    def _get_archives(self, archive_name='tip'):
 
        allowed = self.baseui.configlist("web", "allow_archive",
 
                                         untrusted=True)
 
        for i in [('zip', '.zip'), ('gz', '.tar.gz'), ('bz2', '.tar.bz2')]:
 
            if i[0] in allowed or self._repo.ui.configbool("web",
 
                                                           "allow" + i[0],
 
                                                           untrusted=True):
 
                yield {"type": i[0], "extension": i[1], "node": archive_name}
 

	
 
    def _get_url(self, url):
rhodecode/tests/functional/test_files.py
Show inline comments
 
@@ -285,26 +285,25 @@ removed extra unicode conversion in diff
 
        self.log_user()
 
        rev = u'ERRORce30c96924232dffcd24178a07ffeb5dfc'
 
        f_path = 'vcs/nodes.py'
 

	
 
        response = self.app.get(url(controller='files', action='rawfile',
 
                                    repo_name=HG_REPO,
 
                                    revision=rev,
 
                                    f_path=f_path))
 

	
 
        msg = """Revision %r does not exist for this repository""" % (rev)
 
        self.checkSessionFlash(response, msg)
 

	
 
        msg = """%s""" % (HG_REPO)
 
        self.checkSessionFlash(response, msg)
 
        self.assertEqual('http://localhost/%s/files/tip/' % HG_REPO, response.headers['location'])
 

	
 
    def test_raw_file_wrong_f_path(self):
 
        self.log_user()
 
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
 
        f_path = 'vcs/ERRORnodes.py'
 
        response = self.app.get(url(controller='files', action='rawfile',
 
                                    repo_name=HG_REPO,
 
                                    revision=rev,
 
                                    f_path=f_path))
 

	
 
        msg = "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12])
 
        self.checkSessionFlash(response, msg)
 
@@ -324,26 +323,25 @@ removed extra unicode conversion in diff
 
    def test_raw_wrong_cs(self):
 
        self.log_user()
 
        rev = u'ERRORcce30c96924232dffcd24178a07ffeb5dfc'
 
        f_path = 'vcs/nodes.py'
 

	
 
        response = self.app.get(url(controller='files', action='raw',
 
                                    repo_name=HG_REPO,
 
                                    revision=rev,
 
                                    f_path=f_path))
 
        msg = """Revision %r does not exist for this repository""" % (rev)
 
        self.checkSessionFlash(response, msg)
 

	
 
        msg = """%s""" % (HG_REPO)
 
        self.checkSessionFlash(response, msg)
 
        self.assertEqual('http://localhost/%s/files/tip/' % HG_REPO, response.headers['location'])
 

	
 
    def test_raw_wrong_f_path(self):
 
        self.log_user()
 
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
 
        f_path = 'vcs/ERRORnodes.py'
 
        response = self.app.get(url(controller='files', action='raw',
 
                                    repo_name=HG_REPO,
 
                                    revision=rev,
 
                                    f_path=f_path))
 
        msg = "There is no file nor directory at the given path: %r at revision %r" % (f_path, rev[:12])
 
        self.checkSessionFlash(response, msg)
 

	
0 comments (0 inline, 0 general)