Remove dead code from vclib.

* lib/vclib/__init__.py
  (Repository.getitem, Repository.getfiles, Repository.getsubdirs,
   Revision, Repository._getvf_files, Repository._getvf_subdirs,
   Versfile, Versdir, Versitem, Repository._getvf_info,
   Repository._getvf_tree, Repository._getvf_properties,
   Repository._getvf_cofile):
    removed

* lib/vclib/svn/__init__.py
  (SubversionRepository.getitem, SubversionRepository._getvf_files,
   SubversionRepository._getvf_subdirs,
   SubversionRepository._getvf_info,
   SubversionRepository._getvf_tree,
   SubversionRepository._getvf_properties,
   SubversionRepository._getvf_cofile):
    removed

* lib/vclib/bincvs/__init__.py
  (BinCVSRepository.getitem, BinCVSRepository._getvf_files,
   BinCVSRepository._getvf_subdirs,
   BinCVSRepository._getvf_info,
   BinCVSRepository._getvf_tree,
   BinCVSRepository._getvf_properties,
   BinCVSRepository._getvf_cofile):
    removed


git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@736 8cb11bc2-c004-0410-86c3-e597b4017df7
remotes/tags/1.0.0-rc1
rey4 2003-10-21 19:54:27 +00:00
parent e367c87dfe
commit c1785db585
3 changed files with 3 additions and 365 deletions

View File

