@matheusbsbs / matheus-bagliano / commits / c9c527d7b6
Fork 0

Made the name of the git branch used for the perforce import configurable through a new --branch=<name> commandline option.

Signed-off-by: Simon Hausmann <hausmann@kde.org>

Simon Hausmann committed Feb 8, 2007 at 15:53 UTC c9c527d7b60f406e143c1f7947a8c6c5ea9d9a8a
1 file changed +16 -6
contrib/fast-import/p4-fast-export.py
+16 -6
@@ -10,16 +10,26 @@
10 # - support p4 submit (hah!)
11 #
12 import os, string, sys, time
13 -import marshal, popen2
13 +import marshal, popen2, getopt
14
15 branch = "refs/heads/p4"
16 prefix = previousDepotPath = os.popen("git-repo-config --get p4.depotpath").read()
17 if len(prefix) != 0:
18 prefix = prefix[:-1]
19
20 -if len(sys.argv) == 1 and len(prefix) != 0:
20 +try:
21 + opts, args = getopt.getopt(sys.argv[1:], "", [ "branch=" ])
22 +except getopt.GetoptError:
23 + print "fixme, syntax error"
24 + sys.exit(1)
25 +
26 +for o, a in opts:
27 + if o == "--branch":
28 + branch = "refs/heads/" + a
29 +
30 +if len(args) == 0 and len(prefix) != 0:
31 print "[using previously specified depot path %s]" % prefix
22 -elif len(sys.argv) != 2:
32 +elif len(args) != 1:
33 print "usage: %s //depot/path[@revRange]" % sys.argv[0]
34 print "\n example:"
35 print " %s //depot/my/project/ -- to import the current head"
@@ -30,10 +40,10 @@ elif len(sys.argv) != 2:
40 print ""
41 sys.exit(1)
42 else:
33 - if len(prefix) != 0 and prefix != sys.argv[1]:
34 - print "previous import used depot path %s and now %s was specified. this doesn't work!" % (prefix, sys.argv[1])
43 + if len(prefix) != 0 and prefix != args[0]:
44 + print "previous import used depot path %s and now %s was specified. this doesn't work!" % (prefix, args[0])
45 sys.exit(1)
36 - prefix = sys.argv[1]
46 + prefix = args[0]
47
48 changeRange = ""
49 revision = ""