2006-03-18 05:07:36 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*-python-*-
|
2000-04-21 04:43:04 +04:00
|
|
|
#
|
2006-03-18 05:07:36 +03:00
|
|
|
# Copyright (C) 1999-2006 The ViewCVS Group. All Rights Reserved.
|
2000-04-21 04:43:04 +04:00
|
|
|
#
|
2000-05-09 12:36:29 +04:00
|
|
|
# By using this file, you agree to the terms and conditions set forth in
|
2006-03-18 03:33:54 +03:00
|
|
|
# the LICENSE.html file which can be found at the top level of the ViewVC
|
2005-12-17 20:19:28 +03:00
|
|
|
# distribution or at http://viewvc.org/license-1.html.
|
2000-05-09 12:36:29 +04:00
|
|
|
#
|
2006-03-18 05:07:36 +03:00
|
|
|
# For more information, visit http://viewvc.org/
|
2000-04-21 04:43:04 +04:00
|
|
|
#
|
|
|
|
# -----------------------------------------------------------------------
|
2000-04-21 10:23:37 +04:00
|
|
|
#
|
2000-05-09 12:36:29 +04:00
|
|
|
# updates SQL database with new commit records
|
2000-04-21 10:23:37 +04:00
|
|
|
#
|
|
|
|
# -----------------------------------------------------------------------
|
2000-05-09 12:36:29 +04:00
|
|
|
#
|
2000-04-21 04:43:04 +04:00
|
|
|
|
2000-04-27 02:46:47 +04:00
|
|
|
#########################################################################
|
|
|
|
#
|
|
|
|
# INSTALL-TIME CONFIGURATION
|
|
|
|
#
|
|
|
|
# These values will be set during the installation process. During
|
|
|
|
# development, they will remain None.
|
|
|
|
#
|
|
|
|
|
|
|
|
LIBRARY_DIR = None
|
|
|
|
CONF_PATHNAME = None
|
|
|
|
|
|
|
|
# Adjust sys.path to include our library directory
|
|
|
|
import sys
|
Tweak logic used to find installed paths ("lib" directory, configuration
file, templates, etc). Specifically, make the following changes:
- Get rid of hardcoded paths in module files ("lib" directory) and
configuration files (viewcvs.conf and mod_python's .htaccess)
- Allow stub scripts (for asp, cgi, and mod_python) to specify
configuration files so it's possible to have multiple configurations of
viewcvs running off a single installation.
- Be more consistent about resolving paths when they aren't hardcoded
(when ViewCVS is running from a source directory). In particular, try
not to depend on the working directory. That way it's legal to run
./standalone.py instead of bin/standalone.py without getting an
ImportError.
- Get rid of global cfg variables in viewcvs.py and cvsdb.py. They led to
all sorts of hacks in other files to pilfer and reset them. They were
also possible sources of races in multithreaded environments like
mod_python and asp.
- Rewrite mod_python handler so library paths can be specified inside the
stub files.
* lib/apache.py
removed, contained old mod_python handler
* lib/config.py
(Config.load_config):
remove sys.argv voodoo, just load the configuration path specified in
the pathname argument
(Config.set_defaults):
use relative path for cvsgraph_conf setting instead of hardcoded
<VIEWCVS_INSTALL_DIRECTORY> literal
* lib/cvsdb.py
(CONF_PATHNAME, config, cfg):
removed, configuration stuff
(CheckinDatabase.__init__, CheckinDatabase.CreateSQLQueryString):
add "_row_limit" member instead of using cfg object
(CreateCheckinDatabase):
removed, a do-nothing function
(ConnectDatabaseReadOnly, ConnectDatabase):
add cfg arguments
(GetUnrecordedCommitList):
add db argument
* lib/query.py
(CONF_PATHAME):
removed
(build_commit, run_query, main):
add cfg arguments, use new viewcvs.get_template function
* lib/viewcvs.py
(CONF_PATHNAME, cfg, g_install_dir):
removed
(Request.__init__):
add cfg member
(Request.run_viewcvs, Request.get_link, check_freshness,
get_view_template, generate_page, default_view, get_file_view_info,
format_log, common_template_data, MarkupEnscript.__init__,
markup_stream_python, markup_stream_php, make_time_string, view_markup,
sort_file_data, view_directory, paging, view_log, view_annotate,
view_cvsgraph_image, view_cvsgraph, view_doc, rcsdiff_date_reformat,
spaced_html_text, DiffSource.__init__, DiffSource._get_row, view_patch,
view_diff, generate_tarball, download_tarball, view_revision,
is_query_supported, english_query, build_commit, view_query,
view_error, main):
stop using global config, use cfg arguments or request member instead
(_install_path):
new, use __file__ to locate template and configuation paths
(get_view_template):
use _install_path and return compiled template instead of path
(is_viewable, default_view):
rename is_viewable to default_view and return view instead of boolean
(handle_config, load_config):
rename handle_config to load_config and return config object instead
of setting cfg global
* bin/cgi/viewcvs.cgi
* bin/cgi/query.cgi
* bin/cvsdbadmin
* bin/loginfo-handler
* bin/standalone.py
* bin/svndbadmin
look for library relative to sys.argv[0] when no hardcoded library
path is available. Also add configuration loading code.
* bin/asp/viewcvs.asp
* bin/asp/query.asp
add configuration loading code
* bin/mod_python/.htaccess
specify new mod_python handler, remove reference to
<VIEWCVS_APACHE_LIBRARY_DIRECTORY>
* bin/mod_python/handler.py
added, holds new mod_python handler
* bin/mod_python/viewcvs.py
* bin/mod_python/query.py
rewrite for new handler, add hardcoded library and configuration paths
* viewcvs.conf.dist
remove references to <VIEWCVS_INSTALL_DIRECTORY>
* viewcvs-install
(FILE_INFO_LIST):
stop hardcoding paths in config files
(SetPythonPaths,):
get rid of <VIEWCVS_INSTALL_DIRECTORY> and
<VIEWCVS_APACHE_LIBRARY_DIRECTORY> substitutions
(ApacheEscape, _re_apache):
removed
(InstallTree):
stop hardcoding paths in lib directory
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1173 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-12-06 07:04:14 +03:00
|
|
|
import os
|
2000-04-27 02:46:47 +04:00
|
|
|
|
|
|
|
if LIBRARY_DIR:
|
2006-11-02 06:19:40 +03:00
|
|
|
sys.path.insert(0, LIBRARY_DIR)
|
2000-04-27 02:46:47 +04:00
|
|
|
else:
|
2006-11-02 06:19:40 +03:00
|
|
|
sys.path.insert(0, os.path.abspath(os.path.join(sys.argv[0], "../../lib")))
|
2000-04-27 02:46:47 +04:00
|
|
|
|
|
|
|
#########################################################################
|
2000-04-21 04:43:04 +04:00
|
|
|
|
2001-08-21 23:24:40 +04:00
|
|
|
import os
|
|
|
|
import string
|
|
|
|
import getopt
|
|
|
|
import re
|
|
|
|
import cvsdb
|
2006-03-18 03:33:54 +03:00
|
|
|
import viewvc
|
2004-01-26 04:25:47 +03:00
|
|
|
import vclib.bincvs
|
2001-08-21 23:24:40 +04:00
|
|
|
|
2000-04-21 04:43:04 +04:00
|
|
|
DEBUG_FLAG = 0
|
|
|
|
|
|
|
|
## output functions
|
|
|
|
def debug(text):
|
|
|
|
if DEBUG_FLAG:
|
2006-03-18 03:33:54 +03:00
|
|
|
print 'DEBUG(viewvc-loginfo):', text
|
2000-04-21 04:43:04 +04:00
|
|
|
|
|
|
|
def warning(text):
|
2006-03-18 03:33:54 +03:00
|
|
|
print 'WARNING(viewvc-loginfo):', text
|
2000-04-21 04:43:04 +04:00
|
|
|
|
|
|
|
def error(text):
|
2006-03-18 03:33:54 +03:00
|
|
|
print 'ERROR(viewvc-loginfo):', text
|
2000-04-21 04:43:04 +04:00
|
|
|
sys.exit(1)
|
|
|
|
|
2003-02-11 06:09:17 +03:00
|
|
|
_re_revisions = re.compile(
|
2006-11-02 06:19:40 +03:00
|
|
|
r",(?P<old>(?:\d+\.\d+)(?:\.\d+\.\d+)*|NONE)" # comma and first revision
|
|
|
|
r",(?P<new>(?:\d+\.\d+)(?:\.\d+\.\d+)*|NONE)" # comma and second revision
|
|
|
|
r"(?:$| )" # space or end of string
|
2003-02-11 06:09:17 +03:00
|
|
|
)
|
2000-04-21 04:43:04 +04:00
|
|
|
|
2006-11-02 06:13:53 +03:00
|
|
|
def Cvs1Dot12ArgParse(args):
|
|
|
|
"""CVS 1.12 introduced a new loginfo format while provides the various
|
|
|
|
pieces of interesting version information to the handler script as
|
|
|
|
individual arguments instead of as a single string."""
|
|
|
|
if args[1] == '- New directory':
|
|
|
|
return None, None
|
|
|
|
else:
|
|
|
|
directory = args.pop(0)
|
|
|
|
files = []
|
|
|
|
while len(args) > 3:
|
|
|
|
files.append(args[0:3])
|
|
|
|
args = args[3:]
|
|
|
|
return directory, files
|
|
|
|
|
2003-02-11 06:09:17 +03:00
|
|
|
def HeuristicArgParse(s, repository):
|
2006-11-02 06:19:40 +03:00
|
|
|
"""Older versions of CVS (except for CVSNT) do not escape spaces in file
|
|
|
|
and directory names that are passed to the loginfo handler. Since the input
|
|
|
|
to loginfo is a space separated string, this can lead to ambiguities. This
|
|
|
|
function attempts to guess intelligently which spaces are separators and
|
|
|
|
which are part of file or directory names. It disambiguates spaces in
|
|
|
|
filenames from the separator spaces between files by assuming that every
|
|
|
|
space which is preceded by two well-formed revision numbers is in fact a
|
|
|
|
separator. It disambiguates the first separator space from spaces in the
|
|
|
|
directory name by choosing the longest possible directory name that
|
|
|
|
actually exists in the repository"""
|
|
|
|
|
|
|
|
if (s[-16:] == ' - New directory'
|
|
|
|
or s[:26] == ' - New directory,NONE,NONE'):
|
|
|
|
return None, None
|
2003-07-24 12:48:40 +04:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
if (s[-19:] == ' - Imported sources'
|
|
|
|
or s[-29:] == ' - Imported sources,NONE,NONE'):
|
|
|
|
return None, None
|
2003-07-24 12:48:40 +04:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
file_data_list = []
|
|
|
|
start = 0
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
while 1:
|
|
|
|
m = _re_revisions.search(s, start)
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
if start == 0:
|
|
|
|
if m is None:
|
|
|
|
error('Argument "%s" does not contain any revision numbers' \
|
|
|
|
% s)
|
|
|
|
|
|
|
|
directory, filename = FindLongestDirectory(s[:m.start()],
|
|
|
|
repository)
|
|
|
|
if directory is None:
|
|
|
|
error('Argument "%s" does not start with a valid directory' \
|
|
|
|
% s)
|
2000-04-21 04:43:04 +04:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
debug('Directory name is "%s"' % directory)
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
else:
|
|
|
|
if m is None:
|
|
|
|
warning('Failed to interpret past position %i in the loginfo '
|
|
|
|
'argument, leftover string is "%s"' \
|
|
|
|
% start, pos[start:])
|
|
|
|
|
|
|
|
filename = s[start:m.start()]
|
|
|
|
|
|
|
|
old_version, new_version = m.group('old', 'new')
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
file_data_list.append((filename, old_version, new_version))
|
Get rid of rlog module, make CVSdb use bincvs instead.
* lib/rlog.py
deleted
* lib/cvsdb.py
(RLogDataToCommitList):
removed
(GetCommitListFromRCSFile):
change to use vclib instead of rlog module
(GetCommitListFromRCSFile, GetUnrecordedCommitList):
update to accept vclib-style path_parts arguments
* lib/vclib/bincvs/__init__.py
(BinCVSRepository.filelog):
accept "cvs_pass_rev" option for passing -r arguments to rlog
(_match_revs_tags):
make this function work with an incomplete list of revisions
instead of crashing. This is neccessary when an -r argument
is passed to rlog.
(_add_tag):
make this function work when we need to create a tag with no
revision object. We need this to create a HEAD tag when an -r
argument is passed to rlog and we don't know what the HEAD
revision is.
(fetch_log):
removed
* tools/cvsdbadmin
(RebuildFile):
removed, merged into UpdateFile
(UpdateFile)
accept new argument to reinsert all commits
(RecurseRebuild):
removed, merged into RecurseUpdate
(RecurseUpdate):
update to use vclib's listdir instead of os.listdir
(CommandRebuild, CommandUpdate):
removed, code moved into __main__ section
* tools/loginfo-handler
(FileData, CommitFromFileData, GetUnrecordedCommitList):
removed, these were just wrappers over the cvsdb interface
(HeuristicArgParse, CvsNtArgParse)
return tuples describing file data instead of file data objects
(ProcessLoginfo):
update to use cvsdb interface
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@953 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 06:23:23 +04:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
debug('File "%s", old revision %s, new revision %s'
|
|
|
|
% (filename, old_version, new_version))
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
start = m.end()
|
|
|
|
|
|
|
|
if start == len(s): break
|
Get rid of rlog module, make CVSdb use bincvs instead.
* lib/rlog.py
deleted
* lib/cvsdb.py
(RLogDataToCommitList):
removed
(GetCommitListFromRCSFile):
change to use vclib instead of rlog module
(GetCommitListFromRCSFile, GetUnrecordedCommitList):
update to accept vclib-style path_parts arguments
* lib/vclib/bincvs/__init__.py
(BinCVSRepository.filelog):
accept "cvs_pass_rev" option for passing -r arguments to rlog
(_match_revs_tags):
make this function work with an incomplete list of revisions
instead of crashing. This is neccessary when an -r argument
is passed to rlog.
(_add_tag):
make this function work when we need to create a tag with no
revision object. We need this to create a HEAD tag when an -r
argument is passed to rlog and we don't know what the HEAD
revision is.
(fetch_log):
removed
* tools/cvsdbadmin
(RebuildFile):
removed, merged into UpdateFile
(UpdateFile)
accept new argument to reinsert all commits
(RecurseRebuild):
removed, merged into RecurseUpdate
(RecurseUpdate):
update to use vclib's listdir instead of os.listdir
(CommandRebuild, CommandUpdate):
removed, code moved into __main__ section
* tools/loginfo-handler
(FileData, CommitFromFileData, GetUnrecordedCommitList):
removed, these were just wrappers over the cvsdb interface
(HeuristicArgParse, CvsNtArgParse)
return tuples describing file data instead of file data objects
(ProcessLoginfo):
update to use cvsdb interface
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@953 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 06:23:23 +04:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
return directory, file_data_list
|
Get rid of rlog module, make CVSdb use bincvs instead.
* lib/rlog.py
deleted
* lib/cvsdb.py
(RLogDataToCommitList):
removed
(GetCommitListFromRCSFile):
change to use vclib instead of rlog module
(GetCommitListFromRCSFile, GetUnrecordedCommitList):
update to accept vclib-style path_parts arguments
* lib/vclib/bincvs/__init__.py
(BinCVSRepository.filelog):
accept "cvs_pass_rev" option for passing -r arguments to rlog
(_match_revs_tags):
make this function work with an incomplete list of revisions
instead of crashing. This is neccessary when an -r argument
is passed to rlog.
(_add_tag):
make this function work when we need to create a tag with no
revision object. We need this to create a HEAD tag when an -r
argument is passed to rlog and we don't know what the HEAD
revision is.
(fetch_log):
removed
* tools/cvsdbadmin
(RebuildFile):
removed, merged into UpdateFile
(UpdateFile)
accept new argument to reinsert all commits
(RecurseRebuild):
removed, merged into RecurseUpdate
(RecurseUpdate):
update to use vclib's listdir instead of os.listdir
(CommandRebuild, CommandUpdate):
removed, code moved into __main__ section
* tools/loginfo-handler
(FileData, CommitFromFileData, GetUnrecordedCommitList):
removed, these were just wrappers over the cvsdb interface
(HeuristicArgParse, CvsNtArgParse)
return tuples describing file data instead of file data objects
(ProcessLoginfo):
update to use cvsdb interface
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@953 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 06:23:23 +04:00
|
|
|
|
2004-10-16 07:04:30 +04:00
|
|
|
def FindLongestDirectory(s, repository):
|
2006-11-02 06:19:40 +03:00
|
|
|
"""Splits the first part of the argument string into a directory name
|
|
|
|
and a file name, either of which may contain spaces. Returns the longest
|
|
|
|
possible directory name that actually exists"""
|
2004-10-16 04:47:42 +04:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
parts = string.split(s, " ")
|
|
|
|
|
|
|
|
for i in range(len(parts)-1, 0, -1):
|
|
|
|
directory = string.join(parts[:i])
|
|
|
|
filename = string.join(parts[i:])
|
|
|
|
if os.path.isdir(os.path.join(repository, directory)):
|
|
|
|
return directory, filename
|
|
|
|
|
|
|
|
return None, None
|
2003-02-11 06:09:17 +03:00
|
|
|
|
|
|
|
_re_cvsnt_revisions = re.compile(
|
2006-11-02 06:19:40 +03:00
|
|
|
r"(?P<filename>.*)" # comma and first revision
|
|
|
|
r",(?P<old>(?:\d+\.\d+)(?:\.\d+\.\d+)*|NONE)" # comma and first revision
|
|
|
|
r",(?P<new>(?:\d+\.\d+)(?:\.\d+\.\d+)*|NONE)" # comma and second revision
|
|
|
|
r"$" # end of string
|
2003-02-11 06:09:17 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
def CvsNtArgParse(s, repository):
|
2006-11-02 06:19:40 +03:00
|
|
|
"""CVSNT escapes all spaces in filenames and directory names with
|
|
|
|
backslashes"""
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
if s[-18:] == r' -\ New\ directory':
|
|
|
|
return None, None
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
if s[-21:] == r' -\ Imported\ sources':
|
|
|
|
return None, None
|
2004-10-16 04:47:42 +04:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
file_data_list = []
|
|
|
|
directory, pos = NextFile(s)
|
|
|
|
|
|
|
|
debug('Directory name is "%s"' % directory)
|
2004-10-16 04:47:42 +04:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
while 1:
|
|
|
|
fileinfo, pos = NextFile(s, pos)
|
|
|
|
if fileinfo is None:
|
|
|
|
break
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
m = _re_cvsnt_revisions.match(fileinfo)
|
|
|
|
if m is None:
|
|
|
|
warning('Can\'t parse file information in "%s"' % fileinfo)
|
|
|
|
continue
|
Get rid of rlog module, make CVSdb use bincvs instead.
* lib/rlog.py
deleted
* lib/cvsdb.py
(RLogDataToCommitList):
removed
(GetCommitListFromRCSFile):
change to use vclib instead of rlog module
(GetCommitListFromRCSFile, GetUnrecordedCommitList):
update to accept vclib-style path_parts arguments
* lib/vclib/bincvs/__init__.py
(BinCVSRepository.filelog):
accept "cvs_pass_rev" option for passing -r arguments to rlog
(_match_revs_tags):
make this function work with an incomplete list of revisions
instead of crashing. This is neccessary when an -r argument
is passed to rlog.
(_add_tag):
make this function work when we need to create a tag with no
revision object. We need this to create a HEAD tag when an -r
argument is passed to rlog and we don't know what the HEAD
revision is.
(fetch_log):
removed
* tools/cvsdbadmin
(RebuildFile):
removed, merged into UpdateFile
(UpdateFile)
accept new argument to reinsert all commits
(RecurseRebuild):
removed, merged into RecurseUpdate
(RecurseUpdate):
update to use vclib's listdir instead of os.listdir
(CommandRebuild, CommandUpdate):
removed, code moved into __main__ section
* tools/loginfo-handler
(FileData, CommitFromFileData, GetUnrecordedCommitList):
removed, these were just wrappers over the cvsdb interface
(HeuristicArgParse, CvsNtArgParse)
return tuples describing file data instead of file data objects
(ProcessLoginfo):
update to use cvsdb interface
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@953 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 06:23:23 +04:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
file_data = m.group('filename', 'old', 'new')
|
|
|
|
file_data_list.append(file_data)
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
debug('File "%s", old revision %s, new revision %s' % file_data)
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:19:40 +03:00
|
|
|
return directory, file_data_list
|
2003-02-11 06:09:17 +03:00
|
|
|
|
|
|
|
def NextFile(s, pos = 0):
|
2006-11-02 06:19:40 +03:00
|
|
|
escaped = 0
|
|
|
|
ret = ''
|
|
|
|
i = pos
|
|
|
|
while i < len(s):
|
|
|
|
c = s[i]
|
|
|
|
if escaped:
|
|
|
|
ret += c
|
|
|
|
escaped = 0
|
|
|
|
elif c == '\\':
|
|
|
|
escaped = 1
|
|
|
|
elif c == ' ':
|
|
|
|
return ret, i + 1
|
|
|
|
else:
|
|
|
|
ret += c
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
return ret or None, i
|
2003-02-11 06:09:17 +03:00
|
|
|
|
Get rid of rlog module, make CVSdb use bincvs instead.
* lib/rlog.py
deleted
* lib/cvsdb.py
(RLogDataToCommitList):
removed
(GetCommitListFromRCSFile):
change to use vclib instead of rlog module
(GetCommitListFromRCSFile, GetUnrecordedCommitList):
update to accept vclib-style path_parts arguments
* lib/vclib/bincvs/__init__.py
(BinCVSRepository.filelog):
accept "cvs_pass_rev" option for passing -r arguments to rlog
(_match_revs_tags):
make this function work with an incomplete list of revisions
instead of crashing. This is neccessary when an -r argument
is passed to rlog.
(_add_tag):
make this function work when we need to create a tag with no
revision object. We need this to create a HEAD tag when an -r
argument is passed to rlog and we don't know what the HEAD
revision is.
(fetch_log):
removed
* tools/cvsdbadmin
(RebuildFile):
removed, merged into UpdateFile
(UpdateFile)
accept new argument to reinsert all commits
(RecurseRebuild):
removed, merged into RecurseUpdate
(RecurseUpdate):
update to use vclib's listdir instead of os.listdir
(CommandRebuild, CommandUpdate):
removed, code moved into __main__ section
* tools/loginfo-handler
(FileData, CommitFromFileData, GetUnrecordedCommitList):
removed, these were just wrappers over the cvsdb interface
(HeuristicArgParse, CvsNtArgParse)
return tuples describing file data instead of file data objects
(ProcessLoginfo):
update to use cvsdb interface
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@953 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 06:23:23 +04:00
|
|
|
def ProcessLoginfo(rootpath, directory, files):
|
2006-03-18 03:33:54 +03:00
|
|
|
cfg = viewvc.load_config(CONF_PATHNAME)
|
Tweak logic used to find installed paths ("lib" directory, configuration
file, templates, etc). Specifically, make the following changes:
- Get rid of hardcoded paths in module files ("lib" directory) and
configuration files (viewcvs.conf and mod_python's .htaccess)
- Allow stub scripts (for asp, cgi, and mod_python) to specify
configuration files so it's possible to have multiple configurations of
viewcvs running off a single installation.
- Be more consistent about resolving paths when they aren't hardcoded
(when ViewCVS is running from a source directory). In particular, try
not to depend on the working directory. That way it's legal to run
./standalone.py instead of bin/standalone.py without getting an
ImportError.
- Get rid of global cfg variables in viewcvs.py and cvsdb.py. They led to
all sorts of hacks in other files to pilfer and reset them. They were
also possible sources of races in multithreaded environments like
mod_python and asp.
- Rewrite mod_python handler so library paths can be specified inside the
stub files.
* lib/apache.py
removed, contained old mod_python handler
* lib/config.py
(Config.load_config):
remove sys.argv voodoo, just load the configuration path specified in
the pathname argument
(Config.set_defaults):
use relative path for cvsgraph_conf setting instead of hardcoded
<VIEWCVS_INSTALL_DIRECTORY> literal
* lib/cvsdb.py
(CONF_PATHNAME, config, cfg):
removed, configuration stuff
(CheckinDatabase.__init__, CheckinDatabase.CreateSQLQueryString):
add "_row_limit" member instead of using cfg object
(CreateCheckinDatabase):
removed, a do-nothing function
(ConnectDatabaseReadOnly, ConnectDatabase):
add cfg arguments
(GetUnrecordedCommitList):
add db argument
* lib/query.py
(CONF_PATHAME):
removed
(build_commit, run_query, main):
add cfg arguments, use new viewcvs.get_template function
* lib/viewcvs.py
(CONF_PATHNAME, cfg, g_install_dir):
removed
(Request.__init__):
add cfg member
(Request.run_viewcvs, Request.get_link, check_freshness,
get_view_template, generate_page, default_view, get_file_view_info,
format_log, common_template_data, MarkupEnscript.__init__,
markup_stream_python, markup_stream_php, make_time_string, view_markup,
sort_file_data, view_directory, paging, view_log, view_annotate,
view_cvsgraph_image, view_cvsgraph, view_doc, rcsdiff_date_reformat,
spaced_html_text, DiffSource.__init__, DiffSource._get_row, view_patch,
view_diff, generate_tarball, download_tarball, view_revision,
is_query_supported, english_query, build_commit, view_query,
view_error, main):
stop using global config, use cfg arguments or request member instead
(_install_path):
new, use __file__ to locate template and configuation paths
(get_view_template):
use _install_path and return compiled template instead of path
(is_viewable, default_view):
rename is_viewable to default_view and return view instead of boolean
(handle_config, load_config):
rename handle_config to load_config and return config object instead
of setting cfg global
* bin/cgi/viewcvs.cgi
* bin/cgi/query.cgi
* bin/cvsdbadmin
* bin/loginfo-handler
* bin/standalone.py
* bin/svndbadmin
look for library relative to sys.argv[0] when no hardcoded library
path is available. Also add configuration loading code.
* bin/asp/viewcvs.asp
* bin/asp/query.asp
add configuration loading code
* bin/mod_python/.htaccess
specify new mod_python handler, remove reference to
<VIEWCVS_APACHE_LIBRARY_DIRECTORY>
* bin/mod_python/handler.py
added, holds new mod_python handler
* bin/mod_python/viewcvs.py
* bin/mod_python/query.py
rewrite for new handler, add hardcoded library and configuration paths
* viewcvs.conf.dist
remove references to <VIEWCVS_INSTALL_DIRECTORY>
* viewcvs-install
(FILE_INFO_LIST):
stop hardcoding paths in config files
(SetPythonPaths,):
get rid of <VIEWCVS_INSTALL_DIRECTORY> and
<VIEWCVS_APACHE_LIBRARY_DIRECTORY> substitutions
(ApacheEscape, _re_apache):
removed
(InstallTree):
stop hardcoding paths in lib directory
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1173 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-12-06 07:04:14 +03:00
|
|
|
db = cvsdb.ConnectDatabase(cfg)
|
2006-09-29 19:16:15 +04:00
|
|
|
repository = vclib.bincvs.BinCVSRepository(None, rootpath, cfg.utilities)
|
2000-04-21 04:43:04 +04:00
|
|
|
|
Get rid of rlog module, make CVSdb use bincvs instead.
* lib/rlog.py
deleted
* lib/cvsdb.py
(RLogDataToCommitList):
removed
(GetCommitListFromRCSFile):
change to use vclib instead of rlog module
(GetCommitListFromRCSFile, GetUnrecordedCommitList):
update to accept vclib-style path_parts arguments
* lib/vclib/bincvs/__init__.py
(BinCVSRepository.filelog):
accept "cvs_pass_rev" option for passing -r arguments to rlog
(_match_revs_tags):
make this function work with an incomplete list of revisions
instead of crashing. This is neccessary when an -r argument
is passed to rlog.
(_add_tag):
make this function work when we need to create a tag with no
revision object. We need this to create a HEAD tag when an -r
argument is passed to rlog and we don't know what the HEAD
revision is.
(fetch_log):
removed
* tools/cvsdbadmin
(RebuildFile):
removed, merged into UpdateFile
(UpdateFile)
accept new argument to reinsert all commits
(RecurseRebuild):
removed, merged into RecurseUpdate
(RecurseUpdate):
update to use vclib's listdir instead of os.listdir
(CommandRebuild, CommandUpdate):
removed, code moved into __main__ section
* tools/loginfo-handler
(FileData, CommitFromFileData, GetUnrecordedCommitList):
removed, these were just wrappers over the cvsdb interface
(HeuristicArgParse, CvsNtArgParse)
return tuples describing file data instead of file data objects
(ProcessLoginfo):
update to use cvsdb interface
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@953 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 06:23:23 +04:00
|
|
|
# split up the directory components
|
|
|
|
dirpath = filter(None, string.split(os.path.normpath(directory), os.sep))
|
|
|
|
|
2004-10-16 07:04:30 +04:00
|
|
|
## build a list of Commit objects
|
2000-04-21 04:43:04 +04:00
|
|
|
commit_list = []
|
Get rid of rlog module, make CVSdb use bincvs instead.
* lib/rlog.py
deleted
* lib/cvsdb.py
(RLogDataToCommitList):
removed
(GetCommitListFromRCSFile):
change to use vclib instead of rlog module
(GetCommitListFromRCSFile, GetUnrecordedCommitList):
update to accept vclib-style path_parts arguments
* lib/vclib/bincvs/__init__.py
(BinCVSRepository.filelog):
accept "cvs_pass_rev" option for passing -r arguments to rlog
(_match_revs_tags):
make this function work with an incomplete list of revisions
instead of crashing. This is neccessary when an -r argument
is passed to rlog.
(_add_tag):
make this function work when we need to create a tag with no
revision object. We need this to create a HEAD tag when an -r
argument is passed to rlog and we don't know what the HEAD
revision is.
(fetch_log):
removed
* tools/cvsdbadmin
(RebuildFile):
removed, merged into UpdateFile
(UpdateFile)
accept new argument to reinsert all commits
(RecurseRebuild):
removed, merged into RecurseUpdate
(RecurseUpdate):
update to use vclib's listdir instead of os.listdir
(CommandRebuild, CommandUpdate):
removed, code moved into __main__ section
* tools/loginfo-handler
(FileData, CommitFromFileData, GetUnrecordedCommitList):
removed, these were just wrappers over the cvsdb interface
(HeuristicArgParse, CvsNtArgParse)
return tuples describing file data instead of file data objects
(ProcessLoginfo):
update to use cvsdb interface
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@953 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 06:23:23 +04:00
|
|
|
for filename, old_version, new_version in files:
|
|
|
|
filepath = dirpath + [filename]
|
|
|
|
|
2000-04-21 04:43:04 +04:00
|
|
|
## XXX: this is nasty: in the case of a removed file, we are not
|
|
|
|
## given enough information to find it in the rlog output!
|
|
|
|
## So instead, we rlog everything in the removed file, and
|
|
|
|
## add any commits not already in the database
|
Get rid of rlog module, make CVSdb use bincvs instead.
* lib/rlog.py
deleted
* lib/cvsdb.py
(RLogDataToCommitList):
removed
(GetCommitListFromRCSFile):
change to use vclib instead of rlog module
(GetCommitListFromRCSFile, GetUnrecordedCommitList):
update to accept vclib-style path_parts arguments
* lib/vclib/bincvs/__init__.py
(BinCVSRepository.filelog):
accept "cvs_pass_rev" option for passing -r arguments to rlog
(_match_revs_tags):
make this function work with an incomplete list of revisions
instead of crashing. This is neccessary when an -r argument
is passed to rlog.
(_add_tag):
make this function work when we need to create a tag with no
revision object. We need this to create a HEAD tag when an -r
argument is passed to rlog and we don't know what the HEAD
revision is.
(fetch_log):
removed
* tools/cvsdbadmin
(RebuildFile):
removed, merged into UpdateFile
(UpdateFile)
accept new argument to reinsert all commits
(RecurseRebuild):
removed, merged into RecurseUpdate
(RecurseUpdate):
update to use vclib's listdir instead of os.listdir
(CommandRebuild, CommandUpdate):
removed, code moved into __main__ section
* tools/loginfo-handler
(FileData, CommitFromFileData, GetUnrecordedCommitList):
removed, these were just wrappers over the cvsdb interface
(HeuristicArgParse, CvsNtArgParse)
return tuples describing file data instead of file data objects
(ProcessLoginfo):
update to use cvsdb interface
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@953 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 06:23:23 +04:00
|
|
|
if new_version == 'NONE':
|
Tweak logic used to find installed paths ("lib" directory, configuration
file, templates, etc). Specifically, make the following changes:
- Get rid of hardcoded paths in module files ("lib" directory) and
configuration files (viewcvs.conf and mod_python's .htaccess)
- Allow stub scripts (for asp, cgi, and mod_python) to specify
configuration files so it's possible to have multiple configurations of
viewcvs running off a single installation.
- Be more consistent about resolving paths when they aren't hardcoded
(when ViewCVS is running from a source directory). In particular, try
not to depend on the working directory. That way it's legal to run
./standalone.py instead of bin/standalone.py without getting an
ImportError.
- Get rid of global cfg variables in viewcvs.py and cvsdb.py. They led to
all sorts of hacks in other files to pilfer and reset them. They were
also possible sources of races in multithreaded environments like
mod_python and asp.
- Rewrite mod_python handler so library paths can be specified inside the
stub files.
* lib/apache.py
removed, contained old mod_python handler
* lib/config.py
(Config.load_config):
remove sys.argv voodoo, just load the configuration path specified in
the pathname argument
(Config.set_defaults):
use relative path for cvsgraph_conf setting instead of hardcoded
<VIEWCVS_INSTALL_DIRECTORY> literal
* lib/cvsdb.py
(CONF_PATHNAME, config, cfg):
removed, configuration stuff
(CheckinDatabase.__init__, CheckinDatabase.CreateSQLQueryString):
add "_row_limit" member instead of using cfg object
(CreateCheckinDatabase):
removed, a do-nothing function
(ConnectDatabaseReadOnly, ConnectDatabase):
add cfg arguments
(GetUnrecordedCommitList):
add db argument
* lib/query.py
(CONF_PATHAME):
removed
(build_commit, run_query, main):
add cfg arguments, use new viewcvs.get_template function
* lib/viewcvs.py
(CONF_PATHNAME, cfg, g_install_dir):
removed
(Request.__init__):
add cfg member
(Request.run_viewcvs, Request.get_link, check_freshness,
get_view_template, generate_page, default_view, get_file_view_info,
format_log, common_template_data, MarkupEnscript.__init__,
markup_stream_python, markup_stream_php, make_time_string, view_markup,
sort_file_data, view_directory, paging, view_log, view_annotate,
view_cvsgraph_image, view_cvsgraph, view_doc, rcsdiff_date_reformat,
spaced_html_text, DiffSource.__init__, DiffSource._get_row, view_patch,
view_diff, generate_tarball, download_tarball, view_revision,
is_query_supported, english_query, build_commit, view_query,
view_error, main):
stop using global config, use cfg arguments or request member instead
(_install_path):
new, use __file__ to locate template and configuation paths
(get_view_template):
use _install_path and return compiled template instead of path
(is_viewable, default_view):
rename is_viewable to default_view and return view instead of boolean
(handle_config, load_config):
rename handle_config to load_config and return config object instead
of setting cfg global
* bin/cgi/viewcvs.cgi
* bin/cgi/query.cgi
* bin/cvsdbadmin
* bin/loginfo-handler
* bin/standalone.py
* bin/svndbadmin
look for library relative to sys.argv[0] when no hardcoded library
path is available. Also add configuration loading code.
* bin/asp/viewcvs.asp
* bin/asp/query.asp
add configuration loading code
* bin/mod_python/.htaccess
specify new mod_python handler, remove reference to
<VIEWCVS_APACHE_LIBRARY_DIRECTORY>
* bin/mod_python/handler.py
added, holds new mod_python handler
* bin/mod_python/viewcvs.py
* bin/mod_python/query.py
rewrite for new handler, add hardcoded library and configuration paths
* viewcvs.conf.dist
remove references to <VIEWCVS_INSTALL_DIRECTORY>
* viewcvs-install
(FILE_INFO_LIST):
stop hardcoding paths in config files
(SetPythonPaths,):
get rid of <VIEWCVS_INSTALL_DIRECTORY> and
<VIEWCVS_APACHE_LIBRARY_DIRECTORY> substitutions
(ApacheEscape, _re_apache):
removed
(InstallTree):
stop hardcoding paths in lib directory
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1173 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-12-06 07:04:14 +03:00
|
|
|
commits = cvsdb.GetUnrecordedCommitList(repository, filepath, db)
|
2000-04-21 04:43:04 +04:00
|
|
|
else:
|
Get rid of rlog module, make CVSdb use bincvs instead.
* lib/rlog.py
deleted
* lib/cvsdb.py
(RLogDataToCommitList):
removed
(GetCommitListFromRCSFile):
change to use vclib instead of rlog module
(GetCommitListFromRCSFile, GetUnrecordedCommitList):
update to accept vclib-style path_parts arguments
* lib/vclib/bincvs/__init__.py
(BinCVSRepository.filelog):
accept "cvs_pass_rev" option for passing -r arguments to rlog
(_match_revs_tags):
make this function work with an incomplete list of revisions
instead of crashing. This is neccessary when an -r argument
is passed to rlog.
(_add_tag):
make this function work when we need to create a tag with no
revision object. We need this to create a HEAD tag when an -r
argument is passed to rlog and we don't know what the HEAD
revision is.
(fetch_log):
removed
* tools/cvsdbadmin
(RebuildFile):
removed, merged into UpdateFile
(UpdateFile)
accept new argument to reinsert all commits
(RecurseRebuild):
removed, merged into RecurseUpdate
(RecurseUpdate):
update to use vclib's listdir instead of os.listdir
(CommandRebuild, CommandUpdate):
removed, code moved into __main__ section
* tools/loginfo-handler
(FileData, CommitFromFileData, GetUnrecordedCommitList):
removed, these were just wrappers over the cvsdb interface
(HeuristicArgParse, CvsNtArgParse)
return tuples describing file data instead of file data objects
(ProcessLoginfo):
update to use cvsdb interface
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@953 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 06:23:23 +04:00
|
|
|
commits = cvsdb.GetCommitListFromRCSFile(repository, filepath,
|
|
|
|
new_version)
|
|
|
|
|
|
|
|
commit_list.extend(commits)
|
2000-04-21 04:43:04 +04:00
|
|
|
|
|
|
|
## add to the database
|
|
|
|
db.AddCommitList(commit_list)
|
|
|
|
|
|
|
|
|
|
|
|
## MAIN
|
|
|
|
if __name__ == '__main__':
|
|
|
|
## get the repository from the environment
|
|
|
|
try:
|
2004-10-16 04:47:42 +04:00
|
|
|
repository = os.environ['CVSROOT']
|
2000-04-21 04:43:04 +04:00
|
|
|
except KeyError:
|
|
|
|
error('CVSROOT not in environment')
|
|
|
|
|
2003-02-11 06:09:17 +03:00
|
|
|
debug('Repository name is "%s"' % repository)
|
2003-02-09 13:05:00 +03:00
|
|
|
|
2003-02-11 06:09:17 +03:00
|
|
|
## parse arguments
|
2006-11-02 06:13:53 +03:00
|
|
|
|
|
|
|
argc = len(sys.argv)
|
|
|
|
debug('Got %d arguments: %s' % (argc, str(sys.argv)))
|
|
|
|
|
|
|
|
# if we have more than 3 arguments, we are likely using the
|
|
|
|
# newer loginfo format introduced in CVS 1.12:
|
|
|
|
#
|
|
|
|
# ALL <path>/bin/loginfo-handler %p %{sVv}
|
|
|
|
if argc > 3:
|
|
|
|
directory, files = Cvs1Dot12ArgParse(sys.argv[1:])
|
2003-02-11 06:09:17 +03:00
|
|
|
else:
|
2006-11-02 06:13:53 +03:00
|
|
|
if len(sys.argv) > 1:
|
|
|
|
# the first argument should contain file version information
|
|
|
|
arg = sys.argv[1]
|
2003-02-11 06:09:17 +03:00
|
|
|
else:
|
2006-11-02 06:13:53 +03:00
|
|
|
# if there are no arguments, read version information from
|
|
|
|
# first line of input like old versions of ViewCVS did
|
|
|
|
arg = string.rstrip(sys.stdin.readline())
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2006-11-02 06:13:53 +03:00
|
|
|
if len(sys.argv) > 2:
|
|
|
|
# if there is a second argument it indicates which parser
|
|
|
|
# should be used to interpret the version information
|
|
|
|
if sys.argv[2] == 'cvs':
|
|
|
|
fun = HeuristicArgParse
|
|
|
|
elif sys.argv[2] == 'cvsnt':
|
|
|
|
fun = CvsNtArgParse
|
|
|
|
else:
|
|
|
|
error('Bad arguments')
|
|
|
|
else:
|
|
|
|
# if there is no second argument, guess which parser to use based
|
|
|
|
# on the operating system. Since CVSNT now runs on Windows and
|
|
|
|
# Linux, the guess isn't necessarily correct
|
|
|
|
if sys.platform == "win32":
|
|
|
|
fun = CvsNtArgParse
|
|
|
|
else:
|
|
|
|
fun = HeuristicArgParse
|
|
|
|
|
|
|
|
directory, files = fun(arg, repository)
|
2003-02-11 06:09:17 +03:00
|
|
|
|
2004-10-16 04:47:42 +04:00
|
|
|
repository = cvsdb.CleanRepository(repository)
|
2006-11-02 06:13:53 +03:00
|
|
|
|
|
|
|
debug('Repository: %s' % (repository))
|
|
|
|
debug('Directory: %s' % (directory))
|
2006-11-02 06:56:53 +03:00
|
|
|
debug('Files: %s' % (str(files)))
|
2003-02-11 06:09:17 +03:00
|
|
|
|
Get rid of rlog module, make CVSdb use bincvs instead.
* lib/rlog.py
deleted
* lib/cvsdb.py
(RLogDataToCommitList):
removed
(GetCommitListFromRCSFile):
change to use vclib instead of rlog module
(GetCommitListFromRCSFile, GetUnrecordedCommitList):
update to accept vclib-style path_parts arguments
* lib/vclib/bincvs/__init__.py
(BinCVSRepository.filelog):
accept "cvs_pass_rev" option for passing -r arguments to rlog
(_match_revs_tags):
make this function work with an incomplete list of revisions
instead of crashing. This is neccessary when an -r argument
is passed to rlog.
(_add_tag):
make this function work when we need to create a tag with no
revision object. We need this to create a HEAD tag when an -r
argument is passed to rlog and we don't know what the HEAD
revision is.
(fetch_log):
removed
* tools/cvsdbadmin
(RebuildFile):
removed, merged into UpdateFile
(UpdateFile)
accept new argument to reinsert all commits
(RecurseRebuild):
removed, merged into RecurseUpdate
(RecurseUpdate):
update to use vclib's listdir instead of os.listdir
(CommandRebuild, CommandUpdate):
removed, code moved into __main__ section
* tools/loginfo-handler
(FileData, CommitFromFileData, GetUnrecordedCommitList):
removed, these were just wrappers over the cvsdb interface
(HeuristicArgParse, CvsNtArgParse)
return tuples describing file data instead of file data objects
(ProcessLoginfo):
update to use cvsdb interface
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@953 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 06:23:23 +04:00
|
|
|
if files is None:
|
2006-11-02 06:13:53 +03:00
|
|
|
debug('Not a checkin, nothing to do')
|
2003-02-11 06:09:17 +03:00
|
|
|
else:
|
2006-11-02 06:13:53 +03:00
|
|
|
ProcessLoginfo(repository, directory, files)
|
2000-04-21 04:43:04 +04:00
|
|
|
|
|
|
|
sys.exit(0)
|