1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-08 20:36:19 +02:00

add --verbose to all commands.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
This commit is contained in:
Han-Wen Nienhuys 2007-05-23 18:49:35 -03:00
parent b25b20656d
commit 4addad2291

View File

@ -15,47 +15,47 @@ import re
from sets import Set; from sets import Set;
gitdir = os.environ.get("GIT_DIR", "") gitdir = os.environ.get("GIT_DIR", "")
silent = True verbose = False
def write_pipe(c, str): def write_pipe(c, str):
if not silent: if verbose:
sys.stderr.write('writing pipe: %s\n' % c) sys.stderr.write('writing pipe: %s\n' % c)
pipe = os.popen(c, 'w') pipe = os.popen(c, 'w')
val = pipe.write(str) val = pipe.write(str)
if pipe.close(): if pipe.close():
sys.stderr.write('Command failed') sys.stderr.write('Command %s failed\n' % c)
sys.exit(1) sys.exit(1)
return val return val
def read_pipe(c): def read_pipe(c, ignore_error=False):
if not silent: if verbose:
sys.stderr.write('reading pipe: %s\n' % c) sys.stderr.write('reading pipe: %s\n' % c)
pipe = os.popen(c, 'rb') pipe = os.popen(c, 'rb')
val = pipe.read() val = pipe.read()
if pipe.close(): if pipe.close() and not ignore_error:
sys.stderr.write('Command failed') sys.stderr.write('Command %s failed\n' % c)
sys.exit(1) sys.exit(1)
return val return val
def read_pipe_lines(c): def read_pipe_lines(c):
if not silent: if verbose:
sys.stderr.write('reading pipe: %s\n' % c) sys.stderr.write('reading pipe: %s\n' % c)
## todo: check return status ## todo: check return status
pipe = os.popen(c, 'rb') pipe = os.popen(c, 'rb')
val = pipe.readlines() val = pipe.readlines()
if pipe.close(): if pipe.close():
sys.stderr.write('Command failed') sys.stderr.write('Command %s failed\n' % c)
sys.exit(1) sys.exit(1)
return val return val
def system(cmd): def system(cmd):
if not silent: if verbose:
sys.stderr.write("executing %s" % cmd) sys.stderr.write("executing %s" % cmd)
if os.system(cmd) != 0: if os.system(cmd) != 0:
die("command failed: %s" % cmd) die("command failed: %s" % cmd)
@ -157,7 +157,7 @@ def gitBranchExists(branch):
return proc.wait() == 0; return proc.wait() == 0;
def gitConfig(key): def gitConfig(key):
return mypopen("git config %s" % key).read()[:-1] return read_pipe("git config %s" % key, ignore_error=True).strip()
class Command: class Command:
def __init__(self): def __init__(self):
@ -168,6 +168,7 @@ class P4Debug(Command):
def __init__(self): def __init__(self):
Command.__init__(self) Command.__init__(self)
self.options = [ self.options = [
optparse.make_option("--verbose", dest="verbose", action="store_true"),
] ]
self.description = "A tool to debug the output of p4 -G." self.description = "A tool to debug the output of p4 -G."
self.needsGit = False self.needsGit = False
@ -234,6 +235,7 @@ class P4Submit(Command):
Command.__init__(self) Command.__init__(self)
self.options = [ self.options = [
optparse.make_option("--continue", action="store_false", dest="firstTime"), optparse.make_option("--continue", action="store_false", dest="firstTime"),
optparse.make_option("--verbose", dest="verbose", action="store_true"),
optparse.make_option("--origin", dest="origin"), optparse.make_option("--origin", dest="origin"),
optparse.make_option("--reset", action="store_true", dest="reset"), optparse.make_option("--reset", action="store_true", dest="reset"),
optparse.make_option("--log-substitutions", dest="substFile"), optparse.make_option("--log-substitutions", dest="substFile"),
@ -861,11 +863,12 @@ class P4Sync(Command):
if not self.silent: if not self.silent:
print "Creating/updating branch(es) in %s based on origin branch(es)" % self.refPrefix print "Creating/updating branch(es) in %s based on origin branch(es)" % self.refPrefix
for line in mypopen("git rev-parse --symbolic --remotes"): for line in read_pipe_lines("git rev-parse --symbolic --remotes"):
line = line.strip()
if (not line.startswith("origin/")) or line.endswith("HEAD\n"): if (not line.startswith("origin/")) or line.endswith("HEAD\n"):
continue continue
headName = line[len("origin/"):-1] headName = line[len("origin/")]
remoteHead = self.refPrefix + headName remoteHead = self.refPrefix + headName
originHead = "origin/" + headName originHead = "origin/" + headName
@ -1292,6 +1295,7 @@ if len(options) > 0:
(cmd, args) = parser.parse_args(sys.argv[2:], cmd); (cmd, args) = parser.parse_args(sys.argv[2:], cmd);
verbose = cmd.verbose
if cmd.needsGit: if cmd.needsGit:
gitdir = cmd.gitdir gitdir = cmd.gitdir
if len(gitdir) == 0: if len(gitdir) == 0: