Skip to content

Commit 00657f9

Browse files
author
mhagger
committed
Fix sys.path for scripts in contrib.
Patch by: Jon Foster <[email protected]> The problem is that the programs in contrib automatically find the cvs2svn libraries by taking the script path, then chopping off the last directory component. If the full isn't specified, there isn't a "last directory component" to chop off. The fix is just to insert a call to abspath() in the appropriate place. After fixing that, there's a similar-but-different bug when using pychecker: > ~/cvs2svn-trunk/contrib$ pychecker destroy_repository.py > Processing destroy_repository... > ImportError: No module named cvs2svn_lib.key_generator In this case, the problem is that sys.argv[0] points to pychecker, not destroy_repository.py. This can be fixed by using __file__ instead, which is a special Python variable that gives the path to the current source file. git-svn-id: http://cvs2svn.tigris.org/svn/cvs2svn/trunk@5083 be7e6eca-30d4-0310-a8e5-ac0d63af7087
1 parent 74a26ce commit 00657f9

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

contrib/destroy_repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
import shutil
109109
import re
110110

111-
sys.path.insert(0, os.path.dirname(os.path.dirname(sys.argv[0])))
111+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
112112

113113
from cvs2svn_lib.key_generator import KeyGenerator
114114
import cvs2svn_rcsparse

contrib/find_illegal_filenames.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import sys
2828
import os
2929

30-
sys.path.insert(0, os.path.dirname(os.path.dirname(sys.argv[0])))
30+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
3131

3232
from cvs2svn_lib.common import FatalError
3333
from cvs2svn_lib.collect_data import verify_filename_legal

contrib/rcs_file_filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import os
2323
import time
2424

25-
sys.path.insert(0, os.path.dirname(os.path.dirname(sys.argv[0])))
25+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
2626

2727
import cvs2svn_rcsparse
2828

contrib/show_db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import cPickle as pickle
99
from cStringIO import StringIO
1010

11-
sys.path.insert(0, os.path.dirname(os.path.dirname(sys.argv[0])))
11+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
1212

1313
from cvs2svn_lib import config
1414
from cvs2svn_lib.context import Ctx

contrib/shrink_test_case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import optparse
3939
from cStringIO import StringIO
4040

41-
sys.path.insert(0, os.path.dirname(os.path.dirname(sys.argv[0])))
41+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
4242

4343
from cvs2svn_lib.key_generator import KeyGenerator
4444

0 commit comments

Comments
 (0)