viewvc-4intranet/bin/loginfo-handler

278 lines
8.1 KiB
Plaintext
Raw Normal View History

#!/usr/bin/python
# -*- Mode: python -*-
#
# Copyright (C) 2000 The ViewCVS Group. All Rights Reserved.
#
# By using this file, you agree to the terms and conditions set forth in
# the LICENSE.html file which can be found at the top level of the ViewCVS
# distribution or at http://www.lyra.org/viewcvs/license-1.html.
#
# Contact information:
# Greg Stein, PO Box 760, Palo Alto, CA, 94302
# gstein@lyra.org, http://www.lyra.org/viewcvs/
#
# -----------------------------------------------------------------------
#
# updates SQL database with new commit records
#
# -----------------------------------------------------------------------
#
#########################################################################
#
# 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
if LIBRARY_DIR:
sys.path.insert(0, LIBRARY_DIR)
else:
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
sys.path.insert(0, os.path.abspath(os.path.join(sys.argv[0], "../../lib")))
#########################################################################
import os
import string
import getopt
import re
import cvsdb
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 viewcvs
import vclib.bincvs
DEBUG_FLAG = 0
## output functions
def debug(text):
if DEBUG_FLAG:
print 'DEBUG(viewcvs-loginfo):', text
def warning(text):
print 'WARNING(viewcvs-loginfo):', text
def error(text):
print 'ERROR(viewcvs-loginfo):', text
sys.exit(1)
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
_re_revisions = re.compile(
r",(?P<old>(?:\d+\.\d+)(?:\.\d+\.\d+)*|NONE)" # comma and first revision number
r",(?P<new>(?:\d+\.\d+)(?:\.\d+\.\d+)*|NONE)" # comma and second revision number
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
r"(?:$| )" # space or end of string
)
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
def HeuristicArgParse(s, repository):
"""Current 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
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
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
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
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':
return None, None
if s[-19:] == r' - Imported sources':
return None, None
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
file_data_list = []
start = 0
while 1:
m = _re_revisions.search(s, start)
if start == 0:
if m is None:
error('Argument "%s" does not contain any revision numbers' % s)
directory, filename = FindLongestDirectory(s[:m.start()], repository)
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
if directory is None:
error('Argument "%s" does not start with a valid directory' % s)
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
debug('Directory name is "%s"' % directory)
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')
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
file_data_list.append((filename, old_version, new_version))
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
debug('File "%s", old revision %s, new revision %s'
% (filename, old_version, new_version))
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
return directory, file_data_list
def FindLongestDirectory(s, repository):
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +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"""
Fix file path issues in CVSdb on windows. Summary of changes: - Stop converting directory and file paths to lower case with native slashes before storing them in the database. Instead store with preserved case and forward slashes. - Stop trying to clean up paths haphazardly all over the cvsdb module, instead expect paths to be normalized before they get passed to cvsdb. * lib/cvsdb.py (Commit.SetRepository, Commit.SetDirectory, Commit.SetFile, CheckinDatabaseQuery.SetRepository, CheckinDatabaseQuery.SetDirectory): remove path cleanup code (RLogDataToCommitList) don't strip repository prefix because rlog module now does it (CleanRepository): new function * lib/rlog.py (_get_co_file): change to return paths with forward slashes and without repository prefixes (GetRLogData): update call to _get_co_file * tools/cvsdbadmin (UpdateFile, CommandUpdate, RebuildFile, CommandRebuild) remove calls to normcase here (module code): use CleanRepository function to clean up repository path * tools/loginfo-handler (CleanDirectory): removed (HeuristicArgParse, CvsNtArgParse): don't call CleanDirectory or normcase here (HeuristicArgParseDirectory): remove stray print statement (module code): use cvsdb.CleanRepository function to clean up repository path * tools/svndbadmin (module code): use cvsdb.CleanRepository function to clean up repository path * lib/viewcvs.py (view_query): change to use forward slashes in directory names instead of native slashes use cvsdb.CleanRepository function to clean up repository paths * lib/query.py (build_commit): change to handle forward slashes in directory paths instead of native slashes (run_query): use cvsdb.CleanRepository function to clean up repository path git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@952 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 04:47:42 +04:00
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +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
_re_cvsnt_revisions = re.compile(
r"(?P<filename>.*)" # comma and first revision number
r",(?P<old>(?:\d+\.\d+)(?:\.\d+\.\d+)*|NONE)" # comma and first revision number
r",(?P<new>(?:\d+\.\d+)(?:\.\d+\.\d+)*|NONE)" # comma and second revision number
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
r"$" # end of string
)
def CvsNtArgParse(s, repository):
"""CVSNT escapes all spaces in filenames and directory names with
backslashes"""
if s[-18:] == r' -\ New\ directory':
return None, None
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
if s[-21:] == r' -\ Imported\ sources':
return None, None
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
file_data_list = []
directory, pos = NextFile(s)
debug('Directory name is "%s"' % directory)
Fix file path issues in CVSdb on windows. Summary of changes: - Stop converting directory and file paths to lower case with native slashes before storing them in the database. Instead store with preserved case and forward slashes. - Stop trying to clean up paths haphazardly all over the cvsdb module, instead expect paths to be normalized before they get passed to cvsdb. * lib/cvsdb.py (Commit.SetRepository, Commit.SetDirectory, Commit.SetFile, CheckinDatabaseQuery.SetRepository, CheckinDatabaseQuery.SetDirectory): remove path cleanup code (RLogDataToCommitList) don't strip repository prefix because rlog module now does it (CleanRepository): new function * lib/rlog.py (_get_co_file): change to return paths with forward slashes and without repository prefixes (GetRLogData): update call to _get_co_file * tools/cvsdbadmin (UpdateFile, CommandUpdate, RebuildFile, CommandRebuild) remove calls to normcase here (module code): use CleanRepository function to clean up repository path * tools/loginfo-handler (CleanDirectory): removed (HeuristicArgParse, CvsNtArgParse): don't call CleanDirectory or normcase here (HeuristicArgParseDirectory): remove stray print statement (module code): use cvsdb.CleanRepository function to clean up repository path * tools/svndbadmin (module code): use cvsdb.CleanRepository function to clean up repository path * lib/viewcvs.py (view_query): change to use forward slashes in directory names instead of native slashes use cvsdb.CleanRepository function to clean up repository paths * lib/query.py (build_commit): change to handle forward slashes in directory paths instead of native slashes (run_query): use cvsdb.CleanRepository function to clean up repository path git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@952 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 04:47:42 +04:00
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
while 1:
fileinfo, pos = NextFile(s, pos)
if fileinfo is None:
break
Fix file path issues in CVSdb on windows. Summary of changes: - Stop converting directory and file paths to lower case with native slashes before storing them in the database. Instead store with preserved case and forward slashes. - Stop trying to clean up paths haphazardly all over the cvsdb module, instead expect paths to be normalized before they get passed to cvsdb. * lib/cvsdb.py (Commit.SetRepository, Commit.SetDirectory, Commit.SetFile, CheckinDatabaseQuery.SetRepository, CheckinDatabaseQuery.SetDirectory): remove path cleanup code (RLogDataToCommitList) don't strip repository prefix because rlog module now does it (CleanRepository): new function * lib/rlog.py (_get_co_file): change to return paths with forward slashes and without repository prefixes (GetRLogData): update call to _get_co_file * tools/cvsdbadmin (UpdateFile, CommandUpdate, RebuildFile, CommandRebuild) remove calls to normcase here (module code): use CleanRepository function to clean up repository path * tools/loginfo-handler (CleanDirectory): removed (HeuristicArgParse, CvsNtArgParse): don't call CleanDirectory or normcase here (HeuristicArgParseDirectory): remove stray print statement (module code): use cvsdb.CleanRepository function to clean up repository path * tools/svndbadmin (module code): use cvsdb.CleanRepository function to clean up repository path * lib/viewcvs.py (view_query): change to use forward slashes in directory names instead of native slashes use cvsdb.CleanRepository function to clean up repository paths * lib/query.py (build_commit): change to handle forward slashes in directory paths instead of native slashes (run_query): use cvsdb.CleanRepository function to clean up repository path git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@952 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 04:47:42 +04:00
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +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
file_data = m.group('filename', 'old', 'new')
debug('File "%s", old revision %s, new revision %s' % file_data)
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
file_data_list.append(file_data)
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
return directory, file_data_list
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
def NextFile(s, pos = 0):
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
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
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):
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
cfg = viewcvs.load_config(CONF_PATHNAME)
db = cvsdb.ConnectDatabase(cfg)
repository = vclib.bincvs.BinCVSRepository(None, rootpath, cfg.general)
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))
## build a list of Commit objects
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]
## 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)
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)
## add to the database
db.AddCommitList(commit_list)
## MAIN
if __name__ == '__main__':
## get the repository from the environment
try:
Fix file path issues in CVSdb on windows. Summary of changes: - Stop converting directory and file paths to lower case with native slashes before storing them in the database. Instead store with preserved case and forward slashes. - Stop trying to clean up paths haphazardly all over the cvsdb module, instead expect paths to be normalized before they get passed to cvsdb. * lib/cvsdb.py (Commit.SetRepository, Commit.SetDirectory, Commit.SetFile, CheckinDatabaseQuery.SetRepository, CheckinDatabaseQuery.SetDirectory): remove path cleanup code (RLogDataToCommitList) don't strip repository prefix because rlog module now does it (CleanRepository): new function * lib/rlog.py (_get_co_file): change to return paths with forward slashes and without repository prefixes (GetRLogData): update call to _get_co_file * tools/cvsdbadmin (UpdateFile, CommandUpdate, RebuildFile, CommandRebuild) remove calls to normcase here (module code): use CleanRepository function to clean up repository path * tools/loginfo-handler (CleanDirectory): removed (HeuristicArgParse, CvsNtArgParse): don't call CleanDirectory or normcase here (HeuristicArgParseDirectory): remove stray print statement (module code): use cvsdb.CleanRepository function to clean up repository path * tools/svndbadmin (module code): use cvsdb.CleanRepository function to clean up repository path * lib/viewcvs.py (view_query): change to use forward slashes in directory names instead of native slashes use cvsdb.CleanRepository function to clean up repository paths * lib/query.py (build_commit): change to handle forward slashes in directory paths instead of native slashes (run_query): use cvsdb.CleanRepository function to clean up repository path git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@952 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 04:47:42 +04:00
repository = os.environ['CVSROOT']
except KeyError:
error('CVSROOT not in environment')
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
debug('Repository name is "%s"' % repository)
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03:00
## parse arguments
if len(sys.argv) > 1:
# the first argument should contain file version information
arg = sys.argv[1]
else:
# if there are no arguments, read version information from first line
# of input just like previous versions of viewcvs
arg = string.rstrip(sys.stdin.readline())
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 neccessarily correct
if sys.platform == "win32":
fun = CvsNtArgParse
else:
fun = HeuristicArgParse
if len(sys.argv) > 3:
error('Bad arguments')
Fix file path issues in CVSdb on windows. Summary of changes: - Stop converting directory and file paths to lower case with native slashes before storing them in the database. Instead store with preserved case and forward slashes. - Stop trying to clean up paths haphazardly all over the cvsdb module, instead expect paths to be normalized before they get passed to cvsdb. * lib/cvsdb.py (Commit.SetRepository, Commit.SetDirectory, Commit.SetFile, CheckinDatabaseQuery.SetRepository, CheckinDatabaseQuery.SetDirectory): remove path cleanup code (RLogDataToCommitList) don't strip repository prefix because rlog module now does it (CleanRepository): new function * lib/rlog.py (_get_co_file): change to return paths with forward slashes and without repository prefixes (GetRLogData): update call to _get_co_file * tools/cvsdbadmin (UpdateFile, CommandUpdate, RebuildFile, CommandRebuild) remove calls to normcase here (module code): use CleanRepository function to clean up repository path * tools/loginfo-handler (CleanDirectory): removed (HeuristicArgParse, CvsNtArgParse): don't call CleanDirectory or normcase here (HeuristicArgParseDirectory): remove stray print statement (module code): use cvsdb.CleanRepository function to clean up repository path * tools/svndbadmin (module code): use cvsdb.CleanRepository function to clean up repository path * lib/viewcvs.py (view_query): change to use forward slashes in directory names instead of native slashes use cvsdb.CleanRepository function to clean up repository paths * lib/query.py (build_commit): change to handle forward slashes in directory paths instead of native slashes (run_query): use cvsdb.CleanRepository function to clean up repository path git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@952 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-10-16 04:47:42 +04:00
repository = cvsdb.CleanRepository(repository)
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
directory, files = fun(arg, repository)
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
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:
debug('Not a checkin, nothing to do')
There are a few significant changes to the loginfo handler script. 1) There's a new way to pass it parameters. You can write: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} instead of: ALL (echo %{sVv}; cat) | <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler although for backwards compatibility, the old invokation still works. The reason for the change is to make life easier for windows users who do not typically have cat and a unix-style echo command installed on their machines. 2) It now sort of supports spaces in file names. Current versions of CVS pass loginfo parameters in a space-separated string without bothering to escape the spaces that can occur in filenames within the string. This can make it impossible to unambiguously parse, so a heuristic is used to guess which spaces are meant to be separators and which are part of file names. (See the documentation string for the HeuristicArgParse() function for a description of how it works). The heuristic should be pretty reliable when spaces are used in filenames AND directory names, extremely reliable when spaces are allowed in EITHER filenames OR directory names, and completely reliable in the unambiguous case when there are no spaces in path names. There is a completely different situation with CVSNT. CVSNT does escape spaces and special characters with backslashes so no heuristic is needed. A separate parsing routine is used for this case. 3) By default the loginfo handler will run the CVSNT parsing routine on windows and the heuristic parsing routine on all other platforms. But since CVSNT has been backported to Unix, there may be some people who need to override the default. This can be done by tacking on a second parameter: ALL <VIEWCVS_INSTALLATION_DIRECTORY>/loginfo-handler %{sVv} <arg2> where <arg2> is either "cvs", "cvsnt", or "brokencvsnt". "brokencvsnt" is for some semi-recent versions of CVSNT which mistakenly escaped filenames twice. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@604 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-02-11 06:09:17 +03: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
ProcessLoginfo(repository, directory, files)
sys.exit(0)