@ -20,41 +20,17 @@ such as CVS.
import string
# item types returned by Repository.itemtype(). these values are also
# available as object.type where object is a Versfile or Versdir.
# item types returned by Repository.itemtype().
FILE = 'FILE'
DIR = 'DIR'
# Developers' note:
# The only class you need to derive to write a new driver for Versionlib
# is the Repository class.
# ======================================================================
#
# TODO: Add a last modified property
#
class Repository:
"""
Abstract class representing a repository.
Developers: This should be the only class to be derived to obtain an
actual implementation of a versioning system.
"""
# Public methods ( accessible from the upper layers )
def getitem(self, path_parts):
"""Return the item (file or dir) at the given path.
The result will be an instance of Versfile or Versdir. Before calling
this method, you can also use .itemtype() to determine the type of
the item at the given path.
The path is specified as a list of components, relative to the root
of the repository. e.g. ["subdir1", "subdir2", "filename"]
"""
pass
"""Abstract class representing a repository."""
def itemtype(self, path_parts):
"""Return the type of the item (file or dir) at the given path.
@ -87,65 +63,6 @@ class Repository:
of the repository. e.g. ["subdir1", "subdir2", "filename"]
"""
# Private methods ( accessed by Versfile and Revision )
def _getvf_files(self, path_parts):
"Return a dictionary of versioned files. (name : Versfile)"
pass
def _getvf_subdirs(self, path_parts):
"Return a dictionary of subdirectories. (name : Versdir)"
pass
def _getvf_info(self, target, path_parts):
"""
This method will add to <target> (expect to be an instance of Versfile)
a certain number of attributes:
head (string)
age (int timestamp)
author (string)
log
branch
... ( there can be other stuff here)
Developers: method to be overloaded.
"""
def _getvf_tree(self, versfile):
"""
should return a dictionary of Revisions
Developers: method to be overloaded.
"""
def _getvf_properties(self, target, path_parts, revisionnumber):
"""
Add/update into target's attributes (expected to be an instance of
Revision) a certain number of attributes:
rev
date
author
state
log
previous revision number
branches ( a list of revision numbers )
changes ( string of the form: e.g. "+1 -0 lines" )
tags
... ( there can be other stuff here)
Developers: in the cvs implementation, the method will never be called.
There is no point in developping this method as _getvf_tree already
gets the properties.
"""
def _getvf_cofile(self, target, path_parts):
"""
should return a file object representing the checked out revision.
Notice that _getvf_co can also add the properties in <target> the
way _getvf_properties does.
Developers: method to be overloaded.
"""
# ======================================================================
class DirEntry:
"Instances represent items in a directory listing"
@ -154,119 +71,7 @@ class DirEntry:
self.name = name
self.kind = kind
self.verboten = verboten
# ======================================================================
class Versitem:
pass
# ======================================================================
class Versdir(Versitem):
"Instances represent directories within a repository."
#
# Note to developers: you do not need to derive this class.
#
type = DIR
def __init__(self, repository, path_parts):
assert isinstance(repository, Repository)
self.repository = repository
self.path = path_parts
def getfiles(self):
"Return a dictionary of versioned files. (name : Versfile)"
return self.repository._getvf_files(self.path)
def getsubdirs(self):
"Return a dictionary of subdirectories. (name : Versdir)"
return self.repository._getvf_subdirs(self.path)
# ======================================================================
class Versfile(Versitem):
"Instances represent a (versioned) file within a repository."
#
# Note to developers: you do not need to derive this class.
#
type = FILE
names = ("head", "age", "author", "log", "branch", "tags")
def __init__(self, repository, path_parts, tree=None):
"Called by Repository.getfile"
assert isinstance(repository, Repository)
self.repository = repository
self.path = path_parts
if tree != None:
self.tree = tree
# if an attribute is not present in the dict of the instance, look for it in
# the repository. Special treatment for the "tree" attribute.
def __getattr__(self, name):
if name == "tree":
self.tree = self.repository._getvf_tree(self)
return self.tree
if name in self.names:
self.repository._getvf_info(self, self.path)
return self.__dict__[name]
raise AttributeError()
# private methods ( access from Revision's methods )
def _getvf_properties(self, target, revisionnumber):
return self.repository._getvf_properties(target, self.path, revisionnumber)
def _getvf_cofile(self, target):
return self.repository._getvf_cofile(target, self.path)
# ======================================================================
class Revision:
"Instances represent a specific revision of a (versioned) file."
#
# Note to developers: you do not need to derive this class.
#
names = ("date", "author", "state", "log", "previous", "branches",
"changes", "tags")
def __init__(self, versfile, number):
if not isinstance(versfile, Versfile):
raise TypeError(versfile)
self.versfile = versfile
self.rev = number
# if an attribute is not present in the dict of the instance, look for it in
# the repository.
def __getattr__(self, name):
if name in self.names:
self.versfile._getvf_properties(self, self.rev)
return self.__dict__[name]
raise AttributeError()
def checkout(self):
return self.versfile._getvf_cofile(self)
# Here are the shortcuts methods.
def getprevious(self):
return self.versfile.tree[self.previous]
def getbranches(self):
res = []
for i in self.branches:
res.append(self.versfile.tree[i])
return res
# ======================================================================
class Error(Exception):

View File

