3 """Update the rcsparse library from ViewVC."""
12 VIEWVC_REPOS
= 'http://viewvc.tigris.org/svn/viewvc'
14 RCSPARSE_URL
= '/'.join([VIEWVC_REPOS
, BRANCH
, 'lib/vclib/ccvs/rcsparse'])
15 LICENSE_URL
= '/'.join([VIEWVC_REPOS
, BRANCH
, 'LICENSE.html'])
17 DEST
= os
.path
.dirname(__file__
)
20 # This file causes Python to treat its containing directory it as a
21 # package. Please note that the contents of this file differ from
22 # those of the __init__.py file distributed with ViewVC.
27 def get_current_revision():
28 revision_re
= re
.compile(r
'^Revision\:\s*(?P<revision>\d+)$')
30 cmd
= ['svn', 'info', VIEWVC_REPOS
]
31 sys
.stderr
.write('%s\n' % (' '.join(cmd
),))
32 p
= subprocess
.Popen(cmd
, stdout
=subprocess
.PIPE
)
33 (out
, err
) = p
.communicate()
34 for line
in out
.splitlines():
35 m
= revision_re
.match(line
)
37 return int(m
.group('revision'))
40 'Could not determine the current revision of the ViewVC repository!'
43 def export(url
, revision
, dest
):
44 cmd
= ['svn', 'export', '-r', str(revision
), '--force', url
, dest
]
45 sys
.stderr
.write('%s\n' % (' '.join(cmd
),))
46 retcode
= subprocess
.call(cmd
)
49 sys
.exit('Export failed!')
53 parser
= optparse
.OptionParser(
58 '--revision', '-r', metavar
='REV',
59 action
='store', type='int', default
=None,
60 help='download the specific revision REV',
63 (options
, args
) = parser
.parse_args(args
)
66 parser
.error('Unexpected arguments: %s' % (' '.join(args
),))
68 if options
.revision
is None:
69 options
.revision
= get_current_revision()
71 export(RCSPARSE_URL
, options
.revision
, DEST
)
72 export(LICENSE_URL
, options
.revision
, os
.path
.join(DEST
, 'LICENSE.html'))
74 # Record which version of the upstream source was downloaded:
75 open(os
.path
.join(DEST
, 'UPSTREAM_SOURCE'), 'w').write(
76 '%s@%d\n' % (RCSPARSE_URL
, options
.revision
,)
79 # Replace the upstream __init__.py file, which does some stuff that we
81 open(os
.path
.join(DEST
, '__init__.py'), 'w').write(INIT_TEXT
)