blind: added support for --silent

This commit is contained in:
Simon Hausmann
2007-02-22 09:03:39 +01:00
parent 7b6a30fe2a
commit 21dc7ef85d

View File

@@ -15,6 +15,7 @@ import os, string, sys, time
import marshal, popen2, getopt import marshal, popen2, getopt
from sets import Set; from sets import Set;
silent = False
knownBranches = Set() knownBranches = Set()
committedChanges = Set() committedChanges = Set()
branch = "refs/heads/master" branch = "refs/heads/master"
@@ -25,7 +26,7 @@ if len(globalPrefix) != 0:
globalPrefix = globalPrefix[:-1] globalPrefix = globalPrefix[:-1]
try: try:
opts, args = getopt.getopt(sys.argv[1:], "", [ "branch=", "detect-branches", "changesfile=" ]) opts, args = getopt.getopt(sys.argv[1:], "", [ "branch=", "detect-branches", "changesfile=", "silent" ])
except getopt.GetoptError: except getopt.GetoptError:
print "fixme, syntax error" print "fixme, syntax error"
sys.exit(1) sys.exit(1)
@@ -37,6 +38,8 @@ for o, a in opts:
detectBranches = True detectBranches = True
elif o == "--changesfile": elif o == "--changesfile":
changesFile = a changesFile = a
elif o == "--silent":
silent= True
if len(args) == 0 and len(globalPrefix) != 0: if len(args) == 0 and len(globalPrefix) != 0:
print "[using previously specified depot path %s]" % globalPrefix print "[using previously specified depot path %s]" % globalPrefix
@@ -110,6 +113,7 @@ def extractFilesFromCommit(commit):
while commit.has_key("depotFile%s" % fnum): while commit.has_key("depotFile%s" % fnum):
path = commit["depotFile%s" % fnum] path = commit["depotFile%s" % fnum]
if not path.startswith(globalPrefix): if not path.startswith(globalPrefix):
if not silent:
print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, globalPrefix, change) print "\nchanged files: ignoring path %s outside of %s in change %s" % (path, globalPrefix, change)
fnum = fnum + 1 fnum = fnum + 1
continue continue
@@ -272,6 +276,7 @@ def commit(details, files, branch, branchPrefix):
for file in files: for file in files:
path = file["path"] path = file["path"]
if not path.startswith(branchPrefix): if not path.startswith(branchPrefix):
if not silent:
print "\nchanged files: ignoring path %s outside of branch prefix %s in change %s" % (path, branchPrefix, details["change"]) print "\nchanged files: ignoring path %s outside of branch prefix %s in change %s" % (path, branchPrefix, details["change"])
continue continue
rev = file["rev"] rev = file["rev"]
@@ -387,6 +392,7 @@ else:
changes.reverse() changes.reverse()
if len(changes) == 0: if len(changes) == 0:
if not silent:
print "no changes to import!" print "no changes to import!"
sys.exit(1) sys.exit(1)
@@ -394,6 +400,7 @@ else:
for change in changes: for change in changes:
description = p4Cmd("describe %s" % change) description = p4Cmd("describe %s" % change)
if not silent:
sys.stdout.write("\rimporting revision %s (%s%%)" % (change, cnt * 100 / len(changes))) sys.stdout.write("\rimporting revision %s (%s%%)" % (change, cnt * 100 / len(changes)))
sys.stdout.flush() sys.stdout.flush()
cnt = cnt + 1 cnt = cnt + 1
@@ -412,6 +419,7 @@ else:
# print gitError.read() # print gitError.read()
# sys.exit(1) # sys.exit(1)
if not silent:
print "" print ""
gitStream.write("reset refs/tags/p4/%s\n" % lastChange) gitStream.write("reset refs/tags/p4/%s\n" % lastChange)