Skip to content

Commit a33faf2

Browse files
eric-s-raymondgitster
authored andcommitted
Add checks to Python scripts for version dependencies.
Signed-off-by: Eric S. Raymond <esr@thyrsus.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 18499ba commit a33faf2

File tree

8 files changed

+44
-3
lines changed

8 files changed

+44
-3
lines changed

contrib/ciabot/ciabot.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@
4747
# we default to that.
4848
#
4949

50-
import os, sys, commands, socket, urllib
50+
import sys
51+
if sys.hexversion < 0x02000000:
52+
# The limiter is the xml.sax module
53+
sys.stderr.write("ciabot.py: requires Python 2.0.0 or later.\n")
54+
sys.exit(1)
55+
56+
import os, commands, socket, urllib
5157
from xml.sax.saxutils import escape
5258

5359
# Changeset URL prefix for your repo: when the commit ID is appended

contrib/fast-import/import-zips.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@
99
## git log --stat import-zips
1010

1111
from os import popen, path
12-
from sys import argv, exit
12+
from sys import argv, exit, hexversion, stderr
1313
from time import mktime
1414
from zipfile import ZipFile
1515

16+
if hexversion < 0x01060000:
17+
# The limiter is the zipfile module
18+
sys.stderr.write("import-zips.py: requires Python 1.6.0 or later.\n")
19+
sys.exit(1)
20+
1621
if len(argv) < 2:
1722
print 'Usage:', argv[0], '<zipfile>...'
1823
exit(1)

contrib/hg-to-git/hg-to-git.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
import tempfile, pickle, getopt
2424
import re
2525

26+
if sys.hexversion < 0x02030000:
27+
# The behavior of the pickle module changed significantly in 2.3
28+
sys.stderr.write("hg-to-git.py: requires Python 2.3 or later.\n")
29+
sys.exit(1)
30+
2631
# Maps hg version -> git version
2732
hgvers = {}
2833
# List of children for each hg revision

contrib/p4import/git-p4import.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
import time
1515
import getopt
1616

17+
if sys.hexversion < 0x02020000:
18+
# The behavior of the marshal module changed significantly in 2.2
19+
sys.stderr.write("git-p4import.py: requires Python 2.2 or later.\n")
20+
sys.exit(1)
21+
1722
from signal import signal, \
1823
SIGPIPE, SIGINT, SIG_DFL, \
1924
default_int_handler

contrib/svn-fe/svnrdump_sim.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"""
88
import sys, os
99

10+
if sys.hexversion < 0x02040000:
11+
# The limiter is the ValueError() calls. This may be too conservative
12+
sys.stderr.write("svnrdump-sim.py: requires Python 2.4 or later.\n")
13+
sys.exit(1)
1014

1115
def getrevlimit():
1216
var = 'SVNRMAX'

git-p4.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
99
#
1010

11-
import optparse, sys, os, marshal, subprocess, shelve
11+
import sys
12+
if sys.hexversion < 0x02040000:
13+
# The limiter is the subprocess module
14+
sys.stderr.write("git-p4: requires Python 2.4 or later.\n")
15+
sys.exit(1)
16+
17+
import optparse, os, marshal, subprocess, shelve
1218
import tempfile, getopt, os.path, time, platform
1319
import re, shutil
1420

git-remote-testgit.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
from git_remote_helpers.git.importer import GitImporter
3232
from git_remote_helpers.git.non_local import NonLocalGit
3333

34+
if sys.hexversion < 0x01050200:
35+
# os.makedirs() is the limiter
36+
sys.stderr.write("git-remote-testgit: requires Python 1.5.2 or later.\n")
37+
sys.exit(1)
38+
3439
def get_repo(alias, url):
3540
"""Returns a git repository object initialized for usage.
3641
"""

git_remote_helpers/git/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import sys
2+
if sys.hexversion < 0x02040000:
3+
# The limiter is the subprocess module
4+
sys.stderr.write("git_remote_helpers: requires Python 2.4 or later.\n")
5+
sys.exit(1)

0 commit comments

Comments
 (0)