-
Notifications
You must be signed in to change notification settings - Fork 0
/
cvs2hg
executable file
·95 lines (79 loc) · 3.01 KB
/
cvs2hg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
# (Be in -*- python -*- mode.)
#
# ====================================================================
# Copyright (c) 2000-2008 CollabNet. All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals. For exact contribution history, see the revision
# history and logs, available at http://cvs2svn.tigris.org/.
# ====================================================================
import sys
# Make sure that a supported version of Python is being used. Do this
# as early as possible, using only code compatible with Python 1.5.2
# and Python 3.x before the check. Remember:
#
# Python 1.5.2 doesn't have sys.version_info or ''.join().
# Python 3.0 doesn't have string.join().
# There are plans to start deprecating the string formatting '%'
# operator in Python 3.1 (but we use it here anyway).
version_error = """\
ERROR: cvs2hg requires Python 2, version 2.4 or later; it does not
work with Python 3. You are currently using"""
version_advice = """\
Please restart cvs2hg using a different version of the Python
interpreter. Visit http://www.python.org or consult your local system
administrator if you need help.
HINT: If you already have a usable Python version installed, it might
be possible to invoke cvs2hg with the correct Python interpreter by
typing something like 'python2.5 """ + sys.argv[0] + """ [...]'.
"""
try:
version = sys.version_info
except AttributeError:
# This is probably a pre-2.0 version of Python.
sys.stderr.write(version_error + '\n')
sys.stderr.write('-'*70 + '\n')
sys.stderr.write(sys.version + '\n')
sys.stderr.write('-'*70 + '\n')
sys.stderr.write(version_advice)
sys.exit(1)
if not ((2,4) <= version < (3,0)):
sys.stderr.write(
version_error + ' version %d.%d.%d.\n'
% (version[0], version[1], version[2],)
)
sys.stderr.write(version_advice)
sys.exit(1)
hg_required = "ERROR: cvs2hg requires Mercurial 1.1 or later.\n"
hg_missing = "(No Mercurial API found.)\n"
hg_version = "(Attempted to use the Mercurial %s API in\n%s.)\n"
import os
try:
import mercurial
from mercurial import context, __version__
context.memctx # ensure Mercurial >= 1.1
context.memfilectx
except ImportError:
sys.stderr.write(hg_required + hg_missing)
sys.exit(1)
except AttributeError:
sys.stderr.write(hg_required +
hg_version
% (__version__.version,
os.path.dirname(mercurial.__file__)))
sys.exit(1)
import os
from cvs2svn_lib.common import FatalException
from cvs2svn_lib.main import hg_main
try:
hg_main(os.path.basename(sys.argv[0]), sys.argv[1:])
except FatalException, e:
sys.stderr.write(str(e) + '\n')
sys.exit(1)