aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp-pull
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2010-09-03 13:07:10 +0200
committerGuido Günther <agx@sigxcpu.org>2010-11-16 13:27:28 +0100
commit7e79bcd4ab0030db5c5a7998c81f63c48656be80 (patch)
tree89e8281c518e2ce705d99c3fc1f17aac30ae0124 /gbp-pull
parentc385e767dc713ae8b2d32374cd94d2dc3eae2b6e (diff)
Add logging functions
This allows us to color and prefix the output. Closes: #544332
Diffstat (limited to 'gbp-pull')
-rwxr-xr-xgbp-pull25
1 files changed, 13 insertions, 12 deletions
diff --git a/gbp-pull b/gbp-pull
index 79c12a43..4f814b24 100755
--- a/gbp-pull
+++ b/gbp-pull
@@ -27,6 +27,7 @@ from gbp.command_wrappers import (GitFetch, GitMerge, Command,
from gbp.config import (GbpOptionParser, GbpOptionGroup)
from gbp.errors import GbpError
from gbp.git import (GitRepositoryError, GitRepository)
+import gbp.log
def fast_forward_branch(branch, repo, options):
"""
@@ -39,26 +40,26 @@ def fast_forward_branch(branch, repo, options):
remote = repo.get_merge_branch(branch)
if not remote:
- print >>sys.stderr, "Warning: no branch tracking '%s' found - skipping." % branch
+ gbp.log.err("Warning: no branch tracking '%s' found - skipping." % branch)
return False
can_fast_forward, up_to_date = repo.is_fast_forward(branch, remote)
if up_to_date: # Great, we're done
- print "Branch '%s' is already up to date." % branch
+ gbp.log.info("Branch '%s' is already up to date." % branch)
return True
if can_fast_forward:
update = True
else:
if options.force:
- print "Non-fast forwarding '%s' due to --force" % branch
+ gbp.log.info("Non-fast forwarding '%s' due to --force" % branch)
update = True
else:
- print >>sys.stderr, "Warning: Skipping non-fast forward of '%s' - use --force" % branch
+ gbp.log.warn("Skipping non-fast forward of '%s' - use --force" % branch)
if update:
- print "Updating '%s'" % branch
+ gbp.log.info("Updating '%s'" % branch)
repo.set_branch(branch)
GitMerge(remote)()
return update
@@ -80,16 +81,16 @@ def main(argv):
help="Redo the patch queue branch after a pull. Warning: this drops the old patch-queue branch")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
+ parser.add_config_file_option(option_name="color", dest="color")
- (options, args) = parser.parse_args(argv)
- if options.verbose:
- Command.verbose = True
+ (options, args) = parser.parse_args(argv)
+ gbp.log.setup(options.color, options.verbose)
try:
repo = GitRepository(os.path.curdir)
except GitRepositoryError:
- print >>sys.stderr, "%s is not a git repository" % (os.path.abspath('.'))
+ gbp.log.err("%s is not a git repository" % (os.path.abspath('.')))
return 1
try:
@@ -105,8 +106,8 @@ def main(argv):
(ret, out) = repo.is_clean()
if not ret:
- print >>sys.stderr, "You have uncommitted changes in your source tree:"
- print >>sys.stderr, out
+ gbp.log.err("You have uncommitted changes in your source tree:")
+ gbp.log.err(out)
raise GbpError
GitFetch()()
@@ -124,7 +125,7 @@ def main(argv):
retval = 1
except GbpError, err:
if len(err.__str__()):
- print >>sys.stderr, err
+ gbp.log.err(err)
retval = 1
return retval