Author: cmpilato
Date: 2007-05-10 13:47:27-0700
New Revision: 1654
Modified:
trunk/lib/vclib/__init__.py
trunk/lib/vclib/bincvs/__init__.py
trunk/lib/vclib/svn/__init__.py
trunk/lib/vclib/svn_ra/__init__.py
trunk/lib/viewvc.py
Log:
Ensure that vclib.Repository objects are aware of their name, path,
and type by forcing them to implement functions which query those
pieces of information.
* lib/vclib/__init__.py
(Repository.rootname, Repository.rootpath, Repository.roottype): New.
* lib/vclib/bincvs/__init__.py
(CVSRepository.rootname, CVSRepository.rootpath,
CVSRepository.roottype): New.
* lib/vclib/svn/__init__.py
(SubversionRepository.rootname, SubversionRepository.rootpath,
SubversionRepository.roottype): New.
* lib/vclib/svn_ra/__init__.py
(SubversionRepository.rootname, SubversionRepository.rootpath,
SubversionRepository.roottype): New.
* lib/viewvc.py
(Request.run_viewvc): Ask the Repository object for its roottype(),
and translate the vclib value into a string. (It would be nice to
use the vclib value throughout the codebase, but not today.)
Modified: trunk/lib/vclib/__init__.py
Url:
http://viewvc.tigris.org/source/browse/viewvc/trunk/lib/vclib/__init__.py?view=diff&rev=1654&p1=trunk/lib/vclib/__init__.py&p2=trunk/lib/vclib/__init__.py&r1=1653&r2=1654
==============================================================================
--- trunk/lib/vclib/__init__.py (original)
+++ trunk/lib/vclib/__init__.py 2007-05-10 13:47:27-0700
@@ -27,11 +27,25 @@
CONTEXT = 2
SIDE_BY_SIDE = 3
+# root types returned by Repository.roottype().
+CVS = 'cvs'
+SVN = 'svn'
+
+
# ======================================================================
#
class Repository:
"""Abstract class representing a repository."""
+ def rootname(self):
+ """Return the name of this repository."""
+
+ def roottype(self):
+ """Return the type of this repository (vclib.CVS, vclib.SVN, ...)."""
+
+ def rootpath(self):
+ """Return the location of this repository."""
+
def itemtype(self, path_parts, rev):
"""Return the type of the item (file or dir) at the given path and revision
Modified: trunk/lib/vclib/bincvs/__init__.py
Url:
http://viewvc.tigris.org/source/browse/viewvc/trunk/lib/vclib/bincvs/__init__.py?view=diff&rev=1654&p1=trunk/lib/vclib/bincvs/__init__.py&p2=trunk/lib/vclib/bincvs/__init__.py&r1=1653&r2=1654
==============================================================================
--- trunk/lib/vclib/bincvs/__init__.py (original)
+++ trunk/lib/vclib/bincvs/__init__.py 2007-05-10 13:47:27-0700
@@ -34,6 +34,15 @@
self.rootpath = rootpath
self.utilities = utilities
+ def rootname(self):
+ return self.name
+
+ def rootpath(self):
+ return self.rootpath
+
+ def roottype(self):
+ return vclib.CVS
+
def itemtype(self, path_parts, rev):
basepath = self._getpath(path_parts)
if os.path.isdir(basepath):
Modified: trunk/lib/vclib/svn/__init__.py
Url:
http://viewvc.tigris.org/source/browse/viewvc/trunk/lib/vclib/svn/__init__.py?view=diff&rev=1654&p1=trunk/lib/vclib/svn/__init__.py&p2=trunk/lib/vclib/svn/__init__.py&r1=1653&r2=1654
==============================================================================
--- trunk/lib/vclib/svn/__init__.py (original)
+++ trunk/lib/vclib/svn/__init__.py 2007-05-10 13:47:27-0700
@@ -547,6 +547,15 @@
self.youngest = fs.youngest_rev(self.fs_ptr)
self._fsroots = {}
+ def rootname(self):
+ return self.name
+
+ def rootpath(self):
+ return self.rootpath
+
+ def roottype(self):
+ return vclib.SVN
+
def itemtype(self, path_parts, rev):
rev = self._getrev(rev)
basepath = self._getpath(path_parts)
Modified: trunk/lib/vclib/svn_ra/__init__.py
Url:
http://viewvc.tigris.org/source/browse/viewvc/trunk/lib/vclib/svn_ra/__init__.py?view=diff&rev=1654&p1=trunk/lib/vclib/svn_ra/__init__.py&p2=trunk/lib/vclib/svn_ra/__init__.py&r1=1653&r2=1654
==============================================================================
--- trunk/lib/vclib/svn_ra/__init__.py (original)
+++ trunk/lib/vclib/svn_ra/__init__.py 2007-05-10 13:47:27-0700
@@ -282,6 +282,15 @@
self.youngest = ra.svn_ra_get_latest_revnum(self.ra_session)
self._dirent_cache = { }
+ def rootname(self):
+ return self.name
+
+ def rootpath(self):
+ return self.rootpath
+
+ def roottype(self):
+ return vclib.SVN
+
def itemtype(self, path_parts, rev):
path = self._getpath(path_parts[:-1])
rev = self._getrev(rev)
Modified: trunk/lib/viewvc.py
Url:
http://viewvc.tigris.org/source/browse/viewvc/trunk/lib/viewvc.py?view=diff&rev=1654&p1=trunk/lib/viewvc.py&p2=trunk/lib/viewvc.py&r1=1653&r2=1654
==============================================================================
--- trunk/lib/viewvc.py (original)
+++ trunk/lib/viewvc.py 2007-05-10 13:47:27-0700
@@ -242,7 +242,6 @@
self.repos = vclib.bincvs.BinCVSRepository(self.rootname,
self.rootpath,
cfg.utilities)
- self.roottype = 'cvs'
except vclib.ReposNotFound:
raise debug.ViewVCException(
'Unable to locate CVS root "%s". Possible causes include '
@@ -266,7 +265,6 @@
self.repos = vclib.svn.SubversionRepository(self.rootname,
self.rootpath,
cfg.utilities)
- self.roottype = 'svn'
except vclib.ReposNotFound:
raise debug.ViewVCException(
'Unable to locate Subversion root "%s". Possible causes include '
@@ -281,6 +279,17 @@
'correct, then please double-check your configuration.'
% self.rootname, "404 Repository not found")
+ if self.repos:
+ type = self.repos.roottype()
+ if type == vclib.SVN:
+ self.roottype = 'svn'
+ elif type == vclib.CVS:
+ self.roottype = 'cvs'
+ else:
+ raise debug.ViewVCException(
+ 'The root "%s" has an unknown type (%s).' % (self.rootname, type),
+ "500 Internal Server Error")
+
if self.rootname and cfg.options.authorizer:
self.auth = setup_authorizer(cfg, self.username, self.rootname,
self.rootpath, self.roottype)
|