@ -436,15 +436,6 @@ class BinCVSRepository(vclib.Repository):
self.rootpath = rootpath
self.rcs_paths = rcs_paths
def getitem(self, path_parts):
basepath = self._getpath(path_parts)
if os.path.isdir(basepath):
return vclib.Versdir(self, basepath)
rcspath = self._getrcsname(basepath)
if os.path.isfile(rcspath):
return vclib.Versfile(self, rcspath)
raise vclib.ItemNotFound(path_parts)
def itemtype(self, path_parts):
basepath = self._getpath(path_parts)
if os.path.isdir(basepath):
@ -601,81 +592,3 @@ class BinCVSRepository(vclib.Repository):
return filename
else:
return filename + ',v'
def _getvf_subdirs(self, basepath):
h = os.listdir(basepath)
g = { }
for i in h:
thispath = os.path.join(basepath, i)
if os.path.isdir(thispath):
g[i] = vclib.Versdir(self, thispath)
return g
def _getvf_files(self, basepath):
h = os.listdir(basepath)
g = { }
for i in h:
rcspath = self._getrcsname(os.path.join(basepath, i))
if os.path.isfile(rcspath):
g[i] = vclib.Versfile(self, rcspath)
return g
def _getvf_info(self, target, basepath):
"""
This method will add to <target> (expect to be an instance of Versfile)
a certain number of attributes:
head (string)
age (int timestamp)
author (string)
log
branch
... ( there can be other stuff here)
Developers: method to be overloaded.
"""
if not os.path.isfile(basepath):
raise "Unknown file: %s " % basepath
rlog = popen.popen('rlog', basepath, 'rt')
header, eof = parse_log_header(rlog)
target.head = header.head
target.branch = header.branch
target.taginfo = header.taginfo
def _getvf_tree(self, versfile):
"""
should return a dictionary of Revisions
Developers: method to be overloaded.
"""
def _getvf_properties(self, target, basepath, revisionnumber):
"""
Add/update into target's attributes (expected to be an instance of
Revision) a certain number of attributes:
rev
date
author
state
log
previous revision number
branches ( a list of revision numbers )
changes ( string of the form: e.g. "+1 -0 lines" )
tags
... ( there can be other stuff here)
Developers: in the cvs implementation, the method will never be called.
There is no point in developping this method as _getvf_tree already
gets the properties.
"""
def _getvf_cofile(self, target, basepath):
"""
should return a file object representing the checked out revision.
Notice that _getvf_co can also add the properties in <target> the
way _getvf_properties does.
Developers: method to be overloaded.
"""
fp = popen.popen('co', ('-p' + rev, basepath, 'rb'))
fp.readline()
fp.readline()
return fp

View File

@ -259,14 +259,6 @@ class SubversionRepository(vclib.Repository):
core.svn_pool_destroy(self.pool)
core.apr_terminate()
def getitem(self, path_parts):
basepath = self._getpath(path_parts)
item = self.itemtype(path_parts)
if item is vclib.DIR:
return vclib.Versdir(self, basepath)
else:
return vclib.Versfile(self, basepath)
def itemtype(self, path_parts):
basepath = self._getpath(path_parts)
kind = fs.check_path(self.fsroot, basepath, self.pool)
@ -302,75 +294,3 @@ class SubversionRepository(vclib.Repository):
def _getpath(self, path_parts):
return string.join(path_parts, '/')
def _getvf_subdirs(self, basepath):
entries = fs.dir_entries(self.fsroot, basepath, self.pool)
subdirs = { }
names = entries.keys()
names.sort()
subpool = core.svn_pool_create(self.pool)
for name in names:
child = fs_path_join(basepath, name)
if fs.is_dir(self.fsroot, child, subpool):
subdirs[name] = vclib.Versdir(self, child)
core.svn_pool_clear(subpool)
core.svn_pool_destroy(subpool)
return subdirs
def _getvf_files(self, basepath):
entries = fs.dir_entries(self.fsroot, basepath, self.pool)
files = { }
names = entries.keys()
names.sort()
subpool = core.svn_pool_create(self.pool)
for name in names:
child = fs_path_join(basepath, name)
if fs.is_file(self.fsroot, child, subpool):
files[name] = vclib.Versfile(self, child)
core.svn_pool_clear(subpool)
core.svn_pool_destroy(subpool)
return files
def _getvf_info(self, target, basepath):
if not fs.is_file(self.fsroot, basepath, self.pool):
raise "Unknown file: %s " % basepath
# todo
pass
def _getvf_tree(self, versfile):
"""
should return a dictionary of Revisions
Developers: method to be overloaded.
"""
# todo
def _getvf_properties(self, target, basepath, revisionnumber):
"""
Add/update into target's attributes (expected to be an instance of
Revision) a certain number of attributes:
rev
date
author
state
log
previous revision number
branches ( a list of revision numbers )
changes ( string of the form: e.g. "+1 -0 lines" )
tags
... ( there can be other stuff here)
Developers: in the cvs implementation, the method will never be called.
There is no point in developping this method as _getvf_tree already
gets the properties.
"""
# todo
def _getvf_cofile(self, target, basepath):
"""
should return a file object representing the checked out revision.
Notice that _getvf_co can also add the properties in <target> the
way _getvf_properties does.
Developers: method to be overloaded.
"""
# todo