2002-02-12 00:03:31 +03:00
|
|
|
# -*-python-*-
|
|
|
|
#
|
2013-01-04 23:01:54 +04:00
|
|
|
# Copyright (C) 1999-2013 The ViewCVS Group. All Rights Reserved.
|
2002-02-12 00:03:31 +03:00
|
|
|
#
|
|
|
|
# By using this file, you agree to the terms and conditions set forth in
|
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.
|
2002-02-12 00:03:31 +03:00
|
|
|
#
|
2006-03-18 05:07:36 +03:00
|
|
|
# For more information, visit http://viewvc.org/
|
2002-02-12 00:03:31 +03:00
|
|
|
#
|
|
|
|
# -----------------------------------------------------------------------
|
2008-06-12 20:26:33 +04:00
|
|
|
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,)
|
2008-06-12 20:26:33 +04:00
|
|
|
|
|
|
|
|
|
|
|
def canonicalize_rootpath(rootpath):
|
2012-01-05 19:35:39 +04:00
|
|
|
assert os.path.isabs(rootpath)
|
2008-06-12 20:26:33 +04:00
|
|
|
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.
|
2012-01-05 19:35:39 +04:00
|
|
|
assert os.path.isabs(parent_path)
|
2008-06-12 20:26:33 +04:00
|
|
|
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
|
|
|
|
|
2006-03-18 05:07:36 +03:00
|
|
|
|
2008-02-06 22:22:53 +03:00
|
|
|
def CVSRepository(name, rootpath, authorizer, utilities, use_rcsparse):
|
2008-06-12 20:26:33 +04:00
|
|
|
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
|
2008-02-06 22:22:53 +03:00
|
|
|
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
|
2008-02-06 22:22:53 +03:00
|
|
|
return bincvs.BinCVSRepository(name, rootpath, authorizer, utilities)
|