@matheusbsbs / matheus-bagliano / commits / 161958cc2f
Fork 0

Added support for --silent so that p4-fast-export can be called from cronjobs.

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

Simon Hausmann committed Feb 22, 2007 at 09:03 UTC 161958cc2f71eefbf514b2265741f7d2eb1a5f0b
1 file changed +15 -7
contrib/fast-import/p4-fast-export.py
+15 -7
@@ -15,6 +15,7 @@ import os, string, sys, time
15 import marshal, popen2, getopt
16 from sets import Set;
17
18 +silent = False
19 knownBranches = Set()
20 committedChanges = Set()
21 branch = "refs/heads/master"
@@ -25,7 +26,7 @@ if len(globalPrefix) != 0:
26 globalPrefix = globalPrefix[:-1]
27
28 try:
28 - opts, args = getopt.getopt(sys.argv[1:], "", [ "branch=", "detect-branches", "changesfile=" ])
29 + opts, args = getopt.getopt(sys.argv[1:], "", [ "branch=", "detect-branches", "changesfile=", "silent" ])
30 except getopt.GetoptError:
31 print "fixme, syntax error"
32 sys.exit(1)
@@ -37,6 +38,8 @@ for o, a in opts:
38 detectBranches = True
39 elif o == "--changesfile":
40 changesFile = a
41 + elif o == "--silent":
42 + silent= True
43
44 if len(args) == 0 and len(globalPrefix) != 0:
45 print "[using previously specified depot path %s]" % globalPrefix
@@ -110,7 +113,8 @@ def extractFilesFromCommit(commit):
113 while commit.has_key("depotFile%s" % fnum):
114 path = commit["depotFile%s" % fnum]
115 if not path.startswith(globalPrefix):
113 - print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, globalPrefix, change)
116 + if not silent:
117 + print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, globalPrefix, change)
118 fnum = fnum + 1
119 continue
120
@@ -272,7 +276,8 @@ def commit(details, files, branch, branchPrefix):
276 for file in files:
277 path = file["path"]
278 if not path.startswith(branchPrefix):
275 - print "\nchanged files: ignoring path %s outside of branch prefix %s in change %s" % (path, branchPrefix, details["change"])
279 + if not silent:
280 + print "\nchanged files: ignoring path %s outside of branch prefix %s in change %s" % (path, branchPrefix, details["change"])
281 continue
282 rev = file["rev"]
283 depotPath = path + "#" + rev
@@ -387,15 +392,17 @@ else:
392 changes.reverse()
393
394 if len(changes) == 0:
390 - print "no changes to import!"
395 + if not silent:
396 + print "no changes to import!"
397 sys.exit(1)
398
399 cnt = 1
400 for change in changes:
401 description = p4Cmd("describe %s" % change)
402
397 - sys.stdout.write("\rimporting revision %s (%s%%)" % (change, cnt * 100 / len(changes)))
398 - sys.stdout.flush()
403 + if not silent:
404 + sys.stdout.write("\rimporting revision %s (%s%%)" % (change, cnt * 100 / len(changes)))
405 + sys.stdout.flush()
406 cnt = cnt + 1
407
408 # try:
@@ -412,7 +419,8 @@ else:
419 # print gitError.read()
420 # sys.exit(1)
421
415 -print ""
422 +if not silent:
423 + print ""
424
425 gitStream.write("reset refs/tags/p4/%s\n" % lastChange)
426 gitStream.write("from %s\n\n" % branch);