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

1223 lines
40 KiB
Python
Raw Normal View History

# -*-python-*-
#
# Copyright (C) 1999-2013 The ViewCVS Group. All Rights Reserved.
#
# By using this file, you agree to the terms and conditions set forth in
Work on issue 168, s/ViewCVS/ViewVC. This patch changes references to ViewCVS in comments, strings, and documentation. References to ViewCVS in filenames and urls still need to be fixed. Also, logo.png (the blimp) needs to be updated or replaced. This patch is by Gerard Gerritsen (sigcafe), the only change I've made is to restore a reference to ViewCVS in a comment about backwards compatibility. * windows/README * viewcvs-install * README * templates/include/footer.ezt * templates/include/header.ezt * templates/error.ezt * templates/query.ezt * templates/docroot/help.css * templates/docroot/help_query.html * templates/docroot/help_dirview.html * templates/docroot/help_rootview.html * templates/docroot/styles.css * templates/docroot/help_log.html * templates/diff.ezt * tools/make-release * lib/sapi.py * lib/dbi.py * lib/accept.py * lib/cvsdb.py * lib/config.py * lib/query.py * lib/vclib/bincvs/__init__.py * lib/vclib/svn/__init__.py * lib/vclib/__init__.py * lib/vclib/svn_ra/__init__.py * lib/vclib/ccvs/rcsparse/common.py * lib/vclib/ccvs/rcsparse/__init__.py * lib/vclib/ccvs/rcsparse/default.py * lib/vclib/ccvs/rcsparse/texttools.py * lib/vclib/ccvs/rcsparse/debug.py * lib/vclib/ccvs/__init__.py * lib/vclib/ccvs/blame.py * lib/blame.py * lib/popen.py * lib/compat.py * lib/viewcvs.py * lib/debug.py * INSTALL * bin/standalone.py * bin/make-database * bin/mod_python/query.py * bin/mod_python/viewcvs.py * bin/cgi/query.cgi * bin/cgi/viewcvs.cgi * bin/asp/query.asp * bin/asp/viewcvs.asp * bin/svndbadmin * bin/loginfo-handler * bin/cvsdbadmin * viewcvs.conf.dist git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1200 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-12-17 20:19:28 +03:00
# the LICENSE.html file which can be found at the top level of the ViewVC
# distribution or at http://viewvc.org/license-1.html.
#
# For more information, visit http://viewvc.org/
#
# -----------------------------------------------------------------------
This commit contains three changes, which I couldn't split back apart very easily (sorry): 1) use LogEntry for the fileinfo stuff 2) use bincvs.Repository for some basic functionality 3) update bincvs.__init__.py to the API that was checked in last week * viewcvs.py (class Request): remember the split path parts. refine some of the error logic and messages. replace .cvsrep and .cvsroot with a Repository instance (and use .name and .rootpath instead). (_validate_cvsroot): refine the error message (clickable_path): use request.repos (view_directory, generate_tarball): use request.repos. use LogEntry for fileinfo. (file_sort_cmp): update for LogEntry (view_annotate, cvsgraph_image, viewcvs_graph, search_files, view_diff): use repos.rootpath rather than .cvsroot (main): tweak the ordering of some checks and dispatching. use the repos.itemtype() functionality to test for "is a directory". remove test for whether the CVS root exists -- it was done during the Request initialization. * vclib/bincvs/__init__.py (_FILE_HAD_ERROR): copied over from viewcvs.py (class LogError): new class (unused so far) to represent an error. (process_rlog_output): use LogEntry for fileinfo rather than a tuple (class BinCVSRepository): - change the init to verify the root is a directory, and store the name and rootpath (rootpath used to be called basepath). - add new .getitem() and .itemtype() methods for retrieving and querying about items, respectively. - tweak _getpath() joining of paths so we don't have to worry about adding a separator onto .rootpath. - remove .getfile() (now part of getitem). - replace .getsubdirs() with ._getvf_subdirs(). - replace .getfiles() with ._getvf_files(). git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@521 8cb11bc2-c004-0410-86c3-e597b4017df7
2002-06-03 22:35:06 +04:00
"Version Control lib driver for locally accessible cvs-repositories."
import vclib
import vcauth
import os
import os.path
import sys
import stat
import re
import time
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
import calendar
# ViewVC libs
import popen
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
import vclib.ccvs
def _path_join(path_parts):
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
return '/'.join(path_parts)
Merge changes (r1735:1738) from the (misnamed) options-overhaul branch. This reduces the number of vclib plugins to two -- one for each of CVS and Subversion. * lib/viewvc.py (): Update callers of vclib.svn.created_rev(), vclib.svn.get_location(), vclib.svn.get_youngest_revision(), and vclib.svn.last_rev() to use request.repos.* instead. (Request.run_viewvc): For CVS, invoke only vclib.ccvs.CVSRepository(), but pass the use_rcsparse setting to it. For Subversion, invoke only vclib.svn.SubversionRepository(). * lib/vclib/ccvs/ccvs.py Renamed from lib/vclib/ccvs/__init__.py, and tweaked to look for stuff common to the bincvs implementation in the sibling 'bincvs' module. * lib/vclib/ccvs/__init__.py New, a replacement by a new stub file with a factory function that selects which CVS implementation to use. * lib/vclib/ccvs/bincvs.py Moved from lib/vclib/bincvs/__init__.py. * lib/vclib/bincvs Removed (it's now empty). * lib/vclib/svn/svn_repos.py Renamed from lib/vclib/svn/__init__.py. (LocalSubversionRepository.created_rev, LocalSubversionRepository.get_location, LocalSubversionRepository.get_youngest_revision, LocalSubversionRepository.last_rev): Moved into the class from outside. * lib/vclib/svn/svn_ra.py Moved from lib/vclib/svn_ra/__init__.py. (RemoteSubversionRepository.created_rev, RemoteSubversionRepository.get_location, RemoteSubversionRepository.get_youngest_revision, RemoteSubversionRepository.last_rev): Moved into the class from outside. * lib/vclib/svn/__init__.py New, replacing previous incarnation with a file that contains only a single factory function. * lib/vclib/svn_ra/ Removed (it's now empty). * bin/loginfo-handler (ProcessLoginfo): Now use vclib.ccvs.CVSRepository(), disabling use_rcsparse. * bin/cvsdbadmin (__main__): Now use vclib.ccvs.CVSRepository(), disabling use_rcsparse. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1739 8cb11bc2-c004-0410-86c3-e597b4017df7
2007-12-03 18:25:51 +03:00
class BaseCVSRepository(vclib.Repository):
def __init__(self, name, rootpath, authorizer, utilities):
if not os.path.isdir(rootpath):
raise vclib.ReposNotFound(name)
self.name = name
self.rootpath = rootpath
self.auth = authorizer
Cleanup ViewVC's configuration and use of external utilities by creating a new section of the configuration file strictly for defining the locations of these helper applications. This closes issue #229 (configurable path to sed) and issue #62 (configurable path to diff), and perhaps others I failed to find. * viewvc.conf.dist Add a new "utilities" section for corraling all the various tool-location configurations, and relocate (with some tweaks) a bunch of options: general.rcs_path => utilities.rcs_dir general.cvsnt_ext_path = utilities.cvsnt general.svn_path => utilities.svn options.enscript_path => utilities.enscript options.highlight_path => utilities.highlight options.py2html_path => utilities.py2html_dir options.php_exe => utilities.php options.cvsgraph_path => utilities.cvsgraph utilities.diff (new) utilities.gzip (new) utilities.sed (new) options.use_py2html (new) * lib/config.py (_sections): Add 'utilities' section. (Config.set_defaults): Reflect options tweaks made to viewvc.conf.dist in the code here. * lib/viewvc.py (Request.run_viewvc): Track renamed utilities.svn option. Now pass cfg.utilities into BinCVSRepository(), CCVSRepository(), and SubversionRepository(). Collapse now-identical SubversionRepository() calls. (markup_stream_python): Return immediately if options.use_py2html isn't set. Track renamed utilities.py2html_dir option. (view_cvsgraph_image, view_cvsgraph): Track renamed utilities.cvsgraph option. (MarkupPHP.__init__): Track renamed utilities.php option, and allow for 'php' as a fallback value. (MarkupHighlight.__init__): Track renamed utilities.highlight option. (MarkupEnscript.__init__): Track renamed utilities.enscript option, and honor new utilities.sed option. (download_tarball): Use new utilities.gzip option. * lib/vclib/__init__.py (_diff_fp.__init__): Add 'diff_cmd' parameter. * lib/vclib/svn/__init__.py (SubversionRepository.__init__): Drop 'svn_path' parameter, and now accept 'utilities'. (SubversionRepository.rawdiff): Pass self.diff_cmd to _diff_fp(). * lib/vclib/svn_ra/__init__.py (SubversionRepository.rawdiff): Pass self.diff_cmd to _diff_fp(). * lib/vclib/ccvs/__init__.py (CCVSRepository.rawdiff): Pass self.utilities.diff or 'diff' to _diff_fp(). * lib/vclib/bincvs/__init__.py (CVSRepository.__init__): Add 'utilities' parameter. (BinCVSRepository.__init__): Lose as no-longer-necessary. (BinCVSRepository.rcs_popen): Track renamed options, and renamed member variable that hold those options. * docs/upgrading-howto.html Note these options changes. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1407 8cb11bc2-c004-0410-86c3-e597b4017df7
2006-07-28 15:04:12 +04:00
self.utilities = utilities
# See if this repository is even viewable, authz-wise.
if not vclib.check_root_access(self):
raise vclib.ReposNotFound(name)
def open(self):
# See if a universal read access determination can be made.
if self.auth and self.auth.check_universal_access(self.name) == 1:
self.auth = None
def rootname(self):
return self.name
def rootpath(self):
return self.rootpath
def roottype(self):
return vclib.CVS
def authorizer(self):
return self.auth
Change vclib interface to accept 'rev' parameters wherever it accepts path parameters so it is possible to use a single Repository object to request information about any path at any revision. Note: I wasn't able to test the svn_ra.get_location function because I only have subversion 1.2.3. * lib/vclib/__init__.py (Repository.itemtype, Repository.openfile, Repository.listdir, Repository.dirlogs, Repository.itemlog, Repository.annotate): add rev arguments, update docstrings * lib/vclib/bincvs/__init__.py (CVSRepository.itemtype, CVSRepository.listdir, BinCVSRepository.openfile, BinCVSRepository.dirlogs, BinCVSRepository.itemlog): same * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs, CCVSRepository.itemlog): same * lib/vclib/svn/__init__.py (SubversionRepository.__init__): remove rev argument (get_location, created_rev, _get_history, get_revision_info, _fetch_log, _get_last_history_rev, get_logs, do_diff, SubversionRepository.itemtype, SubversionRepository.openfile, SubversionRepository.listdir, SubversionRepository.dirlogs, SubversionRepository.itemlog, SubversionRepository.annotate): add rev arguments, use new _getrev and _getroot functions to handle all revision string parsing and revision_root creation (SubversionRepository._getrev, SubversionRepository._getroot): new functions * lib/vclib/svn_ra/__init__.py (_rev2optrev): accept integers instead of strings, and eliminate head/unspecified revision handling which is already taken care of by _getrev (SubversionRepository.__init__): remove rev argument (get_location, created_rev, get_revision_info, get_logs, SubversionRepository.itemtype, SubversionRepository.openfile, SubversionRepository.listdir, SubversionRepository.dirlogs, SubversionRepository.itemlog, SubversionRepository.annotate, SubversionRepository.rawdiff, SubversionRepository._get_dirents): add rev arguments, use new _getrev function to handle all revision string parsing (SubversionRepository._getrev): new function * lib/blame.py (link_includes): update call to repos.itemtype * tools/cvsdbadmin (RecurseUpdate): update call to repos.listdir * lib/viewcvs.py (Request.run_viewcvs): update calls to SubversionRepository constructors and _strip_suffix (_strip_suffix): add rev parameter, remove redundant where parameter (_repos_pathtype, view_markup, search_files, _get_diff_path_parts, generate_tarball): update calls to vclib methods (nav_path, view_directory, view_log, setup_diff, download_tarball, view_revision): explicitly read 'rev' query param instead of relying on SubversionRepository.rev, and update vclib calls git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1144 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-03 16:23:42 +03:00
def itemtype(self, path_parts, rev):
basepath = self._getpath(path_parts)
kind = None
if os.path.isdir(basepath):
kind = vclib.DIR
elif os.path.isfile(basepath + ',v'):
kind = vclib.FILE
else:
atticpath = self._getpath(self._atticpath(path_parts))
if os.path.isfile(atticpath + ',v'):
kind = vclib.FILE
if not kind:
raise vclib.ItemNotFound(path_parts)
if not vclib.check_path_access(self, path_parts, kind, rev):
raise vclib.ItemNotFound(path_parts)
return kind
def itemprops(self, path_parts, rev):
self.itemtype(path_parts, rev) # does auth-check
return {} # CVS doesn't support properties
Change vclib interface to accept 'rev' parameters wherever it accepts path parameters so it is possible to use a single Repository object to request information about any path at any revision. Note: I wasn't able to test the svn_ra.get_location function because I only have subversion 1.2.3. * lib/vclib/__init__.py (Repository.itemtype, Repository.openfile, Repository.listdir, Repository.dirlogs, Repository.itemlog, Repository.annotate): add rev arguments, update docstrings * lib/vclib/bincvs/__init__.py (CVSRepository.itemtype, CVSRepository.listdir, BinCVSRepository.openfile, BinCVSRepository.dirlogs, BinCVSRepository.itemlog): same * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs, CCVSRepository.itemlog): same * lib/vclib/svn/__init__.py (SubversionRepository.__init__): remove rev argument (get_location, created_rev, _get_history, get_revision_info, _fetch_log, _get_last_history_rev, get_logs, do_diff, SubversionRepository.itemtype, SubversionRepository.openfile, SubversionRepository.listdir, SubversionRepository.dirlogs, SubversionRepository.itemlog, SubversionRepository.annotate): add rev arguments, use new _getrev and _getroot functions to handle all revision string parsing and revision_root creation (SubversionRepository._getrev, SubversionRepository._getroot): new functions * lib/vclib/svn_ra/__init__.py (_rev2optrev): accept integers instead of strings, and eliminate head/unspecified revision handling which is already taken care of by _getrev (SubversionRepository.__init__): remove rev argument (get_location, created_rev, get_revision_info, get_logs, SubversionRepository.itemtype, SubversionRepository.openfile, SubversionRepository.listdir, SubversionRepository.dirlogs, SubversionRepository.itemlog, SubversionRepository.annotate, SubversionRepository.rawdiff, SubversionRepository._get_dirents): add rev arguments, use new _getrev function to handle all revision string parsing (SubversionRepository._getrev): new function * lib/blame.py (link_includes): update call to repos.itemtype * tools/cvsdbadmin (RecurseUpdate): update call to repos.listdir * lib/viewcvs.py (Request.run_viewcvs): update calls to SubversionRepository constructors and _strip_suffix (_strip_suffix): add rev parameter, remove redundant where parameter (_repos_pathtype, view_markup, search_files, _get_diff_path_parts, generate_tarball): update calls to vclib methods (nav_path, view_directory, view_log, setup_diff, download_tarball, view_revision): explicitly read 'rev' query param instead of relying on SubversionRepository.rev, and update vclib calls git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1144 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-03 16:23:42 +03:00
def listdir(self, path_parts, rev, options):
if self.itemtype(path_parts, rev) != vclib.DIR: # does auth-check
raise vclib.Error("Path '%s' is not a directory."
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
% (_path_join(path_parts)))
# Only RCS files (*,v) and subdirs are returned.
data = [ ]
full_name = self._getpath(path_parts)
for file in os.listdir(full_name):
name = None
kind, errors = _check_path(os.path.join(full_name, file))
if kind == vclib.FILE:
if file[-2:] == ',v':
name = file[:-2]
elif kind == vclib.DIR:
if file != 'Attic' and file != 'CVS': # CVS directory is for fileattr
name = file
else:
name = file
if not name:
continue
if vclib.check_path_access(self, path_parts + [name], kind, rev):
data.append(CVSDirEntry(name, kind, errors, 0))
Handle CVS Attic paths transparently in the bincvs module instead of exposing them to users. * templates/include/dir_footer.ezt add link to show dead files * templates/directory.ezt remove code for detecting Attic entries, change (in the attic) caption to (dead) * lib/viewcvs.py (Request.run_viewcvs): handle old Attic URL's by redirecting, remove unused request.full_name member (get_up_path, _re_up_attic_path, nav_header_data, generate_tarball, download_tarball): remove code for handling Attic directories (view_markup): remove unused "full_name" variable (view_directory): remove code for handling Attic directories, replace "no_match" template variable with "num_dead" (view_log): update call to get_up_path (view_annotate, view_cvsgraph_image, view_cvsgraph, view_diff): use CVSRepository.rcsfile to get path to rcs file * lib/vclib/bincvs/__init__.py (CVSRepository.itemtype): look in Attic for repository files (CVSRepository.listdir): remove "cvs_list_attic" option, now always list attic files. leave "Attic" and "CVS" directories out of returned listing. (CVSRepository.rcsfile, CVSRepository._atticpath): new methods (BinCVSRepository.openfile, BinCVSRepository.filelog): use CVSRepository.rcsfile to get path to rcs file (_get_logs): don't mark directories as dead * lib/vclib/ccvs/__init__.py (CCVSRepository.filelog, CCVSRepository.openfile): use CVSRepository.rcsfile to get path to rcs file * website/upgrading.html document "no_match" and "num_dead" template variables git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@908 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-08-01 02:34:51 +04:00
full_name = os.path.join(full_name, 'Attic')
if os.path.isdir(full_name):
for file in os.listdir(full_name):
name = None
kind, errors = _check_path(os.path.join(full_name, file))
if kind == vclib.FILE:
if file[-2:] == ',v':
name = file[:-2]
elif kind != vclib.DIR:
name = file
if not name:
continue
if vclib.check_path_access(self, path_parts + [name], kind, rev):
data.append(CVSDirEntry(name, kind, errors, 1))
return data
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
def _getpath(self, path_parts):
return apply(os.path.join, (self.rootpath,) + tuple(path_parts))
Handle CVS Attic paths transparently in the bincvs module instead of exposing them to users. * templates/include/dir_footer.ezt add link to show dead files * templates/directory.ezt remove code for detecting Attic entries, change (in the attic) caption to (dead) * lib/viewcvs.py (Request.run_viewcvs): handle old Attic URL's by redirecting, remove unused request.full_name member (get_up_path, _re_up_attic_path, nav_header_data, generate_tarball, download_tarball): remove code for handling Attic directories (view_markup): remove unused "full_name" variable (view_directory): remove code for handling Attic directories, replace "no_match" template variable with "num_dead" (view_log): update call to get_up_path (view_annotate, view_cvsgraph_image, view_cvsgraph, view_diff): use CVSRepository.rcsfile to get path to rcs file * lib/vclib/bincvs/__init__.py (CVSRepository.itemtype): look in Attic for repository files (CVSRepository.listdir): remove "cvs_list_attic" option, now always list attic files. leave "Attic" and "CVS" directories out of returned listing. (CVSRepository.rcsfile, CVSRepository._atticpath): new methods (BinCVSRepository.openfile, BinCVSRepository.filelog): use CVSRepository.rcsfile to get path to rcs file (_get_logs): don't mark directories as dead * lib/vclib/ccvs/__init__.py (CCVSRepository.filelog, CCVSRepository.openfile): use CVSRepository.rcsfile to get path to rcs file * website/upgrading.html document "no_match" and "num_dead" template variables git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@908 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-08-01 02:34:51 +04:00
def _atticpath(self, path_parts):
return path_parts[:-1] + ['Attic'] + path_parts[-1:]
def rcsfile(self, path_parts, root=0, v=1):
"Return path to RCS file"
ret_parts = path_parts
ret_file = self._getpath(ret_parts)
if not os.path.isfile(ret_file + ',v'):
ret_parts = self._atticpath(path_parts)
ret_file = self._getpath(ret_parts)
if not os.path.isfile(ret_file + ',v'):
raise vclib.ItemNotFound(path_parts)
if root:
ret = ret_file
else:
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
ret = _path_join(ret_parts)
Handle CVS Attic paths transparently in the bincvs module instead of exposing them to users. * templates/include/dir_footer.ezt add link to show dead files * templates/directory.ezt remove code for detecting Attic entries, change (in the attic) caption to (dead) * lib/viewcvs.py (Request.run_viewcvs): handle old Attic URL's by redirecting, remove unused request.full_name member (get_up_path, _re_up_attic_path, nav_header_data, generate_tarball, download_tarball): remove code for handling Attic directories (view_markup): remove unused "full_name" variable (view_directory): remove code for handling Attic directories, replace "no_match" template variable with "num_dead" (view_log): update call to get_up_path (view_annotate, view_cvsgraph_image, view_cvsgraph, view_diff): use CVSRepository.rcsfile to get path to rcs file * lib/vclib/bincvs/__init__.py (CVSRepository.itemtype): look in Attic for repository files (CVSRepository.listdir): remove "cvs_list_attic" option, now always list attic files. leave "Attic" and "CVS" directories out of returned listing. (CVSRepository.rcsfile, CVSRepository._atticpath): new methods (BinCVSRepository.openfile, BinCVSRepository.filelog): use CVSRepository.rcsfile to get path to rcs file (_get_logs): don't mark directories as dead * lib/vclib/ccvs/__init__.py (CCVSRepository.filelog, CCVSRepository.openfile): use CVSRepository.rcsfile to get path to rcs file * website/upgrading.html document "no_match" and "num_dead" template variables git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@908 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-08-01 02:34:51 +04:00
if v:
ret = ret + ",v"
return ret
def isexecutable(self, path_parts, rev):
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
rcsfile = self.rcsfile(path_parts, 1)
return os.access(rcsfile, os.X_OK)
Merge changes (r1735:1738) from the (misnamed) options-overhaul branch. This reduces the number of vclib plugins to two -- one for each of CVS and Subversion. * lib/viewvc.py (): Update callers of vclib.svn.created_rev(), vclib.svn.get_location(), vclib.svn.get_youngest_revision(), and vclib.svn.last_rev() to use request.repos.* instead. (Request.run_viewvc): For CVS, invoke only vclib.ccvs.CVSRepository(), but pass the use_rcsparse setting to it. For Subversion, invoke only vclib.svn.SubversionRepository(). * lib/vclib/ccvs/ccvs.py Renamed from lib/vclib/ccvs/__init__.py, and tweaked to look for stuff common to the bincvs implementation in the sibling 'bincvs' module. * lib/vclib/ccvs/__init__.py New, a replacement by a new stub file with a factory function that selects which CVS implementation to use. * lib/vclib/ccvs/bincvs.py Moved from lib/vclib/bincvs/__init__.py. * lib/vclib/bincvs Removed (it's now empty). * lib/vclib/svn/svn_repos.py Renamed from lib/vclib/svn/__init__.py. (LocalSubversionRepository.created_rev, LocalSubversionRepository.get_location, LocalSubversionRepository.get_youngest_revision, LocalSubversionRepository.last_rev): Moved into the class from outside. * lib/vclib/svn/svn_ra.py Moved from lib/vclib/svn_ra/__init__.py. (RemoteSubversionRepository.created_rev, RemoteSubversionRepository.get_location, RemoteSubversionRepository.get_youngest_revision, RemoteSubversionRepository.last_rev): Moved into the class from outside. * lib/vclib/svn/__init__.py New, replacing previous incarnation with a file that contains only a single factory function. * lib/vclib/svn_ra/ Removed (it's now empty). * bin/loginfo-handler (ProcessLoginfo): Now use vclib.ccvs.CVSRepository(), disabling use_rcsparse. * bin/cvsdbadmin (__main__): Now use vclib.ccvs.CVSRepository(), disabling use_rcsparse. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1739 8cb11bc2-c004-0410-86c3-e597b4017df7
2007-12-03 18:25:51 +03:00
class BinCVSRepository(BaseCVSRepository):
def _get_tip_revision(self, rcs_file, rev=None):
"""Get the (basically) youngest revision (filtered by REV)."""
args = rcs_file,
fp = self.rcs_popen('rlog', args, 'rt', 0)
filename, default_branch, tags, lockinfo, msg, eof = _parse_log_header(fp)
revs = []
while not eof:
revision, eof = _parse_log_entry(fp)
if revision:
revs.append(revision)
revs = _file_log(revs, tags, lockinfo, default_branch, rev)
if revs:
return revs[-1]
return None
def openfile(self, path_parts, rev, options):
"""see vclib.Repository.openfile docstring
Option values recognized by this implementation:
cvs_oldkeywords
boolean. true to use the original keyword substitution values.
"""
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
if not rev or rev == 'HEAD' or rev == 'MAIN':
rev_flag = '-p'
else:
rev_flag = '-p' + rev
if options.get('cvs_oldkeywords', 0):
kv_flag = '-ko'
else:
kv_flag = '-kkv'
Handle CVS Attic paths transparently in the bincvs module instead of exposing them to users. * templates/include/dir_footer.ezt add link to show dead files * templates/directory.ezt remove code for detecting Attic entries, change (in the attic) caption to (dead) * lib/viewcvs.py (Request.run_viewcvs): handle old Attic URL's by redirecting, remove unused request.full_name member (get_up_path, _re_up_attic_path, nav_header_data, generate_tarball, download_tarball): remove code for handling Attic directories (view_markup): remove unused "full_name" variable (view_directory): remove code for handling Attic directories, replace "no_match" template variable with "num_dead" (view_log): update call to get_up_path (view_annotate, view_cvsgraph_image, view_cvsgraph, view_diff): use CVSRepository.rcsfile to get path to rcs file * lib/vclib/bincvs/__init__.py (CVSRepository.itemtype): look in Attic for repository files (CVSRepository.listdir): remove "cvs_list_attic" option, now always list attic files. leave "Attic" and "CVS" directories out of returned listing. (CVSRepository.rcsfile, CVSRepository._atticpath): new methods (BinCVSRepository.openfile, BinCVSRepository.filelog): use CVSRepository.rcsfile to get path to rcs file (_get_logs): don't mark directories as dead * lib/vclib/ccvs/__init__.py (CCVSRepository.filelog, CCVSRepository.openfile): use CVSRepository.rcsfile to get path to rcs file * website/upgrading.html document "no_match" and "num_dead" template variables git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@908 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-08-01 02:34:51 +04:00
full_name = self.rcsfile(path_parts, root=1, v=0)
used_rlog = 0
tip_rev = None # used only if we have to fallback to using rlog
fp = self.rcs_popen('co', (kv_flag, rev_flag, full_name), 'rb')
try:
filename, revision = _parse_co_header(fp)
except COMissingRevision:
# We got a "revision X.Y.Z absent" error from co. This could be
# because we were asked to find a tip of a branch, which co
# doesn't seem to handle. So we do rlog-gy stuff to figure out
# which revision the tip of the branch currently maps to.
### TODO: Only do this when 'rev' is a branch symbol name?
if not used_rlog:
tip_rev = self._get_tip_revision(full_name + ',v', rev)
used_rlog = 1
if not tip_rev:
raise vclib.Error("Unable to find valid revision")
fp = self.rcs_popen('co', ('-p' + tip_rev.string, full_name), 'rb')
filename, revision = _parse_co_header(fp)
if filename is None:
# CVSNT's co exits without any output if a dead revision is requested.
# Bug at http://www.cvsnt.org/cgi-bin/bugzilla/show_bug.cgi?id=190
# As a workaround, we invoke rlog to find the first non-dead revision
# that precedes it and check out that revision instead. Of course,
# if we've already invoked rlog above, we just reuse its output.
if not used_rlog:
tip_rev = self._get_tip_revision(full_name + ',v', rev)
used_rlog = 1
if not (tip_rev and tip_rev.undead):
raise vclib.Error(
'Could not find non-dead revision preceding "%s"' % rev)
fp = self.rcs_popen('co', ('-p' + tip_rev.undead.string,
full_name), 'rb')
filename, revision = _parse_co_header(fp)
if filename is None:
raise vclib.Error('Missing output from co (filename = "%s")' % full_name)
if not _paths_eq(filename, full_name):
raise vclib.Error(
'The filename from co ("%s") did not match (expected "%s")'
% (filename, full_name))
return fp, revision
Change vclib interface to accept 'rev' parameters wherever it accepts path parameters so it is possible to use a single Repository object to request information about any path at any revision. Note: I wasn't able to test the svn_ra.get_location function because I only have subversion 1.2.3. * lib/vclib/__init__.py (Repository.itemtype, Repository.openfile, Repository.listdir, Repository.dirlogs, Repository.itemlog, Repository.annotate): add rev arguments, update docstrings * lib/vclib/bincvs/__init__.py (CVSRepository.itemtype, CVSRepository.listdir, BinCVSRepository.openfile, BinCVSRepository.dirlogs, BinCVSRepository.itemlog): same * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs, CCVSRepository.itemlog): same * lib/vclib/svn/__init__.py (SubversionRepository.__init__): remove rev argument (get_location, created_rev, _get_history, get_revision_info, _fetch_log, _get_last_history_rev, get_logs, do_diff, SubversionRepository.itemtype, SubversionRepository.openfile, SubversionRepository.listdir, SubversionRepository.dirlogs, SubversionRepository.itemlog, SubversionRepository.annotate): add rev arguments, use new _getrev and _getroot functions to handle all revision string parsing and revision_root creation (SubversionRepository._getrev, SubversionRepository._getroot): new functions * lib/vclib/svn_ra/__init__.py (_rev2optrev): accept integers instead of strings, and eliminate head/unspecified revision handling which is already taken care of by _getrev (SubversionRepository.__init__): remove rev argument (get_location, created_rev, get_revision_info, get_logs, SubversionRepository.itemtype, SubversionRepository.openfile, SubversionRepository.listdir, SubversionRepository.dirlogs, SubversionRepository.itemlog, SubversionRepository.annotate, SubversionRepository.rawdiff, SubversionRepository._get_dirents): add rev arguments, use new _getrev function to handle all revision string parsing (SubversionRepository._getrev): new function * lib/blame.py (link_includes): update call to repos.itemtype * tools/cvsdbadmin (RecurseUpdate): update call to repos.listdir * lib/viewcvs.py (Request.run_viewcvs): update calls to SubversionRepository constructors and _strip_suffix (_strip_suffix): add rev parameter, remove redundant where parameter (_repos_pathtype, view_markup, search_files, _get_diff_path_parts, generate_tarball): update calls to vclib methods (nav_path, view_directory, view_log, setup_diff, download_tarball, view_revision): explicitly read 'rev' query param instead of relying on SubversionRepository.rev, and update vclib calls git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1144 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-03 16:23:42 +03:00
def dirlogs(self, path_parts, rev, entries, options):
"""see vclib.Repository.dirlogs docstring
Change vclib interface to accept 'rev' parameters wherever it accepts path parameters so it is possible to use a single Repository object to request information about any path at any revision. Note: I wasn't able to test the svn_ra.get_location function because I only have subversion 1.2.3. * lib/vclib/__init__.py (Repository.itemtype, Repository.openfile, Repository.listdir, Repository.dirlogs, Repository.itemlog, Repository.annotate): add rev arguments, update docstrings * lib/vclib/bincvs/__init__.py (CVSRepository.itemtype, CVSRepository.listdir, BinCVSRepository.openfile, BinCVSRepository.dirlogs, BinCVSRepository.itemlog): same * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs, CCVSRepository.itemlog): same * lib/vclib/svn/__init__.py (SubversionRepository.__init__): remove rev argument (get_location, created_rev, _get_history, get_revision_info, _fetch_log, _get_last_history_rev, get_logs, do_diff, SubversionRepository.itemtype, SubversionRepository.openfile, SubversionRepository.listdir, SubversionRepository.dirlogs, SubversionRepository.itemlog, SubversionRepository.annotate): add rev arguments, use new _getrev and _getroot functions to handle all revision string parsing and revision_root creation (SubversionRepository._getrev, SubversionRepository._getroot): new functions * lib/vclib/svn_ra/__init__.py (_rev2optrev): accept integers instead of strings, and eliminate head/unspecified revision handling which is already taken care of by _getrev (SubversionRepository.__init__): remove rev argument (get_location, created_rev, get_revision_info, get_logs, SubversionRepository.itemtype, SubversionRepository.openfile, SubversionRepository.listdir, SubversionRepository.dirlogs, SubversionRepository.itemlog, SubversionRepository.annotate, SubversionRepository.rawdiff, SubversionRepository._get_dirents): add rev arguments, use new _getrev function to handle all revision string parsing (SubversionRepository._getrev): new function * lib/blame.py (link_includes): update call to repos.itemtype * tools/cvsdbadmin (RecurseUpdate): update call to repos.listdir * lib/viewcvs.py (Request.run_viewcvs): update calls to SubversionRepository constructors and _strip_suffix (_strip_suffix): add rev parameter, remove redundant where parameter (_repos_pathtype, view_markup, search_files, _get_diff_path_parts, generate_tarball): update calls to vclib methods (nav_path, view_directory, view_log, setup_diff, download_tarball, view_revision): explicitly read 'rev' query param instead of relying on SubversionRepository.rev, and update vclib calls git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1144 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-03 16:23:42 +03:00
rev can be a tag name or None. if set only information from revisions
matching the tag will be retrieved
Option values recognized by this implementation:
cvs_subdirs
boolean. true to fetch logs of the most recently modified file in each
subdirectory
Option values returned by this implementation:
cvs_tags, cvs_branches
lists of tag and branch names encountered in the directory
"""
if self.itemtype(path_parts, rev) != vclib.DIR: # does auth-check
raise vclib.Error("Path '%s' is not a directory."
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
% (_path_join(path_parts)))
subdirs = options.get('cvs_subdirs', 0)
entries_to_fetch = []
for entry in entries:
if vclib.check_path_access(self, path_parts + [entry.name], None, rev):
entries_to_fetch.append(entry)
alltags = _get_logs(self, path_parts, entries_to_fetch, rev, subdirs)
branches = options['cvs_branches'] = []
tags = options['cvs_tags'] = []
for name, rev in alltags.items():
if Tag(None, rev).is_branch:
branches.append(name)
else:
tags.append(name)
def itemlog(self, path_parts, rev, sortby, first, limit, options):
"""see vclib.Repository.itemlog docstring
Change vclib interface to accept 'rev' parameters wherever it accepts path parameters so it is possible to use a single Repository object to request information about any path at any revision. Note: I wasn't able to test the svn_ra.get_location function because I only have subversion 1.2.3. * lib/vclib/__init__.py (Repository.itemtype, Repository.openfile, Repository.listdir, Repository.dirlogs, Repository.itemlog, Repository.annotate): add rev arguments, update docstrings * lib/vclib/bincvs/__init__.py (CVSRepository.itemtype, CVSRepository.listdir, BinCVSRepository.openfile, BinCVSRepository.dirlogs, BinCVSRepository.itemlog): same * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs, CCVSRepository.itemlog): same * lib/vclib/svn/__init__.py (SubversionRepository.__init__): remove rev argument (get_location, created_rev, _get_history, get_revision_info, _fetch_log, _get_last_history_rev, get_logs, do_diff, SubversionRepository.itemtype, SubversionRepository.openfile, SubversionRepository.listdir, SubversionRepository.dirlogs, SubversionRepository.itemlog, SubversionRepository.annotate): add rev arguments, use new _getrev and _getroot functions to handle all revision string parsing and revision_root creation (SubversionRepository._getrev, SubversionRepository._getroot): new functions * lib/vclib/svn_ra/__init__.py (_rev2optrev): accept integers instead of strings, and eliminate head/unspecified revision handling which is already taken care of by _getrev (SubversionRepository.__init__): remove rev argument (get_location, created_rev, get_revision_info, get_logs, SubversionRepository.itemtype, SubversionRepository.openfile, SubversionRepository.listdir, SubversionRepository.dirlogs, SubversionRepository.itemlog, SubversionRepository.annotate, SubversionRepository.rawdiff, SubversionRepository._get_dirents): add rev arguments, use new _getrev function to handle all revision string parsing (SubversionRepository._getrev): new function * lib/blame.py (link_includes): update call to repos.itemtype * tools/cvsdbadmin (RecurseUpdate): update call to repos.listdir * lib/viewcvs.py (Request.run_viewcvs): update calls to SubversionRepository constructors and _strip_suffix (_strip_suffix): add rev parameter, remove redundant where parameter (_repos_pathtype, view_markup, search_files, _get_diff_path_parts, generate_tarball): update calls to vclib methods (nav_path, view_directory, view_log, setup_diff, download_tarball, view_revision): explicitly read 'rev' query param instead of relying on SubversionRepository.rev, and update vclib calls git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1144 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-03 16:23:42 +03:00
rev parameter can be a revision number, a branch number, a tag name,
or None. If None, will return information about all revisions, otherwise,
will only return information about the specified revision or branch.
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
Option values recognized by this implementation:
cvs_pass_rev
boolean, default false. set to true to pass rev parameter as -r
argument to rlog, this is more efficient but causes less
information to be returned
Option values returned by this implementation:
cvs_tags
dictionary of Tag objects for all tags encountered
"""
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
# Invoke rlog
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
rcsfile = self.rcsfile(path_parts, 1)
if rev and options.get('cvs_pass_rev', 0):
args = '-r' + rev, rcsfile
else:
args = rcsfile,
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
fp = self.rcs_popen('rlog', args, 'rt', 0)
filename, default_branch, tags, lockinfo, msg, eof = _parse_log_header(fp)
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
# Retrieve revision objects
revs = []
while not eof:
revision, eof = _parse_log_entry(fp)
if revision:
revs.append(revision)
filtered_revs = _file_log(revs, tags, lockinfo, default_branch, rev)
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
options['cvs_tags'] = tags
if sortby == vclib.SORTBY_DATE:
filtered_revs.sort(_logsort_date_cmp)
elif sortby == vclib.SORTBY_REV:
filtered_revs.sort(_logsort_rev_cmp)
if len(filtered_revs) < first:
return []
if limit:
return filtered_revs[first:first+limit]
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
return filtered_revs
def rcs_popen(self, rcs_cmd, rcs_args, mode, capture_err=1):
Cleanup ViewVC's configuration and use of external utilities by creating a new section of the configuration file strictly for defining the locations of these helper applications. This closes issue #229 (configurable path to sed) and issue #62 (configurable path to diff), and perhaps others I failed to find. * viewvc.conf.dist Add a new "utilities" section for corraling all the various tool-location configurations, and relocate (with some tweaks) a bunch of options: general.rcs_path => utilities.rcs_dir general.cvsnt_ext_path = utilities.cvsnt general.svn_path => utilities.svn options.enscript_path => utilities.enscript options.highlight_path => utilities.highlight options.py2html_path => utilities.py2html_dir options.php_exe => utilities.php options.cvsgraph_path => utilities.cvsgraph utilities.diff (new) utilities.gzip (new) utilities.sed (new) options.use_py2html (new) * lib/config.py (_sections): Add 'utilities' section. (Config.set_defaults): Reflect options tweaks made to viewvc.conf.dist in the code here. * lib/viewvc.py (Request.run_viewvc): Track renamed utilities.svn option. Now pass cfg.utilities into BinCVSRepository(), CCVSRepository(), and SubversionRepository(). Collapse now-identical SubversionRepository() calls. (markup_stream_python): Return immediately if options.use_py2html isn't set. Track renamed utilities.py2html_dir option. (view_cvsgraph_image, view_cvsgraph): Track renamed utilities.cvsgraph option. (MarkupPHP.__init__): Track renamed utilities.php option, and allow for 'php' as a fallback value. (MarkupHighlight.__init__): Track renamed utilities.highlight option. (MarkupEnscript.__init__): Track renamed utilities.enscript option, and honor new utilities.sed option. (download_tarball): Use new utilities.gzip option. * lib/vclib/__init__.py (_diff_fp.__init__): Add 'diff_cmd' parameter. * lib/vclib/svn/__init__.py (SubversionRepository.__init__): Drop 'svn_path' parameter, and now accept 'utilities'. (SubversionRepository.rawdiff): Pass self.diff_cmd to _diff_fp(). * lib/vclib/svn_ra/__init__.py (SubversionRepository.rawdiff): Pass self.diff_cmd to _diff_fp(). * lib/vclib/ccvs/__init__.py (CCVSRepository.rawdiff): Pass self.utilities.diff or 'diff' to _diff_fp(). * lib/vclib/bincvs/__init__.py (CVSRepository.__init__): Add 'utilities' parameter. (BinCVSRepository.__init__): Lose as no-longer-necessary. (BinCVSRepository.rcs_popen): Track renamed options, and renamed member variable that hold those options. * docs/upgrading-howto.html Note these options changes. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1407 8cb11bc2-c004-0410-86c3-e597b4017df7
2006-07-28 15:04:12 +04:00
if self.utilities.cvsnt:
cmd = self.utilities.cvsnt
args = ['rcsfile', rcs_cmd]
args.extend(list(rcs_args))
else:
Cleanup ViewVC's configuration and use of external utilities by creating a new section of the configuration file strictly for defining the locations of these helper applications. This closes issue #229 (configurable path to sed) and issue #62 (configurable path to diff), and perhaps others I failed to find. * viewvc.conf.dist Add a new "utilities" section for corraling all the various tool-location configurations, and relocate (with some tweaks) a bunch of options: general.rcs_path => utilities.rcs_dir general.cvsnt_ext_path = utilities.cvsnt general.svn_path => utilities.svn options.enscript_path => utilities.enscript options.highlight_path => utilities.highlight options.py2html_path => utilities.py2html_dir options.php_exe => utilities.php options.cvsgraph_path => utilities.cvsgraph utilities.diff (new) utilities.gzip (new) utilities.sed (new) options.use_py2html (new) * lib/config.py (_sections): Add 'utilities' section. (Config.set_defaults): Reflect options tweaks made to viewvc.conf.dist in the code here. * lib/viewvc.py (Request.run_viewvc): Track renamed utilities.svn option. Now pass cfg.utilities into BinCVSRepository(), CCVSRepository(), and SubversionRepository(). Collapse now-identical SubversionRepository() calls. (markup_stream_python): Return immediately if options.use_py2html isn't set. Track renamed utilities.py2html_dir option. (view_cvsgraph_image, view_cvsgraph): Track renamed utilities.cvsgraph option. (MarkupPHP.__init__): Track renamed utilities.php option, and allow for 'php' as a fallback value. (MarkupHighlight.__init__): Track renamed utilities.highlight option. (MarkupEnscript.__init__): Track renamed utilities.enscript option, and honor new utilities.sed option. (download_tarball): Use new utilities.gzip option. * lib/vclib/__init__.py (_diff_fp.__init__): Add 'diff_cmd' parameter. * lib/vclib/svn/__init__.py (SubversionRepository.__init__): Drop 'svn_path' parameter, and now accept 'utilities'. (SubversionRepository.rawdiff): Pass self.diff_cmd to _diff_fp(). * lib/vclib/svn_ra/__init__.py (SubversionRepository.rawdiff): Pass self.diff_cmd to _diff_fp(). * lib/vclib/ccvs/__init__.py (CCVSRepository.rawdiff): Pass self.utilities.diff or 'diff' to _diff_fp(). * lib/vclib/bincvs/__init__.py (CVSRepository.__init__): Add 'utilities' parameter. (BinCVSRepository.__init__): Lose as no-longer-necessary. (BinCVSRepository.rcs_popen): Track renamed options, and renamed member variable that hold those options. * docs/upgrading-howto.html Note these options changes. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1407 8cb11bc2-c004-0410-86c3-e597b4017df7
2006-07-28 15:04:12 +04:00
cmd = os.path.join(self.utilities.rcs_dir, rcs_cmd)
args = rcs_args
return popen.popen(cmd, args, mode, capture_err)
def annotate(self, path_parts, rev=None, include_text=False):
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
from vclib.ccvs import blame
source = blame.BlameSource(self.rcsfile(path_parts, 1), rev, include_text)
return source, source.revision
def revinfo(self, rev):
raise vclib.UnsupportedFeature
def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
"""see vclib.Repository.rawdiff docstring
Option values recognized by this implementation:
ignore_keyword_subst - boolean, ignore keyword substitution
"""
if self.itemtype(path_parts1, rev1) != vclib.FILE: # does auth-check
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts1)))
if self.itemtype(path_parts2, rev2) != vclib.FILE: # does auth-check
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts2)))
args = vclib._diff_args(type, options)
if options.get('ignore_keyword_subst', 0):
args.append('-kk')
rcsfile = self.rcsfile(path_parts1, 1)
if path_parts1 != path_parts2:
raise NotImplementedError, "cannot diff across paths in cvs"
args.extend(['-r' + rev1, '-r' + rev2, rcsfile])
fp = self.rcs_popen('rcsdiff', args, 'rt')
# Eat up the non-GNU-diff-y headers.
while 1:
line = fp.readline()
if not line or line[0:5] == 'diff ':
break
return fp
class CVSDirEntry(vclib.DirEntry):
def __init__(self, name, kind, errors, in_attic, absent=0):
vclib.DirEntry.__init__(self, name, kind, errors)
self.in_attic = in_attic
self.absent = absent # meaning, no revisions found on requested tag
Tweak vclib DirEntry and Revision objects. - Revision class is now defined in vclib - DirEntry class has new log_error boolean member to replace use of bincvs._FILE_HAD_ERROR constant. - In CVS, DirEntry.state string member is replaced by boolean DirEntry.dead * lib/vclib/__init__.py (Repository.dirlogs): add documentation (Revision): new class * lib/vclib/bincvs/__init__.py (Revision): inherit from new vclib.Revision class (get_logs, _FILE_HAD_ERROR): stop using _FILE_HAD_ERROR constant (parse_log_entry, get_logs): use "dead" properties instead of "state" properties on Revision and DirEntry objects (_newest_file): bugfix, call _check_path() to make sure returned file is accessible * lib/rlog.py (GetRLogData): use Revision.dead member instead of Revision.state * lib/vclib/svn/__init__.py (Revision, LogEntry): rename LogEntry class to Revision and inherit from vclib.Revision (NodeHistory.add_history): trim beginning slashes from subversion paths passed to this callback (_log_helper): call new Revision constructor (fetch_log): simplify return values (get_logs): set DirEntry.log_error member (SubversionRepository.filelog): update for changed fetch_log function, remove some kludges * lib/viewcvs.py (Request.run_viewcvs, bincvs): import bincvs module as neccessary instead of importing globally (view_markup, sort_file_data, view_directory, view_log, generate_tarball): update to deal with changed DirEntry and Revision members git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@796 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:05:08 +03:00
class Revision(vclib.Revision):
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
def __init__(self, revstr, date=None, author=None, dead=None,
changed=None, log=None):
Tweak vclib DirEntry and Revision objects. - Revision class is now defined in vclib - DirEntry class has new log_error boolean member to replace use of bincvs._FILE_HAD_ERROR constant. - In CVS, DirEntry.state string member is replaced by boolean DirEntry.dead * lib/vclib/__init__.py (Repository.dirlogs): add documentation (Revision): new class * lib/vclib/bincvs/__init__.py (Revision): inherit from new vclib.Revision class (get_logs, _FILE_HAD_ERROR): stop using _FILE_HAD_ERROR constant (parse_log_entry, get_logs): use "dead" properties instead of "state" properties on Revision and DirEntry objects (_newest_file): bugfix, call _check_path() to make sure returned file is accessible * lib/rlog.py (GetRLogData): use Revision.dead member instead of Revision.state * lib/vclib/svn/__init__.py (Revision, LogEntry): rename LogEntry class to Revision and inherit from vclib.Revision (NodeHistory.add_history): trim beginning slashes from subversion paths passed to this callback (_log_helper): call new Revision constructor (fetch_log): simplify return values (get_logs): set DirEntry.log_error member (SubversionRepository.filelog): update for changed fetch_log function, remove some kludges * lib/viewcvs.py (Request.run_viewcvs, bincvs): import bincvs module as neccessary instead of importing globally (view_markup, sort_file_data, view_directory, view_log, generate_tarball): update to deal with changed DirEntry and Revision members git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@796 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:05:08 +03:00
vclib.Revision.__init__(self, _revision_tuple(revstr), revstr,
Finish issue #57 with more support for showing locked status. * lib/vclib/__init__.py (Repository.dirlogs): Update comment. (Revision.__init__): Add 'lockinfo' parameter, used to populate similarly named class member. * lib/vclib/svn/svn_repos.py (Revision.__init__): Add 'lockinfo' parameter, and update call to vclib.Revision(). (_log_helper): Update call to Revision(), and lose custom lockinfo handling. (LocalSubversionRepository.dirlogs): Populate entry lockinfo with a call to svn_fs_get_lock() for each entry. * lib/vclib/svn/svn_ra.py (LogCollector.__init__): Add 'lockinfo' parameter, used to populate similarly named class member. (LogCollector.add_log): Pass self.lockinfo to updated call to Revision(). (RemoteSubversionRepository.itemlog): Pass lock info to LogCollector(), and lose custom lockinfo handling. (RemoteSubversionRepository.itemtype, RemoteSubversionRepository.listdir): Update expected return value from _get_dirents(). (RemoteSubversionRepository.dirlogs): Populate entry lockinfo from updated return value from _get_dirents(). (RemoteSubversionRepository._get_dirents): Rework to trade in dirents and locks instead of only dirents. * lib/vclib/ccvs/bincvs.py (Revision.__init__): Update call to vclib.Revision(). (_get_logs): Add 'lockinfo' member to DirEntry() items. * lib/vclib/ccvs/ccvs.py (InfoSink.__init__): Init lockinfo dictionary. (InfoSink.set_locker): New. (InfoSink.define_revision): Set lockinfo on Revision item. (InfoSink.set_revision_info): Populate DirEntry lockinfo from Revision lockinfo data. * lib/viewvc.py (view_directory): Populate entry lockinfo. (common_template_data): Populate the 'lockinfo' data dictionary item. * templates/directory.ezt, * templates/dir_new.ezt * templates/annotate.ezt, * templates/markup.ezt Tweak to show lock status. * docs/template-authoring-guide.html Note new data dictionary items. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1787 8cb11bc2-c004-0410-86c3-e597b4017df7
2008-02-13 00:06:40 +03:00
date, author, changed, log, None, None)
Tweak vclib DirEntry and Revision objects. - Revision class is now defined in vclib - DirEntry class has new log_error boolean member to replace use of bincvs._FILE_HAD_ERROR constant. - In CVS, DirEntry.state string member is replaced by boolean DirEntry.dead * lib/vclib/__init__.py (Repository.dirlogs): add documentation (Revision): new class * lib/vclib/bincvs/__init__.py (Revision): inherit from new vclib.Revision class (get_logs, _FILE_HAD_ERROR): stop using _FILE_HAD_ERROR constant (parse_log_entry, get_logs): use "dead" properties instead of "state" properties on Revision and DirEntry objects (_newest_file): bugfix, call _check_path() to make sure returned file is accessible * lib/rlog.py (GetRLogData): use Revision.dead member instead of Revision.state * lib/vclib/svn/__init__.py (Revision, LogEntry): rename LogEntry class to Revision and inherit from vclib.Revision (NodeHistory.add_history): trim beginning slashes from subversion paths passed to this callback (_log_helper): call new Revision constructor (fetch_log): simplify return values (get_logs): set DirEntry.log_error member (SubversionRepository.filelog): update for changed fetch_log function, remove some kludges * lib/viewcvs.py (Request.run_viewcvs, bincvs): import bincvs module as neccessary instead of importing globally (view_markup, sort_file_data, view_directory, view_log, generate_tarball): update to deal with changed DirEntry and Revision members git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@796 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:05:08 +03:00
self.dead = dead
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
class Tag:
def __init__(self, name, revstr):
self.name = name
self.number = _tag_tuple(revstr)
self.is_branch = len(self.number) % 2 == 1 or not self.number
This commit contains three changes, which I couldn't split back apart very easily (sorry): 1) use LogEntry for the fileinfo stuff 2) use bincvs.Repository for some basic functionality 3) update bincvs.__init__.py to the API that was checked in last week * viewcvs.py (class Request): remember the split path parts. refine some of the error logic and messages. replace .cvsrep and .cvsroot with a Repository instance (and use .name and .rootpath instead). (_validate_cvsroot): refine the error message (clickable_path): use request.repos (view_directory, generate_tarball): use request.repos. use LogEntry for fileinfo. (file_sort_cmp): update for LogEntry (view_annotate, cvsgraph_image, viewcvs_graph, search_files, view_diff): use repos.rootpath rather than .cvsroot (main): tweak the ordering of some checks and dispatching. use the repos.itemtype() functionality to test for "is a directory". remove test for whether the CVS root exists -- it was done during the Request initialization. * vclib/bincvs/__init__.py (_FILE_HAD_ERROR): copied over from viewcvs.py (class LogError): new class (unused so far) to represent an error. (process_rlog_output): use LogEntry for fileinfo rather than a tuple (class BinCVSRepository): - change the init to verify the root is a directory, and store the name and rootpath (rootpath used to be called basepath). - add new .getitem() and .itemtype() methods for retrieving and querying about items, respectively. - tweak _getpath() joining of paths so we don't have to worry about adding a separator onto .rootpath. - remove .getfile() (now part of getitem). - replace .getsubdirs() with ._getvf_subdirs(). - replace .getfiles() with ._getvf_files(). git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@521 8cb11bc2-c004-0410-86c3-e597b4017df7
2002-06-03 22:35:06 +04:00
# ======================================================================
# Functions for dealing with Revision and Tag objects
def _logsort_date_cmp(rev1, rev2):
# sort on date; secondary on revision number
return -cmp(rev1.date, rev2.date) or -cmp(rev1.number, rev2.number)
def _logsort_rev_cmp(rev1, rev2):
# sort highest revision first
return -cmp(rev1.number, rev2.number)
def _match_revs_tags(revlist, taglist):
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"""Match up a list of Revision objects with a list of Tag objects
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
Sets the following properties on each Revision in revlist:
"tags"
list of non-branch tags which refer to this revision
example: if revision is 1.2.3.4, tags is a list of all 1.2.3.4 tags
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"branches"
list of branch tags which refer to this revision's branch
example: if revision is 1.2.3.4, branches is a list of all 1.2.3 tags
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"branch_points"
list of branch tags which branch off of this revision
example: if revision is 1.2, it's a list of tags like 1.2.3 and 1.2.4
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"prev"
reference to the previous revision, possibly None
example: if revision is 1.2.3.4, prev is 1.2.3.3
This commit contains three changes, which I couldn't split back apart very easily (sorry): 1) use LogEntry for the fileinfo stuff 2) use bincvs.Repository for some basic functionality 3) update bincvs.__init__.py to the API that was checked in last week * viewcvs.py (class Request): remember the split path parts. refine some of the error logic and messages. replace .cvsrep and .cvsroot with a Repository instance (and use .name and .rootpath instead). (_validate_cvsroot): refine the error message (clickable_path): use request.repos (view_directory, generate_tarball): use request.repos. use LogEntry for fileinfo. (file_sort_cmp): update for LogEntry (view_annotate, cvsgraph_image, viewcvs_graph, search_files, view_diff): use repos.rootpath rather than .cvsroot (main): tweak the ordering of some checks and dispatching. use the repos.itemtype() functionality to test for "is a directory". remove test for whether the CVS root exists -- it was done during the Request initialization. * vclib/bincvs/__init__.py (_FILE_HAD_ERROR): copied over from viewcvs.py (class LogError): new class (unused so far) to represent an error. (process_rlog_output): use LogEntry for fileinfo rather than a tuple (class BinCVSRepository): - change the init to verify the root is a directory, and store the name and rootpath (rootpath used to be called basepath). - add new .getitem() and .itemtype() methods for retrieving and querying about items, respectively. - tweak _getpath() joining of paths so we don't have to worry about adding a separator onto .rootpath. - remove .getfile() (now part of getitem). - replace .getsubdirs() with ._getvf_subdirs(). - replace .getfiles() with ._getvf_files(). git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@521 8cb11bc2-c004-0410-86c3-e597b4017df7
2002-06-03 22:35:06 +04:00
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"next"
reference to next revision, possibly None
example: if revision is 1.2.3.4, next is 1.2.3.5
This commit contains three changes, which I couldn't split back apart very easily (sorry): 1) use LogEntry for the fileinfo stuff 2) use bincvs.Repository for some basic functionality 3) update bincvs.__init__.py to the API that was checked in last week * viewcvs.py (class Request): remember the split path parts. refine some of the error logic and messages. replace .cvsrep and .cvsroot with a Repository instance (and use .name and .rootpath instead). (_validate_cvsroot): refine the error message (clickable_path): use request.repos (view_directory, generate_tarball): use request.repos. use LogEntry for fileinfo. (file_sort_cmp): update for LogEntry (view_annotate, cvsgraph_image, viewcvs_graph, search_files, view_diff): use repos.rootpath rather than .cvsroot (main): tweak the ordering of some checks and dispatching. use the repos.itemtype() functionality to test for "is a directory". remove test for whether the CVS root exists -- it was done during the Request initialization. * vclib/bincvs/__init__.py (_FILE_HAD_ERROR): copied over from viewcvs.py (class LogError): new class (unused so far) to represent an error. (process_rlog_output): use LogEntry for fileinfo rather than a tuple (class BinCVSRepository): - change the init to verify the root is a directory, and store the name and rootpath (rootpath used to be called basepath). - add new .getitem() and .itemtype() methods for retrieving and querying about items, respectively. - tweak _getpath() joining of paths so we don't have to worry about adding a separator onto .rootpath. - remove .getfile() (now part of getitem). - replace .getsubdirs() with ._getvf_subdirs(). - replace .getfiles() with ._getvf_files(). git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@521 8cb11bc2-c004-0410-86c3-e597b4017df7
2002-06-03 22:35:06 +04:00
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"parent"
reference to revision this one branches off of, possibly None
example: if revision is 1.2.3.4, parent is 1.2
This commit contains three changes, which I couldn't split back apart very easily (sorry): 1) use LogEntry for the fileinfo stuff 2) use bincvs.Repository for some basic functionality 3) update bincvs.__init__.py to the API that was checked in last week * viewcvs.py (class Request): remember the split path parts. refine some of the error logic and messages. replace .cvsrep and .cvsroot with a Repository instance (and use .name and .rootpath instead). (_validate_cvsroot): refine the error message (clickable_path): use request.repos (view_directory, generate_tarball): use request.repos. use LogEntry for fileinfo. (file_sort_cmp): update for LogEntry (view_annotate, cvsgraph_image, viewcvs_graph, search_files, view_diff): use repos.rootpath rather than .cvsroot (main): tweak the ordering of some checks and dispatching. use the repos.itemtype() functionality to test for "is a directory". remove test for whether the CVS root exists -- it was done during the Request initialization. * vclib/bincvs/__init__.py (_FILE_HAD_ERROR): copied over from viewcvs.py (class LogError): new class (unused so far) to represent an error. (process_rlog_output): use LogEntry for fileinfo rather than a tuple (class BinCVSRepository): - change the init to verify the root is a directory, and store the name and rootpath (rootpath used to be called basepath). - add new .getitem() and .itemtype() methods for retrieving and querying about items, respectively. - tweak _getpath() joining of paths so we don't have to worry about adding a separator onto .rootpath. - remove .getfile() (now part of getitem). - replace .getsubdirs() with ._getvf_subdirs(). - replace .getfiles() with ._getvf_files(). git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@521 8cb11bc2-c004-0410-86c3-e597b4017df7
2002-06-03 22:35:06 +04:00
"undead"
If the revision is dead, then this is a reference to the first
previous revision which isn't dead, otherwise it's a reference
to itself. If all the previous revisions are dead it's None.
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"branch_number"
tuple representing branch number or empty tuple if on trunk
example: if revision is 1.2.3.4, branch_number is (1, 2, 3)
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
Each tag in taglist gets these properties set:
"co_rev"
reference to revision that would be retrieved if tag were checked out
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"branch_rev"
reference to revision branched off of, only set for branch tags
example: if tag is 1.2.3, branch_rev points to 1.2 revision
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"aliases"
list of tags that have the same number
"""
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
# map of branch numbers to lists of corresponding branch Tags
branch_dict = {}
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
# map of revision numbers to lists of non-branch Tags
tag_dict = {}
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
# map of revision numbers to lists of branch Tags
branch_point_dict = {}
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
# toss tags into "branch_dict", "tag_dict", and "branch_point_dict"
# set "aliases" property and default "co_rev" and "branch_rev" values
for tag in taglist:
tag.co_rev = None
if tag.is_branch:
tag.branch_rev = None
_dict_list_add(branch_point_dict, tag.number[:-1], tag)
tag.aliases = _dict_list_add(branch_dict, tag.number, tag)
else:
tag.aliases = _dict_list_add(tag_dict, tag.number, tag)
# sort the revisions so the loop below can work properly
revlist.sort()
# array of the most recently encountered revision objects indexed by depth
history = []
# loop through revisions, setting properties and storing state in "history"
for rev in revlist:
depth = len(rev.number) / 2 - 1
# set "prev" and "next" properties
rev.prev = rev.next = None
if depth < len(history):
prev = history[depth]
if prev and (depth == 0 or rev.number[:-1] == prev.number[:-1]):
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
rev.prev = prev
prev.next = rev
# set "parent"
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
rev.parent = None
if depth and depth <= len(history):
parent = history[depth-1]
if parent and parent.number == rev.number[:-2]:
rev.parent = history[depth-1]
# set "undead"
if rev.dead:
prev = rev.prev or rev.parent
rev.undead = prev and prev.undead
else:
rev.undead = rev
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
# set "tags" and "branch_points"
rev.tags = tag_dict.get(rev.number, [])
rev.branch_points = branch_point_dict.get(rev.number, [])
# set "branches" and "branch_number"
if rev.prev:
rev.branches = rev.prev.branches
rev.branch_number = rev.prev.branch_number
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
rev.branch_number = depth and rev.number[:-1] or ()
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
try:
rev.branches = branch_dict[rev.branch_number]
except KeyError:
rev.branches = []
# set "co_rev" and "branch_rev"
for tag in rev.tags:
tag.co_rev = rev
for tag in rev.branch_points:
tag.co_rev = rev
tag.branch_rev = rev
# This loop only needs to be run for revisions at the heads of branches,
# but for the simplicity's sake, it actually runs for every revision on
# a branch. The later revisions overwrite values set by the earlier ones.
for branch in rev.branches:
branch.co_rev = rev
# end of outer loop, store most recent revision in "history" array
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
while len(history) <= depth:
history.append(None)
history[depth] = rev
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
def _add_tag(tag_name, revision):
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"""Create a new tag object and associate it with a revision"""
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 revision:
tag = Tag(tag_name, revision.string)
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
tag.aliases = revision.tags
revision.tags.append(tag)
else:
tag = Tag(tag_name, None)
tag.aliases = []
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
tag.co_rev = revision
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
tag.is_branch = 0
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
return tag
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 _remove_tag(tag):
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
"""Remove a tag's associations"""
tag.aliases.remove(tag)
if tag.is_branch and tag.branch_rev:
tag.branch_rev.branch_points.remove(tag)
def _revision_tuple(revision_string):
"""convert a revision number into a tuple of integers"""
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
t = tuple(map(int, revision_string.split('.')))
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
if len(t) % 2 == 0:
return t
raise ValueError
def _tag_tuple(revision_string):
"""convert a revision number or branch number into a tuple of integers"""
if revision_string:
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
t = map(int, revision_string.split('.'))
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
l = len(t)
if l == 1:
return ()
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
if l > 2 and t[-2] == 0 and l % 2 == 0:
del t[-2]
return tuple(t)
return ()
def _dict_list_add(dict, idx, elem):
try:
list = dict[idx]
except KeyError:
list = dict[idx] = [elem]
else:
list.append(elem)
return list
# ======================================================================
# Functions for parsing output from RCS utilities
class COMalformedOutput(vclib.Error):
pass
class COMissingRevision(vclib.Error):
pass
### suck up other warnings in _re_co_warning?
_re_co_filename = re.compile(r'^(.*),v\s+-->\s+(?:(?:standard output)|(?:stdout))\s*\n?$')
_re_co_warning = re.compile(r'^.*co: .*,v: warning: Unknown phrases like .*\n$')
_re_co_missing_rev = re.compile(r'^.*co: .*,v: revision.*absent\n$')
_re_co_side_branches = re.compile(r'^.*co: .*,v: no side branches present for [\d\.]+\n$')
_re_co_revision = re.compile(r'^revision\s+([\d\.]+)\s*\n$')
def _parse_co_header(fp):
"""Parse RCS co header.
fp is a file (pipe) opened for reading the co standard error stream.
Returns: (filename, revision) or (None, None) if output is empty
"""
# header from co:
#
#/home/cvsroot/mod_dav/dav_shared_stub.c,v --> standard output
#revision 1.1
#
# Sometimes, the following line might occur at line 2:
#co: INSTALL,v: warning: Unknown phrases like `permissions ...;' are present.
# parse the output header
filename = None
# look for a filename in the first line (if there is a first line).
line = fp.readline()
if not line:
return None, None
match = _re_co_filename.match(line)
if not match:
raise COMalformedOutput, "Unable to find filename in co output stream"
filename = match.group(1)
# look through subsequent lines for a revision. we might encounter
# some ignorable or problematic lines along the way.
while 1:
line = fp.readline()
if not line:
break
# look for a revision.
match = _re_co_revision.match(line)
if match:
return filename, match.group(1)
elif _re_co_missing_rev.match(line) or _re_co_side_branches.match(line):
raise COMissingRevision, "Got missing revision error from co output stream"
elif _re_co_warning.match(line):
pass
else:
break
raise COMalformedOutput, "Unable to find revision in co output stream"
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
# if your rlog doesn't use 77 '=' characters, then this must change
LOG_END_MARKER = '=' * 77 + '\n'
ENTRY_END_MARKER = '-' * 28 + '\n'
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
_EOF_FILE = 'end of file entries' # no more entries for this RCS file
_EOF_LOG = 'end of log' # hit the true EOF on the pipe
_EOF_ERROR = 'error message found' # rlog issued an error
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
# rlog error messages look like
#
# rlog: filename/goes/here,v: error message
# rlog: filename/goes/here,v:123: error message
#
# so we should be able to match them with a regex like
#
# ^rlog\: (.*)(?:\:\d+)?\: (.*)$
#
# But for some reason the windows version of rlog omits the "rlog: " prefix
# for the first error message when the standard error stream has been
# redirected to a file or pipe. (the prefix is present in subsequent errors
# and when rlog is run from the console). So the expression below is more
# complicated
_re_log_error = re.compile(r'^(?:rlog\: )*(.*,v)(?:\:\d+)?\: (.*)$')
# CVSNT error messages look like:
# cvs rcsfile: `C:/path/to/file,v' does not appear to be a valid rcs file
# cvs [rcsfile aborted]: C:/path/to/file,v: No such file or directory
# cvs [rcsfile aborted]: cannot open C:/path/to/file,v: Permission denied
_re_cvsnt_error = re.compile(r'^(?:cvs rcsfile\: |cvs \[rcsfile aborted\]: )'
r'(?:\`(.*,v)\' |cannot open (.*,v)\: |(.*,v)\: |)'
r'(.*)$')
def _parse_log_header(fp):
"""Parse and RCS/CVS log header.
fp is a file (pipe) opened for reading the log information.
On entry, fp should point to the start of a log entry.
On exit, fp will have consumed the separator line between the header and
the first revision log.
If there is no revision information (e.g. the "-h" switch was passed to
rlog), then fp will consumed the file separator line on exit.
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
Returns: filename, default branch, tag dictionary, lock dictionary,
rlog error message, and eof flag
"""
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
filename = head = branch = msg = ""
taginfo = { } # tag name => number
lockinfo = { } # revision => locker
state = 0 # 0 = base, 1 = parsing symbols, 2 = parsing locks
eof = None
while 1:
line = fp.readline()
if not line:
# the true end-of-file
eof = _EOF_LOG
break
if state == 1:
if line[0] == '\t':
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
[ tag, rev ] = map(lambda x: x.strip(), line.split(':'))
taginfo[tag] = rev
else:
# oops. this line isn't tag info. stop parsing tags.
state = 0
if state == 2:
if line[0] == '\t':
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
[ locker, rev ] = map(lambda x: x.strip(), line.split(':'))
lockinfo[rev] = locker
else:
# oops. this line isn't lock info. stop parsing tags.
state = 0
if state == 0:
if line[:9] == 'RCS file:':
filename = line[10:-1]
elif line[:5] == 'head:':
head = line[6:-1]
elif line[:7] == 'branch:':
branch = line[8:-1]
elif line[:6] == 'locks:':
# start parsing the lock information
state = 2
elif line[:14] == 'symbolic names':
# start parsing the tag information
state = 1
elif line == ENTRY_END_MARKER:
# end of the headers
break
elif line == LOG_END_MARKER:
# end of this file's log information
eof = _EOF_FILE
break
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
else:
error = _re_cvsnt_error.match(line)
if error:
p1, p2, p3, msg = error.groups()
filename = p1 or p2 or p3
if not filename:
raise vclib.Error("Could not get filename from CVSNT error:\n%s"
% line)
eof = _EOF_ERROR
break
error = _re_log_error.match(line)
if error:
filename, msg = error.groups()
if msg[:30] == 'warning: Unknown phrases like ':
# don't worry about this warning. it can happen with some RCS
# files that have unknown fields in them (e.g. "permissions 644;"
continue
eof = _EOF_ERROR
break
return filename, branch, taginfo, lockinfo, msg, eof
_re_log_info = re.compile(r'^date:\s+([^;]+);'
r'\s+author:\s+([^;]+);'
r'\s+state:\s+([^;]+);'
r'(\s+lines:\s+([0-9\s+-]+);?)?'
r'(\s+commitid:\s+([a-zA-Z0-9]+))?\n$')
### _re_rev should be updated to extract the "locked" flag
_re_rev = re.compile(r'^revision\s+([0-9.]+).*')
def _parse_log_entry(fp):
"""Parse a single log entry.
On entry, fp should point to the first line of the entry (the "revision"
line).
On exit, fp will have consumed the log separator line (dashes) or the
end-of-file marker (equals).
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
Returns: Revision object and eof flag (see _EOF_*)
"""
rev = None
line = fp.readline()
if not line:
return None, _EOF_LOG
if line == LOG_END_MARKER:
# Needed because some versions of RCS precede LOG_END_MARKER
# with ENTRY_END_MARKER
return None, _EOF_FILE
if line[:8] == 'revision':
match = _re_rev.match(line)
if not match:
return None, _EOF_LOG
rev = match.group(1)
line = fp.readline()
if not line:
return None, _EOF_LOG
match = _re_log_info.match(line)
eof = None
log = ''
while 1:
line = fp.readline()
if not line:
# true end-of-file
eof = _EOF_LOG
break
if line[:9] == 'branches:':
continue
if line == ENTRY_END_MARKER:
break
if line == LOG_END_MARKER:
# end of this file's log information
eof = _EOF_FILE
break
log = log + line
if not rev or not match:
# there was a parsing error
return None, eof
# parse out a time tuple for the local time
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
tm = vclib.ccvs.cvs_strptime(match.group(1))
# rlog seems to assume that two-digit years are 1900-based (so, "04"
# comes out as "1904", not "2004").
EPOCH = 1970
if tm[0] < EPOCH:
tm = list(tm)
if (tm[0] - 1900) < 70:
tm[0] = tm[0] + 100
if tm[0] < EPOCH:
raise ValueError, 'invalid year'
Wow. Drop a "general code cleanup" kind of bomb on the codebase. All of this is aimed at not paying the maintenance price of supporting Python versions prior to 2.4 any longer, plus a little bit of just getting dead code out of the way. * lib/compat.py Remove as unused. * bin/cvsdbadmin, * bin/loginfo-handler, * bin/make-database, * bin/svndbadmin, * lib/accept.py, * lib/blame.py, * lib/cvsdb.py, * lib/popen.py, * lib/query.py, * lib/sapi.py, * lib/vcauth/forbidden/__init__.py * lib/vcauth/forbiddenre/__init__.py, * lib/vcauth/svnauthz/__init__.py, * lib/vclib/__init__.py, * lib/vclib/ccvs/blame.py, * lib/win32popen.py, * tests/timelog.py Replace explicit import and use of the 'string' module with newer constructs. * bin/standalone.py, * lib/viewvc.py No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. * lib/dbi.py Use calender.timegm() instead of compat.timegm(). * lib/vcauth/__init__.py Lose unused module imports. * lib/config.py, Replace explicit import and use of the 'string' module with newer constructs where possible. Lose old ConfigParser patch-up code for Python 1.5.1. * lib/vclib/ccvs/ccvs.py Replace explicit import and use of the 'string' module with newer constructs where possible. Import _path_join() from bincvs, and use it instead of a bunch of copy-and-pasted string join() statements throughout. * lib/vclib/ccvs/__init__.py (cvs_strptime): Moved here from the 'compat' module. * lib/vclib/ccvs/bincvs.py (): No longer use 'compat' module. Replace explicit import and use of the 'string' module with newer constructs. (_path_join): New, used now instead of a bunch of copy-and-pasted string join() statements throughout. * viewvc-install Don't use the 'compat' module any more. Also, so some rearranging of non-critical bits. * misc/: New directory. * misc/py2html.py: Moved from 'lib/py2html.py'. * misc/PyFontify.py: Moved from 'lib/PyFontify.py'. * misc/elemx/: Moved from 'elemx/'. * misc/tparse/: Moved from 'tparse/'. * tools/make-release Omit 'misc' directory from releases, too. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2437 8cb11bc2-c004-0410-86c3-e597b4017df7
2010-09-03 20:49:52 +04:00
date = calendar.timegm(tm)
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
return Revision(rev, date,
# author, state, lines changed
Tweak vclib DirEntry and Revision objects. - Revision class is now defined in vclib - DirEntry class has new log_error boolean member to replace use of bincvs._FILE_HAD_ERROR constant. - In CVS, DirEntry.state string member is replaced by boolean DirEntry.dead * lib/vclib/__init__.py (Repository.dirlogs): add documentation (Revision): new class * lib/vclib/bincvs/__init__.py (Revision): inherit from new vclib.Revision class (get_logs, _FILE_HAD_ERROR): stop using _FILE_HAD_ERROR constant (parse_log_entry, get_logs): use "dead" properties instead of "state" properties on Revision and DirEntry objects (_newest_file): bugfix, call _check_path() to make sure returned file is accessible * lib/rlog.py (GetRLogData): use Revision.dead member instead of Revision.state * lib/vclib/svn/__init__.py (Revision, LogEntry): rename LogEntry class to Revision and inherit from vclib.Revision (NodeHistory.add_history): trim beginning slashes from subversion paths passed to this callback (_log_helper): call new Revision constructor (fetch_log): simplify return values (get_logs): set DirEntry.log_error member (SubversionRepository.filelog): update for changed fetch_log function, remove some kludges * lib/viewcvs.py (Request.run_viewcvs, bincvs): import bincvs module as neccessary instead of importing globally (view_markup, sort_file_data, view_directory, view_log, generate_tarball): update to deal with changed DirEntry and Revision members git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@796 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:05:08 +03:00
match.group(2), match.group(3) == "dead", match.group(5),
log), eof
def _skip_file(fp):
"Skip the rest of a file's log information."
while 1:
line = fp.readline()
if not line:
break
if line == LOG_END_MARKER:
break
def _paths_eq(path1, path2):
"See if two path strings are the same"
# This function is neccessary because CVSNT (since version 2.0.29)
# converts paths passed as arguments to use upper case drive
# letter and forward slashes
return os.path.normcase(path1) == os.path.normcase(path2)
# ======================================================================
# Functions for interpreting and manipulating log information
def _file_log(revs, taginfo, lockinfo, cur_branch, filter):
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
"""Augment list of Revisions and a dictionary of Tags"""
# Add artificial ViewVC tag MAIN. If the file has a default branch, then
# MAIN acts like a branch tag pointing to that branch. Otherwise MAIN acts
# like a branch tag that points to the trunk. (Note: A default branch is
# just a branch number specified in an RCS file that tells CVS and RCS
# what branch to use for checkout and update operations by default, when
# there's no revision argument or sticky branch to override it. Default
# branches get set by "cvs import" to point to newly created vendor
# branches. Sometimes they are also set manually with "cvs admin -b")
taginfo['MAIN'] = cur_branch
# Create tag objects
for name, num in taginfo.items():
taginfo[name] = Tag(name, num)
tags = taginfo.values()
# Set view_tag to a Tag object in order to filter results. We can filter by
# revision number or branch number
if filter:
try:
view_tag = Tag(None, filter)
except ValueError:
view_tag = None
else:
tags.append(view_tag)
# Match up tags and revisions
_match_revs_tags(revs, tags)
# Match up lockinfo and revision
for rev in revs:
rev.lockinfo = lockinfo.get(rev.string)
# Add artificial ViewVC tag HEAD, which acts like a non-branch tag pointing
# at the latest revision on the MAIN branch. The HEAD revision doesn't have
# anything to do with the "head" revision number specified in the RCS file
# and in rlog output. HEAD refers to the revision that the CVS and RCS co
# commands will check out by default, whereas the "head" field just refers
# to the highest revision on the trunk.
taginfo['HEAD'] = _add_tag('HEAD', taginfo['MAIN'].co_rev)
# Determine what revisions to return
if filter:
# If view_tag isn't set, it means filter is not a valid revision or
# branch number. Check taginfo to see if filter is set to a valid tag
# name. If so, filter by that tag, otherwise raise an error.
if not view_tag:
try:
view_tag = taginfo[filter]
except KeyError:
raise vclib.Error('Invalid tag or revision number "%s"' % filter)
filtered_revs = [ ]
New URL scheme for Subversion. The problem with the old scheme is it doesn't have a concept of a "sticky" revision. So if you are looking at version 10 of a directory, and click to view a file inside which was last modified in version 6, the fact you were looking at version 10 of the parent directory is not recorded anywhere, and the "Parent Directory" links on the markup page will take you to a version 6 directory listing instead of the listing you came from. This problem exists all over ViewCVS, not just in directory listings, and the result of it is that when you browse a repository by following the provided links you get sent further and further back into the history, all the while seeing incomplete log pages and outdated directory listings which you never asked for. The new URL scheme works by introducing a new 'pathrev' sticky variable and is described in detail in a comment in the _orig_path function in lib/viewcvs.py. The scheme is not backwards compatabile with all (or maybe even most) old subversion URLs. Specifically, any old URL referring to a path that no longer exists in the HEAD will not work. Other subversion URLs will still work. It is still possible to add backwards compatibility. We'd have to rename the rev parameter to something else, so we could know that all URLs with 'rev' in them are old style URLs which need to be redirected. I don't know if it's worth doing this though. This is not an isolated change. I've tried to unite the Subversion "sticky revision" with the present "only_with_tag" logic for CVS. And since I had to go over viewcvs.py with a fine-toothed comb implementing these things, there are also some miscellaneous cleanups there. * lib/vclib/bincvs/__init__.py (_file_log): change filtering so when matching revisions to tag, includes all preceding revisions, not just tag revision itself * lib/viewcvs.py (_sticky_vars): 'only_with_tag' is gone, so change this back into a list with no span-roots values (request.run_viewcvs): read new 'pathrev' parameter and use it when calling repos.itemtype (request.get_link): add 'pathrev' parameter to urls, restore update _sticky_vars loop (_legal_params, prep_tags, build_commit): replace 'only_with_tag' with 'pathrev' (_orig_path): new function (nav_path, common_template_data): stop adding 'rev' parameters to links removed unused 'roots_href' template variable (nav_header_data): add new 'revision_href', 'orig_path', 'orig_href' template variables for use in markup and annotate views (view_markup, view_checkout, view_annotate, setup_diff, generate_tarball, download_tarball): use 'pathrev' when looking up file revision (view_directory): use 'pathrev' when looking up directory revisions instead of 'rev'. stop adding 'rev' to links. add template variables: pathrev, pathrev_action, pathrev_hidden_values. remove unused template variables: num_files, rev, view_tag, has_tags, main_href, jump_rev_action, jump_rev_hidden_values, row.show_log. (view_log): use 'pathrev' to retrieve log information instead of 'rev'. stop linking to original paths of copied files. add template variables: entry.orig_path, entry.orig_href, default_branch, pathrev, pathrev_action, pathrev_hidden_values, branch_tags, plain_tags. remove template variables: entry.filename, entry.prev_path, branch, path_selected, view_tag, branch_names, branch_select_action, branch_select_hidden_values. (view_cvsgraph): use common_template_data instead of nav_header_data, 'pathrev' instead of 'only_with tag' (view_diff): use common_template_data instead of nav_header_data add template variables: path_left, path_right (view_revision): use 'pathrev' instead of 'rev' in links * templates/include/dir_header.ezt rearrange header and add sticky tag/revision row * templates/include/dir_footer.ezt remove tag selector * templates/include/pathrev_form.ezt new, sticky tag/revision selector form based on code from dir_footer.ezt * templates/include/branch.ezt * templates/include/branch_form.ezt * templates/include/view_tag.ezt removed * templates/include/log_header.ezt new, based on branch.ezt and view_tag.ezt * templates/include/log_footer.ezt new * templates/include/log.ezt * templates/include/log_table.ezt include log_header.ezt and log_footer.ezt * templates/include/annotate.ezt * templates/include/diff.ezt * templates/include/markup.ezt show original paths and add view_revision links * cvsgraph.conf.dist replace only_with_tag parameter with pathrev * website/template-authoring-guide.html update template variable information git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1145 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-03 16:31:02 +03:00
# only include revisions on the tag branch or it's parent branches
if view_tag.is_branch:
New URL scheme for Subversion. The problem with the old scheme is it doesn't have a concept of a "sticky" revision. So if you are looking at version 10 of a directory, and click to view a file inside which was last modified in version 6, the fact you were looking at version 10 of the parent directory is not recorded anywhere, and the "Parent Directory" links on the markup page will take you to a version 6 directory listing instead of the listing you came from. This problem exists all over ViewCVS, not just in directory listings, and the result of it is that when you browse a repository by following the provided links you get sent further and further back into the history, all the while seeing incomplete log pages and outdated directory listings which you never asked for. The new URL scheme works by introducing a new 'pathrev' sticky variable and is described in detail in a comment in the _orig_path function in lib/viewcvs.py. The scheme is not backwards compatabile with all (or maybe even most) old subversion URLs. Specifically, any old URL referring to a path that no longer exists in the HEAD will not work. Other subversion URLs will still work. It is still possible to add backwards compatibility. We'd have to rename the rev parameter to something else, so we could know that all URLs with 'rev' in them are old style URLs which need to be redirected. I don't know if it's worth doing this though. This is not an isolated change. I've tried to unite the Subversion "sticky revision" with the present "only_with_tag" logic for CVS. And since I had to go over viewcvs.py with a fine-toothed comb implementing these things, there are also some miscellaneous cleanups there. * lib/vclib/bincvs/__init__.py (_file_log): change filtering so when matching revisions to tag, includes all preceding revisions, not just tag revision itself * lib/viewcvs.py (_sticky_vars): 'only_with_tag' is gone, so change this back into a list with no span-roots values (request.run_viewcvs): read new 'pathrev' parameter and use it when calling repos.itemtype (request.get_link): add 'pathrev' parameter to urls, restore update _sticky_vars loop (_legal_params, prep_tags, build_commit): replace 'only_with_tag' with 'pathrev' (_orig_path): new function (nav_path, common_template_data): stop adding 'rev' parameters to links removed unused 'roots_href' template variable (nav_header_data): add new 'revision_href', 'orig_path', 'orig_href' template variables for use in markup and annotate views (view_markup, view_checkout, view_annotate, setup_diff, generate_tarball, download_tarball): use 'pathrev' when looking up file revision (view_directory): use 'pathrev' when looking up directory revisions instead of 'rev'. stop adding 'rev' to links. add template variables: pathrev, pathrev_action, pathrev_hidden_values. remove unused template variables: num_files, rev, view_tag, has_tags, main_href, jump_rev_action, jump_rev_hidden_values, row.show_log. (view_log): use 'pathrev' to retrieve log information instead of 'rev'. stop linking to original paths of copied files. add template variables: entry.orig_path, entry.orig_href, default_branch, pathrev, pathrev_action, pathrev_hidden_values, branch_tags, plain_tags. remove template variables: entry.filename, entry.prev_path, branch, path_selected, view_tag, branch_names, branch_select_action, branch_select_hidden_values. (view_cvsgraph): use common_template_data instead of nav_header_data, 'pathrev' instead of 'only_with tag' (view_diff): use common_template_data instead of nav_header_data add template variables: path_left, path_right (view_revision): use 'pathrev' instead of 'rev' in links * templates/include/dir_header.ezt rearrange header and add sticky tag/revision row * templates/include/dir_footer.ezt remove tag selector * templates/include/pathrev_form.ezt new, sticky tag/revision selector form based on code from dir_footer.ezt * templates/include/branch.ezt * templates/include/branch_form.ezt * templates/include/view_tag.ezt removed * templates/include/log_header.ezt new, based on branch.ezt and view_tag.ezt * templates/include/log_footer.ezt new * templates/include/log.ezt * templates/include/log_table.ezt include log_header.ezt and log_footer.ezt * templates/include/annotate.ezt * templates/include/diff.ezt * templates/include/markup.ezt show original paths and add view_revision links * cvsgraph.conf.dist replace only_with_tag parameter with pathrev * website/template-authoring-guide.html update template variable information git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1145 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-03 16:31:02 +03:00
branch = view_tag.number
elif len(view_tag.number) > 2:
branch = view_tag.number[:-1]
else:
branch = ()
# for a normal tag, include all tag revision and all preceding revisions.
# for a branch tag, include revisions on branch, branch point revision,
# and all preceding revisions
for rev in revs:
if (rev.number == view_tag.number
or rev.branch_number == view_tag.number
or (rev.number < view_tag.number
and rev.branch_number == branch[:len(rev.branch_number)])):
filtered_revs.append(rev)
# get rid of the view_tag if it was only created for filtering
if view_tag.name is None:
_remove_tag(view_tag)
else:
filtered_revs = revs
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
return filtered_revs
def _get_logs(repos, dir_path_parts, entries, view_tag, get_dirs):
alltags = { # all the tags seen in the files of this dir
'MAIN' : '',
'HEAD' : '1.1'
}
entries_idx = 0
entries_len = len(entries)
max_args = 100
while 1:
chunk = []
while len(chunk) < max_args and entries_idx < entries_len:
entry = entries[entries_idx]
path = _log_path(entry, repos._getpath(dir_path_parts), get_dirs)
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
if path:
entry.path = path
entry.idx = entries_idx
chunk.append(entry)
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
# set properties even if we don't retrieve logs
entry.rev = entry.date = entry.author = None
entry.dead = entry.log = entry.lockinfo = None
entries_idx = entries_idx + 1
if not chunk:
return alltags
args = []
if not view_tag:
# NOTE: can't pass tag on command line since a tag may contain "-"
# we'll search the output for the appropriate revision
# fetch the latest revision on the default branch
args.append('-r')
args.extend(map(lambda x: x.path, chunk))
rlog = repos.rcs_popen('rlog', args, 'rt')
# consume each file found in the resulting log
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
chunk_idx = 0
while chunk_idx < len(chunk):
file = chunk[chunk_idx]
filename, default_branch, taginfo, lockinfo, msg, eof \
= _parse_log_header(rlog)
if eof == _EOF_LOG:
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
# the rlog output ended early. this can happen on errors that rlog
# thinks are so serious that it stops parsing the current file and
# refuses to parse any of the files that come after it. one of the
# errors that triggers this obnoxious behavior looks like:
#
# rlog: c:\cvsroot\dir\file,v:8: unknown expand mode u
# rlog aborted
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
# if current file has errors, restart on the next one
if file.errors:
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
chunk_idx = chunk_idx + 1
if chunk_idx < len(chunk):
entries_idx = chunk[chunk_idx].idx
break
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
# otherwise just error out
raise vclib.Error('Rlog output ended early. Expected RCS file "%s"'
% file.path)
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
# if rlog filename doesn't match current file and we already have an
# error message about this file, move on to the next file
while not (file and _paths_eq(file.path, filename)):
if file and file.errors:
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
chunk_idx = chunk_idx + 1
file = chunk_idx < len(chunk) and chunk[chunk_idx] or None
continue
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
raise vclib.Error('Error parsing rlog output. Expected RCS file %s'
', found %s' % (file and file.path, filename))
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
# if we get an rlog error message, restart loop without advancing
# chunk_idx cause there might be more output about the same file
if eof == _EOF_ERROR:
file.errors.append("rlog error: %s" % msg)
continue
tag = None
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
if view_tag == 'MAIN' or view_tag == 'HEAD':
tag = Tag(None, default_branch)
elif taginfo.has_key(view_tag):
tag = Tag(None, taginfo[view_tag])
elif view_tag and (eof != _EOF_FILE):
# the tag wasn't found, so skip this file (unless we already
# know there's nothing left of it to read)
_skip_file(rlog)
eof = _EOF_FILE
# we don't care about the specific values -- just the keys and whether
# the values point to branches or revisions. this the fastest way to
# merge the set of keys and keep values that allow us to make the
# distinction between branch tags and normal tags
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
alltags.update(taginfo)
# read all of the log entries until we find the revision we want
wanted_entry = None
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
while not eof:
# fetch one of the log entries
entry, eof = _parse_log_entry(rlog)
if not entry:
# parsing error
break
# A perfect match is a revision on the branch being viewed or
# a revision having the tag being viewed or any revision
# when nothing is being viewed. When there's a perfect match
# we set the wanted_entry value and break out of the loop.
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
# An imperfect match is a revision at the branch point of a
# branch being viewed. When there's an imperfect match we
# also set the wanted_entry value but keep looping in case
# something better comes along.
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
perfect = not tag or entry.number == tag.number or \
(len(entry.number) == 2 and not tag.number) or \
entry.number[:-1] == tag.number
if perfect or entry.number == tag.number[:-1]:
wanted_entry = entry
if perfect:
break
if wanted_entry:
Move all the code that manipulates CVS revision numbers out of viewcvs.py and into the bincvs module, unfortunately rewriting most of it in the process. I thought I finished this before, but some code in view_markup and augment_entry slipped below my radar. The main difference between the new code and the old code is that the old code used string representations of revision numbers and manipulated them with string operations and regular expressions while the new code converts all revision numbers into tuples of integers and manipulates them in that form. This change also restores some minor ViewCVS 0.9.2 behaviors that I inadvertently changed before: - "Branch" fields on log pages list "MAIN" tags instead of skipping them - The "Default branch" field on the top of log pages lists all names for a default branch instead of picking one randomly - Viewing a directory with "only_with_tag=HEAD" shows default branch revisions, not just trunk revisions * lib/vclib/bincvs/__init__.py (LogEntry, LogHeader, LogError, TagInfo): removed classes (Revision): new class, replaces LogEntry (Tag): new class, replaces TagInfo (match_rev_tags, add_tag, remove_tag): new functions for manipulating revisions and tags (_revision_tuple, _tag_tuple, _dict_list_add): new internal functions (parse_log_header): return multiple values directly instead of packing them into a LogHeader object (parse_log_entry, _sort_tags, BinCVSRepository.openfile): use Revision and Tag classes instead of LogEntry and TagInfo classes (get_logs): fix handling of HEAD tag (fetch_log): stop returning "head" field from rlog, it's not useful for anything * lib/viewcvs.py (prep_tags, logsort_date_cmp, logsort_rev_cmp) tweaked to work with bincvs.Tag and bincvs.Revision objects (find_first_rev): removed (view_markup, augment_entry): change to deal with Revision and Tag objects, remove some revision number computation (read_log): don't do revision/tag matching here, instead call match_revs_tags update filtering code and some comments (view_log_cvs): fix default branch code to display all known branch names * lib/rlog.py (GetRLogData): update for changed bincvs.fetch_log git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@786 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-21 03:50:17 +03:00
file.rev = wanted_entry.string
file.date = wanted_entry.date
file.author = wanted_entry.author
Handle CVS Attic paths transparently in the bincvs module instead of exposing them to users. * templates/include/dir_footer.ezt add link to show dead files * templates/directory.ezt remove code for detecting Attic entries, change (in the attic) caption to (dead) * lib/viewcvs.py (Request.run_viewcvs): handle old Attic URL's by redirecting, remove unused request.full_name member (get_up_path, _re_up_attic_path, nav_header_data, generate_tarball, download_tarball): remove code for handling Attic directories (view_markup): remove unused "full_name" variable (view_directory): remove code for handling Attic directories, replace "no_match" template variable with "num_dead" (view_log): update call to get_up_path (view_annotate, view_cvsgraph_image, view_cvsgraph, view_diff): use CVSRepository.rcsfile to get path to rcs file * lib/vclib/bincvs/__init__.py (CVSRepository.itemtype): look in Attic for repository files (CVSRepository.listdir): remove "cvs_list_attic" option, now always list attic files. leave "Attic" and "CVS" directories out of returned listing. (CVSRepository.rcsfile, CVSRepository._atticpath): new methods (BinCVSRepository.openfile, BinCVSRepository.filelog): use CVSRepository.rcsfile to get path to rcs file (_get_logs): don't mark directories as dead * lib/vclib/ccvs/__init__.py (CCVSRepository.filelog, CCVSRepository.openfile): use CVSRepository.rcsfile to get path to rcs file * website/upgrading.html document "no_match" and "num_dead" template variables git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@908 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-08-01 02:34:51 +04:00
file.dead = file.kind == vclib.FILE and wanted_entry.dead
file.absent = 0
file.log = wanted_entry.log
Finish issue #57 with more support for showing locked status. * lib/vclib/__init__.py (Repository.dirlogs): Update comment. (Revision.__init__): Add 'lockinfo' parameter, used to populate similarly named class member. * lib/vclib/svn/svn_repos.py (Revision.__init__): Add 'lockinfo' parameter, and update call to vclib.Revision(). (_log_helper): Update call to Revision(), and lose custom lockinfo handling. (LocalSubversionRepository.dirlogs): Populate entry lockinfo with a call to svn_fs_get_lock() for each entry. * lib/vclib/svn/svn_ra.py (LogCollector.__init__): Add 'lockinfo' parameter, used to populate similarly named class member. (LogCollector.add_log): Pass self.lockinfo to updated call to Revision(). (RemoteSubversionRepository.itemlog): Pass lock info to LogCollector(), and lose custom lockinfo handling. (RemoteSubversionRepository.itemtype, RemoteSubversionRepository.listdir): Update expected return value from _get_dirents(). (RemoteSubversionRepository.dirlogs): Populate entry lockinfo from updated return value from _get_dirents(). (RemoteSubversionRepository._get_dirents): Rework to trade in dirents and locks instead of only dirents. * lib/vclib/ccvs/bincvs.py (Revision.__init__): Update call to vclib.Revision(). (_get_logs): Add 'lockinfo' member to DirEntry() items. * lib/vclib/ccvs/ccvs.py (InfoSink.__init__): Init lockinfo dictionary. (InfoSink.set_locker): New. (InfoSink.define_revision): Set lockinfo on Revision item. (InfoSink.set_revision_info): Populate DirEntry lockinfo from Revision lockinfo data. * lib/viewvc.py (view_directory): Populate entry lockinfo. (common_template_data): Populate the 'lockinfo' data dictionary item. * templates/directory.ezt, * templates/dir_new.ezt * templates/annotate.ezt, * templates/markup.ezt Tweak to show lock status. * docs/template-authoring-guide.html Note new data dictionary items. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1787 8cb11bc2-c004-0410-86c3-e597b4017df7
2008-02-13 00:06:40 +03:00
file.lockinfo = lockinfo.get(file.rev)
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
# suppress rlog errors if we find a usable revision in the end
del file.errors[:]
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
elif file.kind == vclib.FILE:
file.dead = 0
#file.errors.append("No revisions exist on %s" % (view_tag or "MAIN"))
file.absent = 1
# done with this file now, skip the rest of this file's revisions
if not eof:
_skip_file(rlog)
Improve error handling in directory view. * lib/vclib/bincvs/__init__.py (BinCVSRepository.openfile, BinCVSRepository.filelog, fetch_log): update calls to _parse_log_header (_re_log_error, _re_cvsnt_error, _re_lineno): update regular expressions for parsing rlog error messages (_parse_log_header): do a better job of parsing rlog error messages and return messages to callers (_get_logs): set new DirEntry.log_errors property and deal with multiple rlog error messages about the same file and cases where error messages precede file information (_log_path): return error info * lib/vclib/ccvs/__init__.py (CCVSRepository.dirlogs): set new DirEntry.log_errors property * lib/vclib/svn/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/svn_ra/__init__.py (get_logs): set new DirEntry.log_errors property * lib/vclib/__init__.py (Repository.dirlogs): document new DirEntry.log_errors property * lib/viewcvs.py (view_directory): set new template variables * website/upgrading.html document new template variables * templates/include/dir_footer.ezt get rid of confusing "One or more files were unreadable" message. We display more specific error messages in the directory list. add links to set selection criteria at the bottom of "There are [num_files] files, but none match the current selection criteria" message * templates/directory.ezt * templates/dir_alternate.ezt simplify the way error messages are displayed git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@907 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-07-31 18:38:03 +04:00
# end of while loop, advance index
chunk_idx = chunk_idx + 1
rlog.close()
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
def _log_path(entry, dirpath, getdirs):
path = name = None
if not entry.errors:
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
if entry.kind == vclib.FILE:
path = entry.in_attic and 'Attic' or ''
name = entry.name
elif entry.kind == vclib.DIR and getdirs:
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
entry.newest_file = _newest_file(os.path.join(dirpath, entry.name))
if entry.newest_file:
path = entry.name
name = entry.newest_file
if name:
return os.path.join(dirpath, path, name + ',v')
return None
Get ccvs module in working state, and add "use_rcsparse" option to use it instead of bincvs. It works for log pages, directory pages, markup pages, checkouts, and tarball downloads, but not for diffs because vclib doesn't currently have an interface for diffing. * viewcvs.conf.dist (use_rcsparse): new option * lib/config.py (Config.set_defaults): make use_rcsparse off by default * lib/viewcvs.py (Request.run_viewcvs) import ccvs module instead of bincvs if use_rcsparse is enabled (markup_stream_enscript): check for eof() method on file objects before calling * lib/vclib/bincvs/__init__.py (CVSRepository, BinCVSRepository): separate new base class CVSRepository out of BinCVSRepository. The new base class is shared with the ccvs module (BinCVSRepository.filelog, _file_log): move calls to rcs utilities out of _file_log() function and into the filelog() method. This way _file_log() can be shared with the ccvs module (Revision.__init__): add default argument values to simplify some calls in the ccvs module (_get_logs, _log_path): move some functionality out of _get_logs() into new _log_path() function, which is shared with ccvs * lib/vclib/ccvs/__init__.py Lots of kludges added to this module to get it running again and taking advantage of functionality already implemented in bincvs. It's not pretty, but at least it works and is no longer out of date. (CCVSRepository, CVSRepository): delete old CVSRepository class, create new CCVSRepository class implementing the current vclib api (MatchingSink): new sink superclass (InfoSink): updated to work with tags and default branches instead of always finding latest trunk revisions. Also changed to work with DirEntry objects (TreeSink): updated to work with Revision objects (StreamText.next_revision, StreamText): remove "next_revision" debugging method and all references to it (COSink): reimplement with a simpler algorithm * lib/vclib/ccvs/rcsparse/common.py (Sink.admin_completed): new callback (_Parser.parse): call new callback git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@798 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:25:30 +03:00
# ======================================================================
# Functions for dealing with the filesystem
if sys.platform == "win32":
def _check_path(path):
kind = None
errors = []
if os.path.isfile(path):
kind = vclib.FILE
elif os.path.isdir(path):
kind = vclib.DIR
else:
errors.append("error: path is not a file or directory")
if not os.access(path, os.R_OK):
errors.append("error: path is not accessible")
return kind, errors
else:
_uid = os.getuid()
_gid = os.getgid()
def _check_path(pathname):
try:
info = os.stat(pathname)
except os.error, e:
return None, ["stat error: %s" % e]
kind = None
errors = []
mode = info[stat.ST_MODE]
isdir = stat.S_ISDIR(mode)
isreg = stat.S_ISREG(mode)
if isreg or isdir:
#
# Quick version of access() where we use existing stat() data.
#
# This might not be perfect -- the OS may return slightly different
# results for some bizarre reason. However, we make a good show of
# "can I read this file/dir?" by checking the various perm bits.
#
# NOTE: if the UID matches, then we must match the user bits -- we
# cannot defer to group or other bits. Similarly, if the GID matches,
# then we must have read access in the group bits.
#
# If the UID or GID don't match, we need to check the
# results of an os.access() call, in case the web server process
# is in the group that owns the directory.
#
if isdir:
mask = stat.S_IROTH | stat.S_IXOTH
else:
mask = stat.S_IROTH
if info[stat.ST_UID] == _uid:
if ((mode >> 6) & mask) != mask:
errors.append("error: path is not accessible to user %i" % _uid)
elif info[stat.ST_GID] == _gid:
if ((mode >> 3) & mask) != mask:
errors.append("error: path is not accessible to group %i" % _gid)
# If the process running the web server is a member of
# the group stat.ST_GID access may be granted.
# so the fall back to os.access is needed to figure this out.
elif (mode & mask) != mask:
if not os.access(pathname, isdir and (os.R_OK | os.X_OK) or os.R_OK):
errors.append("error: path is not accessible")
if isdir:
kind = vclib.DIR
else:
kind = vclib.FILE
else:
errors.append("error: path is not a file or directory")
return kind, errors
def _newest_file(dirpath):
"""Find the last modified RCS file in a directory"""
newest_file = None
newest_time = 0
### FIXME: This sucker is leaking unauthorized paths! ###
for subfile in os.listdir(dirpath):
### filter CVS locks? stale NFS handles?
if subfile[-2:] != ',v':
continue
Tweak vclib DirEntry and Revision objects. - Revision class is now defined in vclib - DirEntry class has new log_error boolean member to replace use of bincvs._FILE_HAD_ERROR constant. - In CVS, DirEntry.state string member is replaced by boolean DirEntry.dead * lib/vclib/__init__.py (Repository.dirlogs): add documentation (Revision): new class * lib/vclib/bincvs/__init__.py (Revision): inherit from new vclib.Revision class (get_logs, _FILE_HAD_ERROR): stop using _FILE_HAD_ERROR constant (parse_log_entry, get_logs): use "dead" properties instead of "state" properties on Revision and DirEntry objects (_newest_file): bugfix, call _check_path() to make sure returned file is accessible * lib/rlog.py (GetRLogData): use Revision.dead member instead of Revision.state * lib/vclib/svn/__init__.py (Revision, LogEntry): rename LogEntry class to Revision and inherit from vclib.Revision (NodeHistory.add_history): trim beginning slashes from subversion paths passed to this callback (_log_helper): call new Revision constructor (fetch_log): simplify return values (get_logs): set DirEntry.log_error member (SubversionRepository.filelog): update for changed fetch_log function, remove some kludges * lib/viewcvs.py (Request.run_viewcvs, bincvs): import bincvs module as neccessary instead of importing globally (view_markup, sort_file_data, view_directory, view_log, generate_tarball): update to deal with changed DirEntry and Revision members git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@796 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:05:08 +03:00
path = os.path.join(dirpath, subfile)
info = os.stat(path)
if not stat.S_ISREG(info[stat.ST_MODE]):
continue
if info[stat.ST_MTIME] > newest_time:
Tweak vclib DirEntry and Revision objects. - Revision class is now defined in vclib - DirEntry class has new log_error boolean member to replace use of bincvs._FILE_HAD_ERROR constant. - In CVS, DirEntry.state string member is replaced by boolean DirEntry.dead * lib/vclib/__init__.py (Repository.dirlogs): add documentation (Revision): new class * lib/vclib/bincvs/__init__.py (Revision): inherit from new vclib.Revision class (get_logs, _FILE_HAD_ERROR): stop using _FILE_HAD_ERROR constant (parse_log_entry, get_logs): use "dead" properties instead of "state" properties on Revision and DirEntry objects (_newest_file): bugfix, call _check_path() to make sure returned file is accessible * lib/rlog.py (GetRLogData): use Revision.dead member instead of Revision.state * lib/vclib/svn/__init__.py (Revision, LogEntry): rename LogEntry class to Revision and inherit from vclib.Revision (NodeHistory.add_history): trim beginning slashes from subversion paths passed to this callback (_log_helper): call new Revision constructor (fetch_log): simplify return values (get_logs): set DirEntry.log_error member (SubversionRepository.filelog): update for changed fetch_log function, remove some kludges * lib/viewcvs.py (Request.run_viewcvs, bincvs): import bincvs module as neccessary instead of importing globally (view_markup, sort_file_data, view_directory, view_log, generate_tarball): update to deal with changed DirEntry and Revision members git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@796 8cb11bc2-c004-0410-86c3-e597b4017df7
2004-01-25 22:05:08 +03:00
kind, verboten = _check_path(path)
if kind == vclib.FILE and not verboten:
newest_file = subfile[:-2]
newest_time = info[stat.ST_MTIME]
return newest_file