summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b25b206)
raw | patch | inline | side by side (parent: b25b206)
author | Han-Wen Nienhuys <hanwen@google.com> | |
Wed, 23 May 2007 21:49:35 +0000 (18:49 -0300) | ||
committer | Han-Wen Nienhuys <hanwen@google.com> | |
Mon, 28 May 2007 14:45:26 +0000 (11:45 -0300) |
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
contrib/fast-import/git-p4 | patch | blob | history |
index efa2fce29ea2d3f63d16c02573807b9aa672ea0b..cf9db73da6a7d02c831f8a49cb68cf7bc1e313e5 100755 (executable)
from sets import Set;
gitdir = os.environ.get("GIT_DIR", "")
-silent = True
+verbose = False
def write_pipe(c, str):
- if not silent:
+ if verbose:
sys.stderr.write('writing pipe: %s\n' % c)
pipe = os.popen(c, 'w')
val = pipe.write(str)
if pipe.close():
- sys.stderr.write('Command failed')
+ sys.stderr.write('Command %s failed\n' % c)
sys.exit(1)
return val
-def read_pipe(c):
- if not silent:
+def read_pipe(c, ignore_error=False):
+ if verbose:
sys.stderr.write('reading pipe: %s\n' % c)
pipe = os.popen(c, 'rb')
val = pipe.read()
- if pipe.close():
- sys.stderr.write('Command failed')
+ if pipe.close() and not ignore_error:
+ sys.stderr.write('Command %s failed\n' % c)
sys.exit(1)
return val
def read_pipe_lines(c):
- if not silent:
+ if verbose:
sys.stderr.write('reading pipe: %s\n' % c)
## todo: check return status
pipe = os.popen(c, 'rb')
val = pipe.readlines()
if pipe.close():
- sys.stderr.write('Command failed')
+ sys.stderr.write('Command %s failed\n' % c)
sys.exit(1)
return val
def system(cmd):
- if not silent:
+ if verbose:
sys.stderr.write("executing %s" % cmd)
if os.system(cmd) != 0:
die("command failed: %s" % cmd)
return proc.wait() == 0;
def gitConfig(key):
- return mypopen("git config %s" % key).read()[:-1]
+ return read_pipe("git config %s" % key, ignore_error=True).strip()
class Command:
def __init__(self):
def __init__(self):
Command.__init__(self)
self.options = [
- ]
+ optparse.make_option("--verbose", dest="verbose", action="store_true"),
+ ]
self.description = "A tool to debug the output of p4 -G."
self.needsGit = False
Command.__init__(self)
self.options = [
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("--reset", action="store_true", dest="reset"),
optparse.make_option("--log-substitutions", dest="substFile"),
if not self.silent:
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"):
continue
- headName = line[len("origin/"):-1]
+ headName = line[len("origin/")]
remoteHead = self.refPrefix + headName
originHead = "origin/" + headName
(cmd, args) = parser.parse_args(sys.argv[2:], cmd);
+verbose = cmd.verbose
if cmd.needsGit:
gitdir = cmd.gitdir
if len(gitdir) == 0: