changeset 568:bf8114a76224

Add more debug output
author Bjoern Ricks <bricks@intevation.de>
date Fri, 02 Sep 2011 11:19:03 +0000
parents 9d44d4da3411
children aaeca9cf0143
files treepkg/git.py treepkg/packager.py
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/treepkg/git.py	Fri Sep 02 11:04:07 2011 +0000
+++ b/treepkg/git.py	Fri Sep 02 11:19:03 2011 +0000
@@ -27,7 +27,7 @@
 
     """Describes a git repository"""
 
-    def __init__(self, url, branch=None):
+    def __init__(self, url, branch=None, logger=None):
         """Initialize the git repository description
         Parameters:
           url -- The url of the repository
@@ -36,6 +36,7 @@
                     defaults to master
         """
         self.url = url
+        self.log = logger
         if not branch:
             # as default track master as local-master
             self.local_branch = "local-master"
@@ -51,10 +52,12 @@
     def checkout(self, localdir):
         """Clones the repository at url into the localdir"""
         run.call(cmdexpand("git clone -q $url $localdir", **locals()))
-        if branch:
+        if self.branch:
             self.checkout_branch(localdir)
 
     def checkout_branch(self, localdir):
+        self.log_info("Switching to local branch '%s' for branch '%s'" %\
+                (self.local_branch, self.branch))
         run.call(cmdexpand("git checkout -q --track -b $local $branch",
             branch=self.branch, local=self.local_branch), cwd=localdir)
 
@@ -84,12 +87,17 @@
             all_branches.append(tbranch)
         if not self.local_branch in all_branches:
             self.checkout_branch(localdir)
+        self.log_info("Current branch is '%s'" % cur_branch)
         # TODO: check if self.local_branch is curbranch
         # doesn't hurt if a checkout is done on the current branch
         if self.branch:
+            self.log_info("Switching to local branch '%s'" % self.local_branch)
             run.call(cmdexpand("git checkout -q $branch", branch=self.local_branch),
                     cwd=localdir)
 
+    def log_info(self, *args):
+        if self.logger is not None:
+            self.logger.info(*args)
 
     def last_changed_revision(self, localdir):
         """Returns the SHA1 sum of the latest commit in the working copy in localdir"""
--- a/treepkg/packager.py	Fri Sep 02 11:04:07 2011 +0000
+++ b/treepkg/packager.py	Fri Sep 02 11:19:03 2011 +0000
@@ -569,7 +569,7 @@
             self.working_copy = SvnWorkingCopy(repo, self.checkout_dir,
                                               logger=logging)
         elif scm_type == "git":
-            repo = GitRepository(url, branch=branch)
+            repo = GitRepository(url, branch=branch, logger=logging)
             self.working_copy = GitWorkingCopy(repo, self.checkout_dir,
                                               logger=logging) 
         else:
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)