Merge branch 'wg/svn-fe-style-fixes'

* wg/svn-fe-style-fixes:
  svn-fe: conform to pep8
This commit is contained in:
Junio C Hamano 2014-06-06 11:24:32 -07:00
Родитель e318b83511 20c4fbf97d
Коммит ff0b8753a1
1 изменённых файлов: 52 добавлений и 41 удалений

Просмотреть файл

@ -5,53 +5,64 @@ of the specified revision range.
To simulate incremental imports the environment variable SVNRMAX can be set To simulate incremental imports the environment variable SVNRMAX can be set
to the highest revision that should be available. to the highest revision that should be available.
""" """
import sys, os import sys
import os
if sys.hexversion < 0x02040000: if sys.hexversion < 0x02040000:
# The limiter is the ValueError() calls. This may be too conservative # The limiter is the ValueError() calls. This may be too conservative
sys.stderr.write("svnrdump-sim.py: requires Python 2.4 or later.\n") sys.stderr.write("svnrdump-sim.py: requires Python 2.4 or later.\n")
sys.exit(1) sys.exit(1)
def getrevlimit(): def getrevlimit():
var = 'SVNRMAX' var = 'SVNRMAX'
if var in os.environ: if var in os.environ:
return os.environ[var] return os.environ[var]
return None return None
def writedump(url, lower, upper): def writedump(url, lower, upper):
if url.startswith('sim://'): if url.startswith('sim://'):
filename = url[6:] filename = url[6:]
if filename[-1] == '/': filename = filename[:-1] #remove terminating slash if filename[-1] == '/':
else: filename = filename[:-1] # remove terminating slash
raise ValueError('sim:// url required') else:
f = open(filename, 'r'); raise ValueError('sim:// url required')
state = 'header' f = open(filename, 'r')
wroterev = False state = 'header'
while(True): wroterev = False
l = f.readline() while(True):
if l == '': break l = f.readline()
if state == 'header' and l.startswith('Revision-number: '): if l == '':
state = 'prefix' break
if state == 'prefix' and l == 'Revision-number: %s\n' % lower: if state == 'header' and l.startswith('Revision-number: '):
state = 'selection' state = 'prefix'
if not upper == 'HEAD' and state == 'selection' and l == 'Revision-number: %s\n' % upper: if state == 'prefix' and l == 'Revision-number: %s\n' % lower:
break; state = 'selection'
if not upper == 'HEAD' and state == 'selection' and \
l == 'Revision-number: %s\n' % upper:
break
if state == 'header' or state == 'selection': if state == 'header' or state == 'selection':
if state == 'selection': wroterev = True if state == 'selection':
sys.stdout.write(l) wroterev = True
return wroterev sys.stdout.write(l)
return wroterev
if __name__ == "__main__": if __name__ == "__main__":
if not (len(sys.argv) in (3, 4, 5)): if not (len(sys.argv) in (3, 4, 5)):
print("usage: %s dump URL -rLOWER:UPPER") print("usage: %s dump URL -rLOWER:UPPER")
sys.exit(1) sys.exit(1)
if not sys.argv[1] == 'dump': raise NotImplementedError('only "dump" is suppported.') if not sys.argv[1] == 'dump':
url = sys.argv[2] raise NotImplementedError('only "dump" is suppported.')
r = ('0', 'HEAD') url = sys.argv[2]
if len(sys.argv) == 4 and sys.argv[3][0:2] == '-r': r = ('0', 'HEAD')
r = sys.argv[3][2:].lstrip().split(':') if len(sys.argv) == 4 and sys.argv[3][0:2] == '-r':
if not getrevlimit() is None: r[1] = getrevlimit() r = sys.argv[3][2:].lstrip().split(':')
if writedump(url, r[0], r[1]): ret = 0 if not getrevlimit() is None:
else: ret = 1 r[1] = getrevlimit()
sys.exit(ret) if writedump(url, r[0], r[1]):
ret = 0
else:
ret = 1
sys.exit(ret)