viewvc-4intranet/lib/vclib/ccvs/__init__.py

51 lines
1.6 KiB
Python
Raw Normal View History

# -*-python-*-
#
# Copyright (C) 1999-2013 The ViewCVS Group. All Rights Reserved.
#
# By using this file, you agree to the terms and conditions set forth in
Work on issue 168, s/ViewCVS/ViewVC. This patch changes references to ViewCVS in comments, strings, and documentation. References to ViewCVS in filenames and urls still need to be fixed. Also, logo.png (the blimp) needs to be updated or replaced. This patch is by Gerard Gerritsen (sigcafe), the only change I've made is to restore a reference to ViewCVS in a comment about backwards compatibility. * windows/README * viewcvs-install * README * templates/include/footer.ezt * templates/include/header.ezt * templates/error.ezt * templates/query.ezt * templates/docroot/help.css * templates/docroot/help_query.html * templates/docroot/help_dirview.html * templates/docroot/help_rootview.html * templates/docroot/styles.css * templates/docroot/help_log.html * templates/diff.ezt * tools/make-release * lib/sapi.py * lib/dbi.py * lib/accept.py * lib/cvsdb.py * lib/config.py * lib/query.py * lib/vclib/bincvs/__init__.py * lib/vclib/svn/__init__.py * lib/vclib/__init__.py * lib/vclib/svn_ra/__init__.py * lib/vclib/ccvs/rcsparse/common.py * lib/vclib/ccvs/rcsparse/__init__.py * lib/vclib/ccvs/rcsparse/default.py * lib/vclib/ccvs/rcsparse/texttools.py * lib/vclib/ccvs/rcsparse/debug.py * lib/vclib/ccvs/__init__.py * lib/vclib/ccvs/blame.py * lib/blame.py * lib/popen.py * lib/compat.py * lib/viewcvs.py * lib/debug.py * INSTALL * bin/standalone.py * bin/make-database * bin/mod_python/query.py * bin/mod_python/viewcvs.py * bin/cgi/query.cgi * bin/cgi/viewcvs.cgi * bin/asp/query.asp * bin/asp/viewcvs.asp * bin/svndbadmin * bin/loginfo-handler * bin/cvsdbadmin * viewcvs.conf.dist git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1200 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-12-17 20:19:28 +03:00
# the LICENSE.html file which can be found at the top level of the ViewVC
# distribution or at http://viewvc.org/license-1.html.
#
# For more information, visit http://viewvc.org/
#
# -----------------------------------------------------------------------
import os
import os.path
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
import time
def cvs_strptime(timestr):
return time.strptime(timestr, '%Y/%m/%d %H:%M:%S')[:-1] + (0,)
def canonicalize_rootpath(rootpath):
assert os.path.isabs(rootpath)
return os.path.normpath(rootpath)
def expand_root_parent(parent_path):
# Each subdirectory of PARENT_PATH that contains a child
# "CVSROOT/config" is added the set of returned roots. Or, if the
# PARENT_PATH itself contains a child "CVSROOT/config", then all its
# subdirectories are returned as roots.
assert os.path.isabs(parent_path)
roots = {}
subpaths = os.listdir(parent_path)
cvsroot = os.path.exists(os.path.join(parent_path, "CVSROOT", "config"))
for rootname in subpaths:
rootpath = os.path.join(parent_path, rootname)
if cvsroot \
or (os.path.exists(os.path.join(rootpath, "CVSROOT", "config"))):
roots[rootname] = canonicalize_rootpath(rootpath)
return roots
def CVSRepository(name, rootpath, authorizer, utilities, use_rcsparse):
rootpath = canonicalize_rootpath(rootpath)
Merge changes (r1735:1738) from the (misnamed) options-overhaul branch. This reduces the number of vclib plugins to two -- one for each of CVS and Subversion. * lib/viewvc.py (): Update callers of vclib.svn.created_rev(), vclib.svn.get_location(), vclib.svn.get_youngest_revision(), and vclib.svn.last_rev() to use request.repos.* instead. (Request.run_viewvc): For CVS, invoke only vclib.ccvs.CVSRepository(), but pass the use_rcsparse setting to it. For Subversion, invoke only vclib.svn.SubversionRepository(). * lib/vclib/ccvs/ccvs.py Renamed from lib/vclib/ccvs/__init__.py, and tweaked to look for stuff common to the bincvs implementation in the sibling 'bincvs' module. * lib/vclib/ccvs/__init__.py New, a replacement by a new stub file with a factory function that selects which CVS implementation to use. * lib/vclib/ccvs/bincvs.py Moved from lib/vclib/bincvs/__init__.py. * lib/vclib/bincvs Removed (it's now empty). * lib/vclib/svn/svn_repos.py Renamed from lib/vclib/svn/__init__.py. (LocalSubversionRepository.created_rev, LocalSubversionRepository.get_location, LocalSubversionRepository.get_youngest_revision, LocalSubversionRepository.last_rev): Moved into the class from outside. * lib/vclib/svn/svn_ra.py Moved from lib/vclib/svn_ra/__init__.py. (RemoteSubversionRepository.created_rev, RemoteSubversionRepository.get_location, RemoteSubversionRepository.get_youngest_revision, RemoteSubversionRepository.last_rev): Moved into the class from outside. * lib/vclib/svn/__init__.py New, replacing previous incarnation with a file that contains only a single factory function. * lib/vclib/svn_ra/ Removed (it's now empty). * bin/loginfo-handler (ProcessLoginfo): Now use vclib.ccvs.CVSRepository(), disabling use_rcsparse. * bin/cvsdbadmin (__main__): Now use vclib.ccvs.CVSRepository(), disabling use_rcsparse. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1739 8cb11bc2-c004-0410-86c3-e597b4017df7
2007-12-03 18:25:51 +03:00
if use_rcsparse:
import ccvs
return ccvs.CCVSRepository(name, rootpath, authorizer, utilities)
Merge changes (r1735:1738) from the (misnamed) options-overhaul branch. This reduces the number of vclib plugins to two -- one for each of CVS and Subversion. * lib/viewvc.py (): Update callers of vclib.svn.created_rev(), vclib.svn.get_location(), vclib.svn.get_youngest_revision(), and vclib.svn.last_rev() to use request.repos.* instead. (Request.run_viewvc): For CVS, invoke only vclib.ccvs.CVSRepository(), but pass the use_rcsparse setting to it. For Subversion, invoke only vclib.svn.SubversionRepository(). * lib/vclib/ccvs/ccvs.py Renamed from lib/vclib/ccvs/__init__.py, and tweaked to look for stuff common to the bincvs implementation in the sibling 'bincvs' module. * lib/vclib/ccvs/__init__.py New, a replacement by a new stub file with a factory function that selects which CVS implementation to use. * lib/vclib/ccvs/bincvs.py Moved from lib/vclib/bincvs/__init__.py. * lib/vclib/bincvs Removed (it's now empty). * lib/vclib/svn/svn_repos.py Renamed from lib/vclib/svn/__init__.py. (LocalSubversionRepository.created_rev, LocalSubversionRepository.get_location, LocalSubversionRepository.get_youngest_revision, LocalSubversionRepository.last_rev): Moved into the class from outside. * lib/vclib/svn/svn_ra.py Moved from lib/vclib/svn_ra/__init__.py. (RemoteSubversionRepository.created_rev, RemoteSubversionRepository.get_location, RemoteSubversionRepository.get_youngest_revision, RemoteSubversionRepository.last_rev): Moved into the class from outside. * lib/vclib/svn/__init__.py New, replacing previous incarnation with a file that contains only a single factory function. * lib/vclib/svn_ra/ Removed (it's now empty). * bin/loginfo-handler (ProcessLoginfo): Now use vclib.ccvs.CVSRepository(), disabling use_rcsparse. * bin/cvsdbadmin (__main__): Now use vclib.ccvs.CVSRepository(), disabling use_rcsparse. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1739 8cb11bc2-c004-0410-86c3-e597b4017df7
2007-12-03 18:25:51 +03:00
else:
import bincvs
return bincvs.BinCVSRepository(name, rootpath, authorizer, utilities)