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-e597b4017df7remotes/unified-vclib-svn
parent
a86bac818e
commit
a5df176395
|
@ -40,7 +40,6 @@ else:
|
|||
#########################################################################
|
||||
|
||||
import os
|
||||
import string
|
||||
import cvsdb
|
||||
import viewvc
|
||||
import vclib.ccvs
|
||||
|
@ -56,7 +55,7 @@ def UpdateFile(db, repository, path, update, quiet_level):
|
|||
print '[ERROR] %s' % (e)
|
||||
return
|
||||
|
||||
file = string.join(path, "/")
|
||||
file = '/'.join(path)
|
||||
printing = 0
|
||||
if update:
|
||||
if quiet_level < 1 or (quiet_level < 2 and len(commit_list)):
|
||||
|
|
|
@ -39,7 +39,6 @@ else:
|
|||
#########################################################################
|
||||
|
||||
import os
|
||||
import string
|
||||
import getopt
|
||||
import re
|
||||
import cvsdb
|
||||
|
@ -152,11 +151,11 @@ def FindLongestDirectory(s, repository):
|
|||
and a file name, either of which may contain spaces. Returns the longest
|
||||
possible directory name that actually exists"""
|
||||
|
||||
parts = string.split(s, " ")
|
||||
parts = s.split()
|
||||
|
||||
for i in range(len(parts)-1, 0, -1):
|
||||
directory = string.join(parts[:i])
|
||||
filename = string.join(parts[i:])
|
||||
directory = ' '.join(parts[:i])
|
||||
filename = ' '.join(parts[i:])
|
||||
if os.path.isdir(os.path.join(repository, directory)):
|
||||
return directory, filename
|
||||
|
||||
|
@ -227,7 +226,7 @@ def ProcessLoginfo(rootpath, directory, files):
|
|||
cfg.utilities, 0)
|
||||
|
||||
# split up the directory components
|
||||
dirpath = filter(None, string.split(os.path.normpath(directory), os.sep))
|
||||
dirpath = filter(None, os.path.normpath(directory).split(os.sep))
|
||||
|
||||
## build a list of Commit objects
|
||||
commit_list = []
|
||||
|
@ -279,7 +278,7 @@ if __name__ == '__main__':
|
|||
else:
|
||||
# if there are no arguments, read version information from
|
||||
# first line of input like old versions of ViewCVS did
|
||||
arg = string.rstrip(sys.stdin.readline())
|
||||
arg = sys.stdin.readline().rstrip()
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
# if there is a second argument it indicates which parser
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
#
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
import os, sys, string
|
||||
import os
|
||||
import sys
|
||||
import popen2
|
||||
import getopt
|
||||
|
||||
|
@ -311,7 +312,7 @@ if __name__ == "__main__":
|
|||
dbname = raw_input("ViewVC Database Name [default: ViewVC]: ") or "ViewVC"
|
||||
|
||||
# Create the database
|
||||
dscript = string.replace(DATABASE_SCRIPT_COMMON, "<dbname>", dbname)
|
||||
dscript = DATABASE_SCRIPT_COMMON.replace("<dbname>", dbname)
|
||||
if version == "1.0":
|
||||
print BONSAI_COMPAT
|
||||
dscript = dscript + DATABASE_SCRIPT_VERSION_0
|
||||
|
|
|
@ -46,7 +46,6 @@ else:
|
|||
|
||||
import sapi
|
||||
import viewvc
|
||||
import compat; compat.for_standalone()
|
||||
|
||||
|
||||
class Options:
|
||||
|
@ -74,7 +73,7 @@ class StandaloneServer(sapi.CgiServer):
|
|||
statusCode = 200
|
||||
statusText = 'OK'
|
||||
else:
|
||||
p = string.find(status, ' ')
|
||||
p = status.find(' ')
|
||||
if p < 0:
|
||||
statusCode = int(status)
|
||||
statusText = ''
|
||||
|
@ -173,7 +172,7 @@ class ViewVCHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
try:
|
||||
lines = open(htpasswd_file, 'r').readlines()
|
||||
for line in lines:
|
||||
file_user, file_pass = string.split(line.rstrip(), ':', 1)
|
||||
file_user, file_pass = line.rstrip().split(':', 1)
|
||||
if username == file_user:
|
||||
return file_pass == crypt.crypt(password, file_pass[:2])
|
||||
except:
|
||||
|
@ -197,10 +196,10 @@ class ViewVCHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
if not authn:
|
||||
raise AuthenticationException()
|
||||
try:
|
||||
kind, data = string.split(authn, ' ', 1)
|
||||
kind, data = authn.split(' ', 1)
|
||||
if kind == 'Basic':
|
||||
data = base64.b64decode(data)
|
||||
username, password = string.split(data, ':', 1)
|
||||
username, password = data.split(':', 1)
|
||||
except:
|
||||
raise AuthenticationException()
|
||||
if not self.validate_password(options.htpasswd_file, username, password):
|
||||
|
@ -214,7 +213,7 @@ class ViewVCHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
|
||||
viewvc_url = self.server.url[:-1] + scriptname
|
||||
rest = self.path[len(scriptname):]
|
||||
i = string.rfind(rest, '?')
|
||||
i = rest.rfind('?')
|
||||
if i >= 0:
|
||||
rest, query = rest[:i], rest[i+1:]
|
||||
else:
|
||||
|
@ -259,10 +258,10 @@ class ViewVCHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
accept = []
|
||||
for line in self.headers.getallmatchingheaders('accept'):
|
||||
if line[:1] in string.whitespace:
|
||||
accept.append(string.strip(line))
|
||||
accept.append(line.strip())
|
||||
else:
|
||||
accept = accept + string.split(line[7:], ',')
|
||||
env['HTTP_ACCEPT'] = string.joinfields(accept, ',')
|
||||
accept = accept + line[7:].split(',')
|
||||
env['HTTP_ACCEPT'] = ','.join(accept)
|
||||
ua = self.headers.getheader('user-agent')
|
||||
if ua:
|
||||
env['HTTP_USER_AGENT'] = ua
|
||||
|
@ -384,7 +383,7 @@ def serve(host, port, callback=None):
|
|||
line = fp.readline()
|
||||
if not line:
|
||||
break
|
||||
if string.find(line, "Concurrent Versions System (CVSNT)") >= 0:
|
||||
if line.find("Concurrent Versions System (CVSNT)") >= 0:
|
||||
cvsnt_works = 1
|
||||
while fp.read(4096):
|
||||
pass
|
||||
|
@ -435,8 +434,7 @@ def main(argv):
|
|||
elif opt in ('-h', '--host'):
|
||||
options.host = val
|
||||
elif opt in ('-s', '--script-alias'):
|
||||
options.script_alias = \
|
||||
string.join(filter(None, string.split(val, '/')), '/')
|
||||
options.script_alias = '/'.join(filter(None, val.split('/')))
|
||||
elif opt in ('-c', '--config-file'):
|
||||
if not os.path.isfile(val):
|
||||
raise BadUsage, "'%s' does not appear to be a valid " \
|
||||
|
|
|
@ -57,7 +57,6 @@ else:
|
|||
#########################################################################
|
||||
|
||||
import os
|
||||
import string
|
||||
import re
|
||||
|
||||
import svn.core
|
||||
|
@ -332,7 +331,7 @@ if __name__ == '__main__':
|
|||
if len(args) < 3:
|
||||
usage()
|
||||
|
||||
command = string.lower(args[1])
|
||||
command = args[1].lower()
|
||||
if command not in ('rebuild', 'update', 'purge'):
|
||||
sys.stderr.write('ERROR: unknown command %s\n' % command)
|
||||
usage()
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
# -----------------------------------------------------------------------
|
||||
|
||||
import re
|
||||
import string
|
||||
|
||||
|
||||
def language(hdr):
|
||||
|
@ -40,7 +39,7 @@ def _parse(hdr, result):
|
|||
name = _re_token.match(hdr, pos)
|
||||
if not name:
|
||||
raise AcceptLanguageParseError()
|
||||
a = result.item_class(string.lower(name.group(1)))
|
||||
a = result.item_class(name.group(1).lower())
|
||||
pos = name.end()
|
||||
while 1:
|
||||
# are we looking at a parameter?
|
||||
|
@ -56,7 +55,7 @@ def _parse(hdr, result):
|
|||
# the "=" was probably missing
|
||||
continue
|
||||
|
||||
pname = string.lower(match.group(1))
|
||||
pname = match.group(1).lower()
|
||||
if pname == 'q' or pname == 'qs':
|
||||
try:
|
||||
a.quality = float(match.group(2))
|
||||
|
@ -70,7 +69,7 @@ def _parse(hdr, result):
|
|||
# bad float literal
|
||||
pass
|
||||
elif pname == 'charset':
|
||||
a.charset = string.lower(match.group(2))
|
||||
a.charset = match.group(2).lower()
|
||||
|
||||
result.append(a)
|
||||
if hdr[pos:pos+1] == ',':
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
# -----------------------------------------------------------------------
|
||||
|
||||
import sys
|
||||
import string
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
|
@ -42,7 +41,7 @@ def link_includes(text, repos, path_parts, include_url):
|
|||
if match:
|
||||
incfile = match.group(3)
|
||||
include_path_parts = path_parts[:-1]
|
||||
for part in filter(None, string.split(incfile, '/')):
|
||||
for part in filter(None, incfile.split('/')):
|
||||
if part == "..":
|
||||
if not include_path_parts:
|
||||
# nothing left to pop; don't bother marking up this include.
|
||||
|
@ -54,14 +53,14 @@ def link_includes(text, repos, path_parts, include_url):
|
|||
include_path = None
|
||||
try:
|
||||
if repos.itemtype(include_path_parts, None) == vclib.FILE:
|
||||
include_path = string.join(include_path_parts, '/')
|
||||
include_path = '/'.join(include_path_parts)
|
||||
except vclib.ItemNotFound:
|
||||
pass
|
||||
|
||||
if include_path:
|
||||
return '#%sinclude%s<a href="%s">"%s"</a>' % \
|
||||
(match.group(1), match.group(2),
|
||||
string.replace(include_url, '/WHERE/', include_path), incfile)
|
||||
include_url.replace('/WHERE/', include_path), incfile)
|
||||
|
||||
return text
|
||||
|
||||
|
@ -135,7 +134,7 @@ def make_html(root, rcs_path):
|
|||
sys.stdout.write('<td> </td><td> </td>')
|
||||
rev_count = rev_count + 1
|
||||
|
||||
sys.stdout.write('<td%s>%s</td></tr>\n' % (align % 'left', string.rstrip(thisline) or ' '))
|
||||
sys.stdout.write('<td%s>%s</td></tr>\n' % (align % 'left', thisline.rstrip() or ' '))
|
||||
sys.stdout.write('</table>\n')
|
||||
|
||||
|
||||
|
|
180
lib/compat.py
180
lib/compat.py
|
@ -1,180 +0,0 @@
|
|||
# -*-python-*-
|
||||
#
|
||||
# Copyright (C) 1999-2007 The ViewCVS Group. All Rights Reserved.
|
||||
#
|
||||
# By using this file, you agree to the terms and conditions set forth in
|
||||
# the LICENSE.html file which can be found at the top level of the ViewVC
|
||||
# distribution or at http://viewvc.org/license-1.html.
|
||||
#
|
||||
# For more information, visit http://viewvc.org/
|
||||
#
|
||||
# -----------------------------------------------------------------------
|
||||
#
|
||||
# compat.py: compatibility functions for operation across Python 1.5.x to 2.2.x
|
||||
#
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
import urllib
|
||||
import string
|
||||
import time
|
||||
import calendar
|
||||
import re
|
||||
import os
|
||||
import rfc822
|
||||
import tempfile
|
||||
import errno
|
||||
|
||||
#
|
||||
# urllib.urlencode() is new to Python 1.5.2
|
||||
#
|
||||
try:
|
||||
urlencode = urllib.urlencode
|
||||
except AttributeError:
|
||||
def urlencode(dict):
|
||||
"Encode a dictionary as application/x-url-form-encoded."
|
||||
if not dict:
|
||||
return ''
|
||||
quote = urllib.quote_plus
|
||||
keyvalue = [ ]
|
||||
for key, value in dict.items():
|
||||
keyvalue.append(quote(key) + '=' + quote(str(value)))
|
||||
return string.join(keyvalue, '&')
|
||||
|
||||
#
|
||||
# time.strptime() is new to Python 1.5.2
|
||||
#
|
||||
if hasattr(time, 'strptime'):
|
||||
def cvs_strptime(timestr):
|
||||
'Parse a CVS-style date/time value.'
|
||||
return time.strptime(timestr, '%Y/%m/%d %H:%M:%S')[:-1] + (0,)
|
||||
else:
|
||||
_re_rev_date = re.compile('([0-9]{4})/([0-9][0-9])/([0-9][0-9]) '
|
||||
'([0-9][0-9]):([0-9][0-9]):([0-9][0-9])')
|
||||
def cvs_strptime(timestr):
|
||||
'Parse a CVS-style date/time value.'
|
||||
match = _re_rev_date.match(timestr)
|
||||
if match:
|
||||
return tuple(map(int, match.groups())) + (0, 1, 0)
|
||||
else:
|
||||
raise ValueError('date is not in cvs format')
|
||||
|
||||
#
|
||||
# os.makedirs() is new to Python 1.5.2
|
||||
#
|
||||
try:
|
||||
makedirs = os.makedirs
|
||||
except AttributeError:
|
||||
def makedirs(path, mode=0777):
|
||||
head, tail = os.path.split(path)
|
||||
if head and tail and not os.path.exists(head):
|
||||
makedirs(head, mode)
|
||||
os.mkdir(path, mode)
|
||||
|
||||
#
|
||||
# rfc822.formatdate() is new to Python 1.6
|
||||
#
|
||||
try:
|
||||
formatdate = rfc822.formatdate
|
||||
except AttributeError:
|
||||
def formatdate(timeval):
|
||||
if timeval is None:
|
||||
timeval = time.time()
|
||||
timeval = time.gmtime(timeval)
|
||||
return "%s, %02d %s %04d %02d:%02d:%02d GMT" % (
|
||||
["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][timeval[6]],
|
||||
timeval[2],
|
||||
["Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][timeval[1]-1],
|
||||
timeval[0], timeval[3], timeval[4], timeval[5])
|
||||
|
||||
#
|
||||
# calendar.timegm() is new to Python 2.x and
|
||||
# calendar.leapdays() was wrong in Python 1.5.2
|
||||
#
|
||||
try:
|
||||
timegm = calendar.timegm
|
||||
except AttributeError:
|
||||
def leapdays(year1, year2):
|
||||
"""Return number of leap years in range [year1, year2).
|
||||
Assume year1 <= year2."""
|
||||
year1 = year1 - 1
|
||||
year2 = year2 - 1
|
||||
return (year2/4 - year1/4) - (year2/100 -
|
||||
year1/100) + (year2/400 - year1/400)
|
||||
|
||||
EPOCH = 1970
|
||||
def timegm(tuple):
|
||||
"""Unrelated but handy function to calculate Unix timestamp from GMT."""
|
||||
year, month, day, hour, minute, second = tuple[:6]
|
||||
# assert year >= EPOCH
|
||||
# assert 1 <= month <= 12
|
||||
days = 365*(year-EPOCH) + leapdays(EPOCH, year)
|
||||
for i in range(1, month):
|
||||
days = days + calendar.mdays[i]
|
||||
if month > 2 and calendar.isleap(year):
|
||||
days = days + 1
|
||||
days = days + day - 1
|
||||
hours = days*24 + hour
|
||||
minutes = hours*60 + minute
|
||||
seconds = minutes*60 + second
|
||||
return seconds
|
||||
|
||||
#
|
||||
# tempfile.mkdtemp() is new to Python 2.3
|
||||
#
|
||||
try:
|
||||
mkdtemp = tempfile.mkdtemp
|
||||
except AttributeError:
|
||||
def mkdtemp(suffix="", prefix="tmp", dir=None):
|
||||
# mktemp() only took a single suffix argument until Python 2.3.
|
||||
# We'll do the best we can.
|
||||
oldtmpdir = os.environ.get('TMPDIR')
|
||||
try:
|
||||
for i in range(10):
|
||||
if dir:
|
||||
os.environ['TMPDIR'] = dir
|
||||
dir = tempfile.mktemp(suffix)
|
||||
if prefix:
|
||||
parent, base = os.path.split(dir)
|
||||
dir = os.path.join(parent, prefix + base)
|
||||
try:
|
||||
os.mkdir(dir, 0700)
|
||||
return dir
|
||||
except OSError, e:
|
||||
if e.errno == errno.EEXIST:
|
||||
continue # try again
|
||||
raise
|
||||
finally:
|
||||
if oldtmpdir:
|
||||
os.environ['TMPDIR'] = oldtmpdir
|
||||
elif os.environ.has_key('TMPDIR'):
|
||||
del(os.environ['TMPDIR'])
|
||||
|
||||
raise IOError, (errno.EEXIST, "No usable temporary directory name found")
|
||||
|
||||
#
|
||||
# the following stuff is *ONLY* needed for standalone.py.
|
||||
# For that reason I've encapsulated it into a function.
|
||||
#
|
||||
|
||||
def for_standalone():
|
||||
import SocketServer
|
||||
if not hasattr(SocketServer.TCPServer, "close_request"):
|
||||
#
|
||||
# method close_request() was missing until Python 2.1
|
||||
#
|
||||
class TCPServer(SocketServer.TCPServer):
|
||||
def process_request(self, request, client_address):
|
||||
"""Call finish_request.
|
||||
|
||||
Overridden by ForkingMixIn and ThreadingMixIn.
|
||||
|
||||
"""
|
||||
self.finish_request(request, client_address)
|
||||
self.close_request(request)
|
||||
|
||||
def close_request(self, request):
|
||||
"""Called to clean up an individual request."""
|
||||
request.close()
|
||||
|
||||
SocketServer.TCPServer = TCPServer
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
import sys
|
||||
import os
|
||||
import string
|
||||
import ConfigParser
|
||||
import fnmatch
|
||||
|
||||
|
@ -165,12 +164,12 @@ class Config:
|
|||
|
||||
for fname in self.general.kv_files:
|
||||
if fname[0] == '[':
|
||||
idx = string.index(fname, ']')
|
||||
parts = string.split(fname[1:idx], '.')
|
||||
fname = string.strip(fname[idx+1:])
|
||||
idx = fname.index(']')
|
||||
parts = fname[1:idx].split('.')
|
||||
fname = fname[idx+1:].strip()
|
||||
else:
|
||||
parts = [ ]
|
||||
fname = string.replace(fname, '%lang%', language)
|
||||
fname = fname.replace('%lang%', language)
|
||||
|
||||
parser = ConfigParser.ConfigParser()
|
||||
parser.optionxform = lambda x: x # don't case-normalize option names.
|
||||
|
@ -202,7 +201,7 @@ class Config:
|
|||
for opt in parser.options(section):
|
||||
value = parser.get(section, opt)
|
||||
if opt in self._force_multi_value:
|
||||
value = map(string.strip, filter(None, string.split(value, ',')))
|
||||
value = map(lambda x: x.strip(), filter(None, value.split(',')))
|
||||
else:
|
||||
try:
|
||||
value = int(value)
|
||||
|
@ -261,11 +260,11 @@ class Config:
|
|||
self._process_section(parser, section, base_section)
|
||||
|
||||
def _find_canon_vhost(self, parser, vhost):
|
||||
vhost = string.split(string.lower(vhost), ':')[0] # lower-case, no port
|
||||
vhost = vhost.lower().split(':')[0] # lower-case, no port
|
||||
for canon_vhost in parser.options('vhosts'):
|
||||
value = parser.get('vhosts', canon_vhost)
|
||||
patterns = map(string.lower, map(string.strip,
|
||||
filter(None, string.split(value, ','))))
|
||||
patterns = map(lambda x: x.lower().strip(),
|
||||
filter(None, value.split(',')))
|
||||
for pat in patterns:
|
||||
if fnmatch.fnmatchcase(vhost, pat):
|
||||
return canon_vhost
|
||||
|
@ -462,11 +461,11 @@ def _startswith(somestr, substr):
|
|||
def _parse_roots(config_name, config_value):
|
||||
roots = { }
|
||||
for root in config_value:
|
||||
pos = string.find(root, ':')
|
||||
if pos < 0:
|
||||
try:
|
||||
name, path = root.split(':', 1)
|
||||
except:
|
||||
raise MalformedRoot(config_name, root)
|
||||
name, path = map(string.strip, (root[:pos], root[pos+1:]))
|
||||
roots[name] = path
|
||||
roots[name.strip()] = path.strip()
|
||||
return roots
|
||||
|
||||
class ViewVCConfigurationError(Exception):
|
||||
|
@ -492,10 +491,3 @@ class MalformedRoot(ViewVCConfigurationError):
|
|||
|
||||
class _sub_config:
|
||||
pass
|
||||
|
||||
if not hasattr(sys, 'hexversion'):
|
||||
# Python 1.5 or 1.5.1. fix the syntax for ConfigParser options.
|
||||
import regex
|
||||
ConfigParser.option_cre = regex.compile('^\([-A-Za-z0-9._]+\)\(:\|['
|
||||
+ string.whitespace
|
||||
+ ']*=\)\(.*\)$')
|
||||
|
|
11
lib/cvsdb.py
11
lib/cvsdb.py
|
@ -12,7 +12,6 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
import string
|
||||
import time
|
||||
import fnmatch
|
||||
import re
|
||||
|
@ -361,7 +360,7 @@ class CheckinDatabase:
|
|||
|
||||
sqlList.append("%s%s%s" % (field, match, self.db.literal(data)))
|
||||
|
||||
return "(%s)" % (string.join(sqlList, " OR "))
|
||||
return "(%s)" % (" OR ".join(sqlList))
|
||||
|
||||
def CreateSQLQueryString(self, query):
|
||||
commits_table = self._version >= 1 and 'commits' or 'checkins'
|
||||
|
@ -440,8 +439,8 @@ class CheckinDatabase:
|
|||
tables.append(table)
|
||||
if cond is not None: joinConds.append(cond)
|
||||
|
||||
tables = string.join(tables, ",")
|
||||
conditions = string.join(joinConds + condList, " AND ")
|
||||
tables = ",".join(tables)
|
||||
conditions = " AND ".join(joinConds + condList)
|
||||
conditions = conditions and "WHERE %s" % conditions
|
||||
|
||||
## limit the number of rows requested or we could really slam
|
||||
|
@ -871,7 +870,7 @@ def ConnectDatabaseReadOnly(cfg):
|
|||
def GetCommitListFromRCSFile(repository, path_parts, revision=None):
|
||||
commit_list = []
|
||||
|
||||
directory = string.join(path_parts[:-1], "/")
|
||||
directory = "/".join(path_parts[:-1])
|
||||
file = path_parts[-1]
|
||||
|
||||
revs = repository.itemlog(path_parts, revision, vclib.SORTBY_DEFAULT,
|
||||
|
@ -888,7 +887,7 @@ def GetCommitListFromRCSFile(repository, path_parts, revision=None):
|
|||
|
||||
if rev.changed:
|
||||
# extract the plus/minus and drop the sign
|
||||
plus, minus = string.split(rev.changed)
|
||||
plus, minus = rev.changed.split()
|
||||
commit.SetPlusCount(plus[1:])
|
||||
commit.SetMinusCount(minus[1:])
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import sys
|
|||
import time
|
||||
import types
|
||||
import re
|
||||
import compat
|
||||
import calendar
|
||||
import MySQLdb
|
||||
|
||||
# set to 1 to store commit times in UTC, or 0 to use the ViewVC machine's
|
||||
|
@ -55,7 +55,7 @@ def TicksFromDateTime(datetime):
|
|||
t = datetime.tuple()
|
||||
|
||||
if utc_time:
|
||||
return compat.timegm(t)
|
||||
return calendar.timegm(t)
|
||||
else:
|
||||
return time.mktime(t[:8] + (-1,))
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import os
|
|||
import sys
|
||||
import sapi
|
||||
import threading
|
||||
import string
|
||||
|
||||
if sys.platform == "win32":
|
||||
import win32popen
|
||||
|
@ -36,7 +35,7 @@ def popen(cmd, args, mode, capture_err=1):
|
|||
if sys.platform == "win32":
|
||||
command = win32popen.CommandLine(cmd, args)
|
||||
|
||||
if string.find(mode, 'r') >= 0:
|
||||
if mode.find('r') >= 0:
|
||||
hStdIn = None
|
||||
|
||||
if debug.SHOW_CHILD_PROCESSES:
|
||||
|
@ -85,7 +84,7 @@ def popen(cmd, args, mode, capture_err=1):
|
|||
# in the parent
|
||||
|
||||
# close the descriptor that we don't need and return the other one.
|
||||
if string.find(mode, 'r') >= 0:
|
||||
if mode.find('r') >= 0:
|
||||
os.close(w)
|
||||
return _pipe(os.fdopen(r, mode), pid)
|
||||
os.close(r)
|
||||
|
@ -96,7 +95,7 @@ def popen(cmd, args, mode, capture_err=1):
|
|||
# we'll need /dev/null for the discarded I/O
|
||||
null = os.open('/dev/null', os.O_RDWR)
|
||||
|
||||
if string.find(mode, 'r') >= 0:
|
||||
if mode.find('r') >= 0:
|
||||
# hook stdout/stderr to the "write" channel
|
||||
os.dup2(w, 1)
|
||||
# "close" stdin; the child shouldn't use it
|
||||
|
@ -125,7 +124,7 @@ def popen(cmd, args, mode, capture_err=1):
|
|||
os.execvp(cmd, (cmd,) + tuple(args))
|
||||
except:
|
||||
# aid debugging, if the os.execvp above fails for some reason:
|
||||
print "<h2>exec failed:</h2><pre>", cmd, string.join(args), "</pre>"
|
||||
print "<h2>exec failed:</h2><pre>", cmd, ' '.join(args), "</pre>"
|
||||
raise
|
||||
|
||||
# crap. shouldn't be here.
|
||||
|
|
26
lib/query.py
26
lib/query.py
|
@ -47,7 +47,7 @@ class FormData:
|
|||
|
||||
def decode_thyself(self, form):
|
||||
try:
|
||||
self.repository = string.strip(form["repository"].value)
|
||||
self.repository = form["repository"].value.strip()
|
||||
except KeyError:
|
||||
pass
|
||||
except TypeError:
|
||||
|
@ -56,7 +56,7 @@ class FormData:
|
|||
self.valid = 1
|
||||
|
||||
try:
|
||||
self.branch = string.strip(form["branch"].value)
|
||||
self.branch = form["branch"].value.strip()
|
||||
except KeyError:
|
||||
pass
|
||||
except TypeError:
|
||||
|
@ -65,7 +65,7 @@ class FormData:
|
|||
self.valid = 1
|
||||
|
||||
try:
|
||||
self.directory = string.strip(form["directory"].value)
|
||||
self.directory = form["directory"].value.strip()
|
||||
except KeyError:
|
||||
pass
|
||||
except TypeError:
|
||||
|
@ -74,7 +74,7 @@ class FormData:
|
|||
self.valid = 1
|
||||
|
||||
try:
|
||||
self.file = string.strip(form["file"].value)
|
||||
self.file = form["file"].value.strip()
|
||||
except KeyError:
|
||||
pass
|
||||
except TypeError:
|
||||
|
@ -83,7 +83,7 @@ class FormData:
|
|||
self.valid = 1
|
||||
|
||||
try:
|
||||
self.who = string.strip(form["who"].value)
|
||||
self.who = form["who"].value.strip()
|
||||
except KeyError:
|
||||
pass
|
||||
except TypeError:
|
||||
|
@ -92,14 +92,14 @@ class FormData:
|
|||
self.valid = 1
|
||||
|
||||
try:
|
||||
self.sortby = string.strip(form["sortby"].value)
|
||||
self.sortby = form["sortby"].value.strip()
|
||||
except KeyError:
|
||||
pass
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
try:
|
||||
self.date = string.strip(form["date"].value)
|
||||
self.date = form["date"].value.strip()
|
||||
except KeyError:
|
||||
pass
|
||||
except TypeError:
|
||||
|
@ -158,7 +158,7 @@ def listparse_string(str):
|
|||
## command; add the command and start over
|
||||
elif c == ",":
|
||||
## strip ending whitespace on un-quoted data
|
||||
temp = string.rstrip(temp)
|
||||
temp = temp.rstrip()
|
||||
return_list.append( ("", temp) )
|
||||
temp = ""
|
||||
state = "eat leading whitespace"
|
||||
|
@ -266,13 +266,13 @@ def form_to_cvsdb_query(form_data):
|
|||
|
||||
def prev_rev(rev):
|
||||
'''Returns a string representing the previous revision of the argument.'''
|
||||
r = string.split(rev, '.')
|
||||
r = rev.split('.')
|
||||
# decrement final revision component
|
||||
r[-1] = str(int(r[-1]) - 1)
|
||||
# prune if we pass the beginning of the branch
|
||||
if len(r) > 2 and r[-1] == '0':
|
||||
r = r[:-2]
|
||||
return string.join(r, '.')
|
||||
return '.'.join(r)
|
||||
|
||||
def is_forbidden(cfg, cvsroot_name, module):
|
||||
'''Return 1 if MODULE in CVSROOT_NAME is forbidden; return 0 otherwise.'''
|
||||
|
@ -299,7 +299,7 @@ def is_forbidden(cfg, cvsroot_name, module):
|
|||
"by this interface. The '%s' root is configured to "
|
||||
"use a different one." % (cvsroot_name))
|
||||
forbidden = params.get('forbidden', '')
|
||||
forbidden = map(string.strip, filter(None, string.split(forbidden, ',')))
|
||||
forbidden = map(lambda x: x.strip(), filter(None, forbidden.split(',')))
|
||||
default = 0
|
||||
for pat in forbidden:
|
||||
if pat[0] == '!':
|
||||
|
@ -314,7 +314,7 @@ def build_commit(server, cfg, desc, files, cvsroots, viewvc_link):
|
|||
ob = _item(num_files=len(files), files=[])
|
||||
|
||||
if desc:
|
||||
ob.log = string.replace(server.escape(desc), '\n', '<br />')
|
||||
ob.log = server.escape(desc).replace('\n', '<br />')
|
||||
else:
|
||||
ob.log = ' '
|
||||
|
||||
|
@ -325,7 +325,7 @@ def build_commit(server, cfg, desc, files, cvsroots, viewvc_link):
|
|||
|
||||
## find the module name (if any)
|
||||
try:
|
||||
module = filter(None, string.split(directory, '/'))[0]
|
||||
module = filter(None, directory.split('/'))[0]
|
||||
except IndexError:
|
||||
module = None
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
# -----------------------------------------------------------------------
|
||||
|
||||
import types
|
||||
import string
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
|
@ -34,10 +33,10 @@ server = None
|
|||
# into HTML attributes.
|
||||
def escape(s):
|
||||
s = str(s)
|
||||
s = string.replace(s, '&', '&')
|
||||
s = string.replace(s, '>', '>')
|
||||
s = string.replace(s, '<', '<')
|
||||
s = string.replace(s, '"', """)
|
||||
s = s.replace('&', '&')
|
||||
s = s.replace('>', '>')
|
||||
s = s.replace('<', '<')
|
||||
s = s.replace('"', """)
|
||||
return s
|
||||
|
||||
|
||||
|
|
|
@ -12,10 +12,6 @@
|
|||
|
||||
"""Generic API for implementing authorization checks employed by ViewVC."""
|
||||
|
||||
import string
|
||||
import vclib
|
||||
|
||||
|
||||
class GenericViewVCAuthorizer:
|
||||
"""Abstract class encapsulating version control authorization routines."""
|
||||
|
||||
|
|
|
@ -12,14 +12,13 @@
|
|||
import vcauth
|
||||
import vclib
|
||||
import fnmatch
|
||||
import string
|
||||
|
||||
class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer):
|
||||
"""A simple top-level module authorizer."""
|
||||
def __init__(self, username, params={}):
|
||||
forbidden = params.get('forbidden', '')
|
||||
self.forbidden = map(string.strip,
|
||||
filter(None, string.split(forbidden, ',')))
|
||||
self.forbidden = map(lambda x: x.strip(),
|
||||
filter(None, forbidden.split(',')))
|
||||
|
||||
def check_root_access(self, rootname):
|
||||
return 1
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
import vcauth
|
||||
import vclib
|
||||
import fnmatch
|
||||
import string
|
||||
import re
|
||||
|
||||
|
||||
|
@ -29,8 +28,8 @@ class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer):
|
|||
"""A simple regular-expression-based authorizer."""
|
||||
def __init__(self, username, params={}):
|
||||
forbidden = params.get('forbiddenre', '')
|
||||
self.forbidden = map(lambda x: _split_regexp(string.strip(x)),
|
||||
filter(None, string.split(forbidden, ',')))
|
||||
self.forbidden = map(lambda x: _split_regexp(x.strip()),
|
||||
filter(None, forbidden.split(',')))
|
||||
|
||||
def _check_root_path_access(self, root_path):
|
||||
default = 1
|
||||
|
@ -49,7 +48,7 @@ class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer):
|
|||
def check_path_access(self, rootname, path_parts, pathtype, rev=None):
|
||||
root_path = rootname
|
||||
if path_parts:
|
||||
root_path = root_path + '/' + string.join(path_parts, '/')
|
||||
root_path = root_path + '/' + '/'.join(path_parts)
|
||||
if pathtype == vclib.DIR:
|
||||
root_path = root_path + '/'
|
||||
else:
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# (c) 2006 Sergey Lapin <slapin@dataart.com>
|
||||
|
||||
import vcauth
|
||||
import string
|
||||
import os.path
|
||||
import debug
|
||||
|
||||
|
@ -94,9 +93,9 @@ class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer):
|
|||
all_groups.append(groupname)
|
||||
group_member = 0
|
||||
groupname = groupname.strip()
|
||||
entries = string.split(cp.get('groups', groupname), ',')
|
||||
entries = cp.get('groups', groupname).split(',')
|
||||
for entry in entries:
|
||||
entry = string.strip(entry)
|
||||
entry = entry.strip()
|
||||
if entry == self.username:
|
||||
group_member = 1
|
||||
break
|
||||
|
@ -137,13 +136,13 @@ class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer):
|
|||
# Figure if this path is explicitly allowed or denied to USERNAME.
|
||||
allow = deny = 0
|
||||
for user in cp.options(section):
|
||||
user = string.strip(user)
|
||||
user = user.strip()
|
||||
if _userspec_matches_user(user):
|
||||
# See if the 'r' permission is among the ones granted to
|
||||
# USER. If so, we can stop looking. (Entry order is not
|
||||
# relevant -- we'll use the most permissive entry, meaning
|
||||
# one 'allow' is all we need.)
|
||||
allow = string.find(cp.get(section, user), 'r') != -1
|
||||
allow = cp.get(section, user).find('r') != -1
|
||||
deny = not allow
|
||||
if allow:
|
||||
break
|
||||
|
@ -172,7 +171,7 @@ class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer):
|
|||
if section.find(':') == -1:
|
||||
path = section
|
||||
else:
|
||||
name, path = string.split(section, ':', 1)
|
||||
name, path = section.split(':', 1)
|
||||
if name == rootname:
|
||||
root_sections.append(section)
|
||||
continue
|
||||
|
@ -184,14 +183,14 @@ class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer):
|
|||
# USERNAME, record it.
|
||||
if allow or deny:
|
||||
if path != '/':
|
||||
path = '/' + string.join(filter(None, string.split(path, '/')), '/')
|
||||
path = '/' + '/'.join(filter(None, path.split('/')))
|
||||
paths_for_root[path] = allow
|
||||
|
||||
# Okay. Superimpose those root-specific values now.
|
||||
for section in root_sections:
|
||||
|
||||
# Get the path again.
|
||||
name, path = string.split(section, ':', 1)
|
||||
name, path = section.split(':', 1)
|
||||
|
||||
# Check for a specific access determination.
|
||||
allow, deny = _process_access_section(section)
|
||||
|
@ -200,7 +199,7 @@ class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer):
|
|||
# USERNAME, record it.
|
||||
if allow or deny:
|
||||
if path != '/':
|
||||
path = '/' + string.join(filter(None, string.split(path, '/')), '/')
|
||||
path = '/' + '/'.join(filter(None, path.split('/')))
|
||||
paths_for_root[path] = allow
|
||||
|
||||
# If the root isn't readable, there's no point in caring about all
|
||||
|
@ -230,7 +229,7 @@ class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer):
|
|||
return 0
|
||||
parts = path_parts[:]
|
||||
while parts:
|
||||
path = '/' + string.join(parts, '/')
|
||||
path = '/' + '/'.join(parts)
|
||||
if paths.has_key(path):
|
||||
return paths[path]
|
||||
del parts[-1]
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
such as CVS.
|
||||
"""
|
||||
|
||||
import string
|
||||
import types
|
||||
|
||||
|
||||
|
@ -304,7 +303,7 @@ class ItemNotFound(Error):
|
|||
# use '/' rather than os.sep because this is for user consumption, and
|
||||
# it was defined using URL separators
|
||||
if type(path) in (types.TupleType, types.ListType):
|
||||
path = string.join(path, '/')
|
||||
path = '/'.join(path)
|
||||
Error.__init__(self, path)
|
||||
|
||||
class InvalidRevision(Error):
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
# -----------------------------------------------------------------------
|
||||
import os
|
||||
import os.path
|
||||
import time
|
||||
|
||||
|
||||
def cvs_strptime(timestr):
|
||||
return time.strptime(timestr, '%Y/%m/%d %H:%M:%S')[:-1] + (0,)
|
||||
|
||||
|
||||
def canonicalize_rootpath(rootpath):
|
||||
|
|
|
@ -18,14 +18,17 @@ import os
|
|||
import os.path
|
||||
import sys
|
||||
import stat
|
||||
import string
|
||||
import re
|
||||
import time
|
||||
import calendar
|
||||
|
||||
# ViewVC libs
|
||||
import compat
|
||||
import popen
|
||||
import vclib.ccvs
|
||||
|
||||
def _path_join(parts):
|
||||
return '/'.join(path_parts)
|
||||
|
||||
class BaseCVSRepository(vclib.Repository):
|
||||
def __init__(self, name, rootpath, authorizer, utilities):
|
||||
if not os.path.isdir(rootpath):
|
||||
|
@ -76,7 +79,7 @@ class BaseCVSRepository(vclib.Repository):
|
|||
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."
|
||||
% (string.join(path_parts, "/")))
|
||||
% (_path_join(path_parts)))
|
||||
|
||||
# Only RCS files (*,v) and subdirs are returned.
|
||||
data = [ ]
|
||||
|
@ -133,15 +136,14 @@ class BaseCVSRepository(vclib.Repository):
|
|||
if root:
|
||||
ret = ret_file
|
||||
else:
|
||||
ret = string.join(ret_parts, "/")
|
||||
ret = _path_join(ret_parts)
|
||||
if v:
|
||||
ret = ret + ",v"
|
||||
return ret
|
||||
|
||||
def isexecutable(self, path_parts, rev):
|
||||
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts, "/")))
|
||||
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)
|
||||
|
||||
|
@ -164,8 +166,7 @@ class BinCVSRepository(BaseCVSRepository):
|
|||
|
||||
def openfile(self, path_parts, rev):
|
||||
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts, "/")))
|
||||
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:
|
||||
|
@ -237,7 +238,7 @@ class BinCVSRepository(BaseCVSRepository):
|
|||
"""
|
||||
if self.itemtype(path_parts, rev) != vclib.DIR: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a directory."
|
||||
% (string.join(path_parts, "/")))
|
||||
% (_path_join(path_parts)))
|
||||
|
||||
subdirs = options.get('cvs_subdirs', 0)
|
||||
entries_to_fetch = []
|
||||
|
@ -274,8 +275,7 @@ class BinCVSRepository(BaseCVSRepository):
|
|||
"""
|
||||
|
||||
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts, "/")))
|
||||
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
|
||||
|
||||
# Invoke rlog
|
||||
rcsfile = self.rcsfile(path_parts, 1)
|
||||
|
@ -320,8 +320,7 @@ class BinCVSRepository(BaseCVSRepository):
|
|||
|
||||
def annotate(self, path_parts, rev=None):
|
||||
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts, "/")))
|
||||
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)
|
||||
|
@ -338,11 +337,9 @@ class BinCVSRepository(BaseCVSRepository):
|
|||
ignore_keyword_subst - boolean, ignore keyword substitution
|
||||
"""
|
||||
if self.itemtype(path_parts1, rev1) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts1, "/")))
|
||||
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts1)))
|
||||
if self.itemtype(path_parts2, rev2) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts2, "/")))
|
||||
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):
|
||||
|
@ -550,7 +547,7 @@ def _remove_tag(tag):
|
|||
|
||||
def _revision_tuple(revision_string):
|
||||
"""convert a revision number into a tuple of integers"""
|
||||
t = tuple(map(int, string.split(revision_string, '.')))
|
||||
t = tuple(map(int, revision_string.split('.')))
|
||||
if len(t) % 2 == 0:
|
||||
return t
|
||||
raise ValueError
|
||||
|
@ -558,7 +555,7 @@ def _revision_tuple(revision_string):
|
|||
def _tag_tuple(revision_string):
|
||||
"""convert a revision number or branch number into a tuple of integers"""
|
||||
if revision_string:
|
||||
t = map(int, string.split(revision_string, '.'))
|
||||
t = map(int, revision_string.split('.'))
|
||||
l = len(t)
|
||||
if l == 1:
|
||||
return ()
|
||||
|
@ -703,7 +700,7 @@ def _parse_log_header(fp):
|
|||
|
||||
if state == 1:
|
||||
if line[0] == '\t':
|
||||
[ tag, rev ] = map(string.strip, string.split(line, ':'))
|
||||
[ tag, rev ] = map(lambda x: x.strip(), line.split(':'))
|
||||
taginfo[tag] = rev
|
||||
else:
|
||||
# oops. this line isn't tag info. stop parsing tags.
|
||||
|
@ -711,7 +708,7 @@ def _parse_log_header(fp):
|
|||
|
||||
if state == 2:
|
||||
if line[0] == '\t':
|
||||
[ locker, rev ] = map(string.strip, string.split(line, ':'))
|
||||
[ locker, rev ] = map(lambda x: x.strip(), line.split(':'))
|
||||
lockinfo[rev] = locker
|
||||
else:
|
||||
# oops. this line isn't lock info. stop parsing tags.
|
||||
|
@ -820,7 +817,7 @@ def _parse_log_entry(fp):
|
|||
return None, eof
|
||||
|
||||
# parse out a time tuple for the local time
|
||||
tm = compat.cvs_strptime(match.group(1))
|
||||
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").
|
||||
|
@ -831,7 +828,7 @@ def _parse_log_entry(fp):
|
|||
tm[0] = tm[0] + 100
|
||||
if tm[0] < EPOCH:
|
||||
raise ValueError, 'invalid year'
|
||||
date = compat.timegm(tm)
|
||||
date = calendar.timegm(tm)
|
||||
|
||||
return Revision(rev, date,
|
||||
# author, state, lines changed
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
import string
|
||||
import re
|
||||
import time
|
||||
import math
|
||||
|
@ -100,7 +99,7 @@ class CVSParser(rcsparse.Sink):
|
|||
|
||||
# Split deltatext specified by rev to each line.
|
||||
def deltatext_split(self, rev):
|
||||
lines = string.split(self.revision_deltatext[rev], '\n')
|
||||
lines = self.revision_deltatext[rev].split('\n')
|
||||
if lines[-1] == '':
|
||||
del lines[-1]
|
||||
return lines
|
||||
|
@ -139,16 +138,16 @@ class CVSParser(rcsparse.Sink):
|
|||
adjust = adjust + 1
|
||||
elif dmatch:
|
||||
# "d" - Delete command
|
||||
start_line = string.atoi(dmatch.group(1))
|
||||
count = string.atoi(dmatch.group(2))
|
||||
start_line = int(dmatch.group(1))
|
||||
count = int(dmatch.group(2))
|
||||
begin = start_line + adjust - 1
|
||||
del text[begin:begin + count]
|
||||
adjust = adjust - count
|
||||
lines_removed_now = lines_removed_now + count
|
||||
elif amatch:
|
||||
# "a" - Add command
|
||||
start_line = string.atoi(amatch.group(1))
|
||||
count = string.atoi(amatch.group(2))
|
||||
start_line = int(amatch.group(1))
|
||||
count = iht(amatch.group(2))
|
||||
add_lines_remaining = count
|
||||
lines_added_now = lines_added_now + count
|
||||
else:
|
||||
|
@ -311,13 +310,13 @@ class CVSParser(rcsparse.Sink):
|
|||
skip = skip - 1
|
||||
elif dmatch:
|
||||
# "d" - Delete command
|
||||
start_line = string.atoi(dmatch.group(1))
|
||||
count = string.atoi(dmatch.group(2))
|
||||
start_line = int(dmatch.group(1))
|
||||
count = int(dmatch.group(2))
|
||||
line_count = line_count - count
|
||||
elif amatch:
|
||||
# "a" - Add command
|
||||
start_line = string.atoi(amatch.group(1))
|
||||
count = string.atoi(amatch.group(2))
|
||||
start_line = int(amatch.group(1))
|
||||
count = int(amatch.group(2))
|
||||
skip = count
|
||||
line_count = line_count + count
|
||||
else:
|
||||
|
@ -359,8 +358,8 @@ class CVSParser(rcsparse.Sink):
|
|||
dmatch = self.d_command.match(command)
|
||||
amatch = self.a_command.match(command)
|
||||
if dmatch:
|
||||
start_line = string.atoi(dmatch.group(1))
|
||||
count = string.atoi(dmatch.group(2))
|
||||
start_line = int(dmatch.group(1))
|
||||
count = int(dmatch.group(2))
|
||||
temp = []
|
||||
while count > 0:
|
||||
temp.append(revision)
|
||||
|
@ -368,8 +367,8 @@ class CVSParser(rcsparse.Sink):
|
|||
self.revision_map = (self.revision_map[:start_line - 1] +
|
||||
temp + self.revision_map[start_line - 1:])
|
||||
elif amatch:
|
||||
start_line = string.atoi(amatch.group(1))
|
||||
count = string.atoi(amatch.group(2))
|
||||
start_line = int(amatch.group(1))
|
||||
count = int(amatch.group(2))
|
||||
del self.revision_map[start_line:start_line + count]
|
||||
skip = count
|
||||
else:
|
||||
|
@ -388,15 +387,15 @@ class CVSParser(rcsparse.Sink):
|
|||
dmatch = self.d_command.match(command)
|
||||
amatch = self.a_command.match(command)
|
||||
if dmatch:
|
||||
start_line = string.atoi(dmatch.group(1))
|
||||
count = string.atoi(dmatch.group(2))
|
||||
start_line = int(dmatch.group(1))
|
||||
count = int(dmatch.group(2))
|
||||
adj_begin = start_line + adjust - 1
|
||||
adj_end = start_line + adjust - 1 + count
|
||||
del self.revision_map[adj_begin:adj_end]
|
||||
adjust = adjust - count
|
||||
elif amatch:
|
||||
start_line = string.atoi(amatch.group(1))
|
||||
count = string.atoi(amatch.group(2))
|
||||
start_line = int(amatch.group(1))
|
||||
count = int(amatch.group(2))
|
||||
skip = count
|
||||
temp = []
|
||||
while count > 0:
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
# -----------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import string
|
||||
import re
|
||||
import cStringIO
|
||||
import tempfile
|
||||
|
@ -22,7 +21,8 @@ import blame
|
|||
|
||||
### The functionality shared with bincvs should probably be moved to a
|
||||
### separate module
|
||||
from bincvs import BaseCVSRepository, Revision, Tag, _file_log, _log_path, _logsort_date_cmp, _logsort_rev_cmp
|
||||
from bincvs import BaseCVSRepository, Revision, Tag, _file_log, _log_path, _logsort_date_cmp, _logsort_rev_cmp, _path_join
|
||||
|
||||
|
||||
class CCVSRepository(BaseCVSRepository):
|
||||
def dirlogs(self, path_parts, rev, entries, options):
|
||||
|
@ -44,7 +44,7 @@ class CCVSRepository(BaseCVSRepository):
|
|||
"""
|
||||
if self.itemtype(path_parts, rev) != vclib.DIR: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a directory."
|
||||
% (string.join(path_parts, "/")))
|
||||
% (part2path(path_parts)))
|
||||
entries_to_fetch = []
|
||||
for entry in entries:
|
||||
if vclib.check_path_access(self, path_parts + [entry.name], None, rev):
|
||||
|
@ -94,8 +94,7 @@ class CCVSRepository(BaseCVSRepository):
|
|||
dictionary of Tag objects for all tags encountered
|
||||
"""
|
||||
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts, "/")))
|
||||
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
|
||||
|
||||
path = self.rcsfile(path_parts, 1)
|
||||
sink = TreeSink()
|
||||
|
@ -120,11 +119,9 @@ class CCVSRepository(BaseCVSRepository):
|
|||
|
||||
def rawdiff(self, path_parts1, rev1, path_parts2, rev2, type, options={}):
|
||||
if self.itemtype(path_parts1, rev1) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts1, "/")))
|
||||
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts1)))
|
||||
if self.itemtype(path_parts2, rev2) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts2, "/")))
|
||||
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts2)))
|
||||
|
||||
temp1 = tempfile.mktemp()
|
||||
open(temp1, 'wb').write(self.openfile(path_parts1, rev1)[0].getvalue())
|
||||
|
@ -144,8 +141,7 @@ class CCVSRepository(BaseCVSRepository):
|
|||
|
||||
def annotate(self, path_parts, rev=None):
|
||||
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts, "/")))
|
||||
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
|
||||
source = blame.BlameSource(self.rcsfile(path_parts, 1), rev)
|
||||
return source, source.revision
|
||||
|
||||
|
@ -154,13 +150,12 @@ class CCVSRepository(BaseCVSRepository):
|
|||
|
||||
def openfile(self, path_parts, rev=None):
|
||||
if self.itemtype(path_parts, rev) != vclib.FILE: # does auth-check
|
||||
raise vclib.Error("Path '%s' is not a file."
|
||||
% (string.join(path_parts, "/")))
|
||||
raise vclib.Error("Path '%s' is not a file." % (_path_join(path_parts)))
|
||||
path = self.rcsfile(path_parts, 1)
|
||||
sink = COSink(rev)
|
||||
rcsparse.parse(open(path, 'rb'), sink)
|
||||
revision = sink.last and sink.last.string
|
||||
return cStringIO.StringIO(string.join(sink.sstext.text, "\n")), revision
|
||||
return cStringIO.StringIO('\n'.join(sink.sstext.text)), revision
|
||||
|
||||
class MatchingSink(rcsparse.Sink):
|
||||
"""Superclass for sinks that search for revisions based on tag or number"""
|
||||
|
|
|
@ -24,12 +24,12 @@ debug.t_start('imports')
|
|||
# standard modules that we know are in the path or builtin
|
||||
import sys
|
||||
import os
|
||||
import calendar
|
||||
import gzip
|
||||
import mimetypes
|
||||
import re
|
||||
import rfc822
|
||||
import stat
|
||||
import string
|
||||
import struct
|
||||
import tempfile
|
||||
import time
|
||||
|
@ -38,7 +38,6 @@ import urllib
|
|||
|
||||
# These modules come from our library (the stub has set up the path)
|
||||
import accept
|
||||
import compat
|
||||
import config
|
||||
import ezt
|
||||
import popen
|
||||
|
@ -120,8 +119,8 @@ class Request:
|
|||
if cfg.options.allow_compress:
|
||||
http_accept_encoding = os.environ.get("HTTP_ACCEPT_ENCODING", "")
|
||||
if "gzip" in filter(None,
|
||||
map(lambda x: string.strip(x),
|
||||
string.split(http_accept_encoding, ","))):
|
||||
map(lambda x: x.strip(),
|
||||
http_accept_encoding.split(','))):
|
||||
self.gzip_compress_level = 9 # make this configurable?
|
||||
|
||||
def run_viewvc(self):
|
||||
|
@ -404,7 +403,7 @@ class Request:
|
|||
server name portions of the URL."""
|
||||
|
||||
url, params = apply(self.get_link, (), args)
|
||||
qs = compat.urlencode(params)
|
||||
qs = urllib.urlencode(params)
|
||||
if qs:
|
||||
result = urllib.quote(url, _URL_SAFE_CHARS) + '?' + qs
|
||||
else:
|
||||
|
@ -580,7 +579,7 @@ def _path_parts(path):
|
|||
"""Split up a repository path into a list of path components"""
|
||||
# clean it up. this removes duplicate '/' characters and any that may
|
||||
# exist at the front or end of the path.
|
||||
return filter(None, string.split(path, '/'))
|
||||
return filter(None, path.split('/'))
|
||||
|
||||
def _normalize_path(path):
|
||||
"""Collapse leading slashes in the script name
|
||||
|
@ -730,7 +729,7 @@ _legal_params = {
|
|||
}
|
||||
|
||||
def _path_join(path_parts):
|
||||
return string.join(path_parts, '/')
|
||||
return '/'.join(path_parts)
|
||||
|
||||
def _strip_suffix(suffix, path_parts, rev, pathtype, repos, view_func):
|
||||
"""strip the suffix from a repository path if the resulting path
|
||||
|
@ -868,7 +867,7 @@ def check_freshness(request, mtime=None, etag=None, weak=0):
|
|||
|
||||
# require revalidation after the configured amount of time
|
||||
if cfg and cfg.options.http_expiration_time >= 0:
|
||||
expiration = compat.formatdate(time.time() +
|
||||
expiration = rfc822.formatdate(time.time() +
|
||||
cfg.options.http_expiration_time)
|
||||
request.server.addheader('Expires', expiration)
|
||||
request.server.addheader('Cache-Control',
|
||||
|
@ -880,7 +879,7 @@ def check_freshness(request, mtime=None, etag=None, weak=0):
|
|||
if etag is not None:
|
||||
request.server.addheader('ETag', etag)
|
||||
if mtime is not None:
|
||||
request.server.addheader('Last-Modified', compat.formatdate(mtime))
|
||||
request.server.addheader('Last-Modified', rfc822.formatdate(mtime))
|
||||
return isfresh
|
||||
|
||||
def get_view_template(cfg, view_name, language="en"):
|
||||
|
@ -893,7 +892,7 @@ def get_view_template(cfg, view_name, language="en"):
|
|||
tname = os.path.join(cfg.options.template_dir or "templates", tname)
|
||||
|
||||
# Allow per-language template selection.
|
||||
tname = string.replace(tname, '%lang%', language)
|
||||
tname = tname.replace('%lang%', language)
|
||||
|
||||
# Finally, construct the whole template path.
|
||||
tname = cfg.path(tname)
|
||||
|
@ -975,7 +974,7 @@ def nav_path(request):
|
|||
|
||||
def prep_tags(request, tags):
|
||||
url, params = request.get_link(params={'pathrev': None})
|
||||
params = compat.urlencode(params)
|
||||
params = urllib.urlencode(params)
|
||||
if params:
|
||||
url = urllib.quote(url, _URL_SAFE_CHARS) + '?' + params + '&pathrev='
|
||||
else:
|
||||
|
@ -1206,7 +1205,7 @@ class ViewVCHtmlFormatter:
|
|||
return out, out_len, 0
|
||||
|
||||
def _entity_encode(self, s):
|
||||
return string.join(map(lambda x: '&#%d;' % (ord(x)), s), '')
|
||||
return ''.join(map(lambda x: '&#%d;' % (ord(x)), s))
|
||||
|
||||
def _tokenize_text(self, s):
|
||||
tokens = []
|
||||
|
@ -1558,7 +1557,7 @@ def markup_stream_pygments(request, cfg, blame_data, fp, filename,
|
|||
self.tabsize = cfg.options.tabsize
|
||||
def __getitem__(self, idx):
|
||||
item = self.blame_source.__getitem__(idx)
|
||||
item.text = string.expandtabs(item.text, self.tabsize)
|
||||
item.text = item.text.expandtabs(self.tabsize)
|
||||
return item
|
||||
return BlameSourceTabsizeWrapper(blame_source, cfg.options.tabsize)
|
||||
else:
|
||||
|
@ -1569,7 +1568,7 @@ def markup_stream_pygments(request, cfg, blame_data, fp, filename,
|
|||
if not line:
|
||||
break
|
||||
line_no = line_no + 1
|
||||
line = sapi.escape(string.expandtabs(line, cfg.options.tabsize))
|
||||
line = sapi.escape(line.expandtabs(cfg.options.tabsize))
|
||||
item = vclib.Annotation(line, line_no, None, None, None, None)
|
||||
item.diff_href = None
|
||||
lines.append(item)
|
||||
|
@ -1627,7 +1626,7 @@ def make_rss_time_string(date, cfg):
|
|||
return time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime(date)) + ' UTC'
|
||||
|
||||
def make_comma_sep_list_string(items):
|
||||
return string.join(map(lambda x: x.name, items), ', ')
|
||||
return ', '.join(map(lambda x: x.name, items))
|
||||
|
||||
def get_itemprops(request, path_parts, rev):
|
||||
itemprops = request.repos.itemprops(path_parts, rev)
|
||||
|
@ -1652,11 +1651,11 @@ def get_itemprops(request, path_parts, rev):
|
|||
return props
|
||||
|
||||
def parse_mime_type(mime_type):
|
||||
mime_parts = map(lambda x: x.strip(), string.split(mime_type, ';'))
|
||||
mime_parts = map(lambda x: x.strip(), mime_type.split(';'))
|
||||
type_subtype = mime_parts[0].lower()
|
||||
parameters = {}
|
||||
for part in mime_parts[1:]:
|
||||
name, value = string.split(part, '=', 1)
|
||||
name, value = part.split('=', 1)
|
||||
parameters[name] = value
|
||||
return type_subtype, parameters
|
||||
|
||||
|
@ -1794,8 +1793,8 @@ def view_annotate(request):
|
|||
markup_or_annotate(request, 1)
|
||||
|
||||
def revcmp(rev1, rev2):
|
||||
rev1 = map(int, string.split(rev1, '.'))
|
||||
rev2 = map(int, string.split(rev2, '.'))
|
||||
rev1 = map(int, rev1.split('.'))
|
||||
rev2 = map(int, rev2.split('.'))
|
||||
return cmp(rev1, rev2)
|
||||
|
||||
def sort_file_data(file_data, roottype, sortdir, sortby, group_dirs):
|
||||
|
@ -1847,7 +1846,7 @@ def sort_file_data(file_data, roottype, sortdir, sortby, group_dirs):
|
|||
|
||||
def icmp(x, y):
|
||||
"""case insensitive comparison"""
|
||||
return cmp(string.lower(x), string.lower(y))
|
||||
return cmp(x.lower(), y.lower())
|
||||
|
||||
def view_roots(request):
|
||||
if 'roots' not in request.cfg.options.allowed_views:
|
||||
|
@ -2816,10 +2815,10 @@ def rcsdiff_date_reformat(date_str, cfg):
|
|||
if date_str is None:
|
||||
return None
|
||||
try:
|
||||
date = compat.cvs_strptime(date_str)
|
||||
date = vclib.ccvs.cvs_strptime(date_str)
|
||||
except ValueError:
|
||||
return date_str
|
||||
return make_time_string(compat.timegm(date), cfg)
|
||||
return make_time_string(calendar.timegm(date), cfg)
|
||||
|
||||
_re_extract_rev = re.compile(r'^[-+*]{3} [^\t]+\t([^\t]+)\t((\d+\.)*\d+)$')
|
||||
_re_extract_info = re.compile(r'@@ \-([0-9]+).*\+([0-9]+).*@@(.*)')
|
||||
|
@ -2858,7 +2857,7 @@ class DiffSource:
|
|||
return item
|
||||
|
||||
def _format_text(self, text):
|
||||
text = string.expandtabs(string.rstrip(text), self.cfg.options.tabsize)
|
||||
text = text.rstrip().expandtabs(self.cfg.options.tabsize)
|
||||
hr_breakable = self.cfg.options.hr_breakable
|
||||
|
||||
# in the code below, "\x01" will be our stand-in for "&". We don't want
|
||||
|
@ -2869,13 +2868,12 @@ class DiffSource:
|
|||
text = re.sub('(' + ('.' * hr_breakable) + ')', '\\1\x02', text)
|
||||
if hr_breakable:
|
||||
# make every other space "breakable"
|
||||
text = string.replace(text, ' ', ' \x01nbsp;')
|
||||
text = text.replace(' ', ' \x01nbsp;')
|
||||
else:
|
||||
text = string.replace(text, ' ', '\x01nbsp;')
|
||||
text = text.replace(' ', '\x01nbsp;')
|
||||
text = sapi.escape(text)
|
||||
text = string.replace(text, '\x01', '&')
|
||||
text = string.replace(text, '\x02',
|
||||
'<span style="color:red">\</span><br />')
|
||||
text = text.replace('\x01', '&')
|
||||
text = text.replace('\x02', '<span style="color:red">\</span><br />')
|
||||
return text
|
||||
|
||||
def _get_row(self):
|
||||
|
@ -3026,8 +3024,8 @@ def diff_parse_headers(fp, diff_type, rev1, rev2, sym1=None, sym2=None):
|
|||
elif line[:3] == 'Bin':
|
||||
flag = _RCSDIFF_IS_BINARY
|
||||
parsing = 0
|
||||
elif (string.find(line, 'not found') != -1 or
|
||||
string.find(line, 'illegal option') != -1):
|
||||
elif (line.find('not found') != -1 or
|
||||
line.find('illegal option') != -1):
|
||||
flag = _RCSDIFF_ERROR
|
||||
parsing = 0
|
||||
header_lines.append(line)
|
||||
|
@ -3041,7 +3039,7 @@ def diff_parse_headers(fp, diff_type, rev1, rev2, sym1=None, sym2=None):
|
|||
'revision %s' % (log_rev2, rev2),
|
||||
'500 Internal Server Error')
|
||||
|
||||
return date1, date2, flag, string.join(header_lines, '')
|
||||
return date1, date2, flag, ''.join(header_lines)
|
||||
|
||||
|
||||
def _get_diff_path_parts(request, query_key, rev, base_rev):
|
||||
|
@ -3078,7 +3076,7 @@ def setup_diff(request):
|
|||
raise debug.ViewVCException('Missing revision from the diff '
|
||||
'form text field', '400 Bad Request')
|
||||
else:
|
||||
idx = string.find(r1, ':')
|
||||
idx = r1.find(':')
|
||||
if idx == -1:
|
||||
rev1 = r1
|
||||
else:
|
||||
|
@ -3092,7 +3090,7 @@ def setup_diff(request):
|
|||
'form text field', '400 Bad Request')
|
||||
sym2 = ''
|
||||
else:
|
||||
idx = string.find(r2, ':')
|
||||
idx = r2.find(':')
|
||||
if idx == -1:
|
||||
rev2 = r2
|
||||
else:
|
||||
|
@ -3797,7 +3795,7 @@ def parse_date(datestr):
|
|||
second = 0
|
||||
# return a "seconds since epoch" value assuming date given in UTC
|
||||
tm = (year, month, day, hour, minute, second, 0, 0, 0)
|
||||
return compat.timegm(tm)
|
||||
return calendar.timegm(tm)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
@ -3854,17 +3852,17 @@ def english_query(request):
|
|||
if maxdate:
|
||||
maxdate = make_time_string(parse_date(maxdate), cfg)
|
||||
ret.append('%s <em>%s</em> ' % (w2, maxdate))
|
||||
return string.join(ret, '')
|
||||
return ''.join(ret)
|
||||
|
||||
def prev_rev(rev):
|
||||
"""Returns a string representing the previous revision of the argument."""
|
||||
r = string.split(rev, '.')
|
||||
r = rev.split('.')
|
||||
# decrement final revision component
|
||||
r[-1] = str(int(r[-1]) - 1)
|
||||
# prune if we pass the beginning of the branch
|
||||
if len(r) > 2 and r[-1] == '0':
|
||||
r = r[:-2]
|
||||
return string.join(r, '.')
|
||||
return '.'.join(r)
|
||||
|
||||
def build_commit(request, files, max_files, dir_strip, format):
|
||||
"""Return a commit object build from the information in FILES, or
|
||||
|
@ -4122,9 +4120,9 @@ def view_query(request):
|
|||
elif branch:
|
||||
query.SetBranch(branch, branch_match)
|
||||
if dir:
|
||||
for subdir in string.split(dir, ','):
|
||||
for subdir in dir.split(','):
|
||||
path = (_path_join(repos_dir + request.path_parts
|
||||
+ _path_parts(string.strip(subdir))))
|
||||
+ _path_parts(subdir.strip())))
|
||||
query.SetDirectory(path, 'exact')
|
||||
query.SetDirectory('%s/%%' % cvsdb.EscapeLike(path), 'like')
|
||||
else:
|
||||
|
@ -4319,14 +4317,14 @@ def expand_root_parents(cfg):
|
|||
|
||||
# Each item in root_parents is a "directory : repo_type" string.
|
||||
for pp in cfg.general.root_parents:
|
||||
pos = string.rfind(pp, ':')
|
||||
pos = pp.rfind(':')
|
||||
if pos < 0:
|
||||
raise debug.ViewVCException(
|
||||
'The path "%s" in "root_parents" does not include a '
|
||||
'repository type. Expected "cvs" or "svn".' % (pp))
|
||||
|
||||
repo_type = string.strip(pp[pos+1:])
|
||||
pp = os.path.normpath(string.strip(pp[:pos]))
|
||||
repo_type = pp[pos+1:].strip()
|
||||
pp = os.path.normpath(pp[:pos].strip())
|
||||
|
||||
if repo_type == 'cvs':
|
||||
roots = vclib.ccvs.expand_root_parent(pp)
|
||||
|
@ -4350,13 +4348,13 @@ def find_root_in_parents(cfg, rootname, roottype):
|
|||
return None
|
||||
|
||||
for pp in cfg.general.root_parents:
|
||||
pos = string.rfind(pp, ':')
|
||||
pos = pp.rfind(':')
|
||||
if pos < 0:
|
||||
continue
|
||||
repo_type = string.strip(pp[pos+1:])
|
||||
repo_type = pp[pos+1:].strip()
|
||||
if repo_type != roottype:
|
||||
continue
|
||||
pp = os.path.normpath(string.strip(pp[:pos]))
|
||||
pp = os.path.normpath(pp[:pos].strip())
|
||||
|
||||
if roottype == 'cvs':
|
||||
roots = vclib.ccvs.expand_root_parent(pp)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
import os, sys, traceback, string, thread
|
||||
import os, sys, traceback, thread
|
||||
try:
|
||||
import win32api
|
||||
except ImportError, e:
|
||||
|
@ -40,9 +40,9 @@ def CommandLine(command, args):
|
|||
"""Convert an executable path and a sequence of arguments into a command
|
||||
line that can be passed to CreateProcess"""
|
||||
|
||||
cmd = "\"" + string.replace(command, "\"", "\"\"") + "\""
|
||||
cmd = "\"" + command.replace("\"", "\"\"") + "\""
|
||||
for arg in args:
|
||||
cmd = cmd + " \"" + string.replace(arg, "\"", "\"\"") + "\""
|
||||
cmd = cmd + " \"" + arg.replace("\"", "\"\"") + "\""
|
||||
return cmd
|
||||
|
||||
def CreateProcess(cmd, hStdInput, hStdOutput, hStdError):
|
||||
|
@ -109,13 +109,13 @@ def CreatePipe(readInheritable, writeInheritable):
|
|||
|
||||
def File2FileObject(pipe, mode):
|
||||
"""Make a C stdio file object out of a win32 file handle"""
|
||||
if string.find(mode, 'r') >= 0:
|
||||
if mode.find('r') >= 0:
|
||||
wmode = os.O_RDONLY
|
||||
elif string.find(mode, 'w') >= 0:
|
||||
elif mode.find('w') >= 0:
|
||||
wmode = os.O_WRONLY
|
||||
if string.find(mode, 'b') >= 0:
|
||||
if mode.find('b') >= 0:
|
||||
wmode = wmode | os.O_BINARY
|
||||
if string.find(mode, 't') >= 0:
|
||||
if mode.find('t') >= 0:
|
||||
wmode = wmode | os.O_TEXT
|
||||
return os.fdopen(msvcrt.open_osfhandle(pipe.Detach(),wmode),mode)
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
import time
|
||||
import string
|
||||
import profile
|
||||
|
||||
from vclib.ccvs import rcsparse
|
||||
|
@ -16,8 +15,8 @@ def lines_changed(delta):
|
|||
added = deleted = 0
|
||||
while idx < len(delta):
|
||||
op = delta[idx]
|
||||
i = string.find(delta, ' ', idx + 1)
|
||||
j = string.find(delta, '\n', i + 1)
|
||||
i = delta.find(' ', idx + 1)
|
||||
j = delta.find('\n', i + 1)
|
||||
line = int(delta[idx+1:i])
|
||||
count = int(delta[i+1:j])
|
||||
idx = j + 1
|
||||
|
@ -27,7 +26,7 @@ def lines_changed(delta):
|
|||
added = added + count
|
||||
# skip new text
|
||||
while count > 0:
|
||||
nl = string.find(delta, '\n', idx)
|
||||
nl = delta.find('\n', idx)
|
||||
assert nl > 0, 'missing a newline in the delta in the RCS file'
|
||||
idx = nl + 1
|
||||
count = count - 1
|
||||
|
@ -70,7 +69,7 @@ class FetchSink(rcsparse.Sink):
|
|||
|
||||
if revision != self.head:
|
||||
added, deleted = lines_changed(text)
|
||||
if string.count(revision, '.') == 1:
|
||||
if revision.count('.') == 1:
|
||||
# on the trunk. reverse delta.
|
||||
changed = '+%d -%d' % (deleted, added)
|
||||
self.entries[self.base[revision]].changed = changed
|
||||
|
|
|
@ -56,6 +56,7 @@ for PLATFORM in unix windows; do
|
|||
|
||||
# Remove some not useful directories
|
||||
for JUNK in elemx \
|
||||
misc \
|
||||
notes \
|
||||
tests \
|
||||
tools \
|
||||
|
|
|
@ -26,7 +26,6 @@ import StringIO
|
|||
# Get access to our library modules.
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), 'lib'))
|
||||
|
||||
import compat
|
||||
import viewvc
|
||||
import compat_ndiff
|
||||
version = viewvc.__version__
|
||||
|
@ -246,7 +245,7 @@ LEGEND
|
|||
dst_parent = os.path.dirname(destdir_path)
|
||||
if not os.path.exists(dst_parent):
|
||||
try:
|
||||
compat.makedirs(dst_parent)
|
||||
os.makedirs(dst_parent)
|
||||
print " created %s%s" % (dst_parent, os.sep)
|
||||
except os.error, e:
|
||||
if e.errno == 17: # EEXIST: file exists
|
||||
|
|
Loading…
Reference in New Issue