[Treepkg-commits] r531 - trunk/treepkg

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Sep 2 13:19:03 CEST 2011


Author: bricks
Date: 2011-09-02 13:19:03 +0200 (Fri, 02 Sep 2011)
New Revision: 531

Modified:
   trunk/treepkg/git.py
   trunk/treepkg/packager.py
Log:
Add more debug output


Modified: trunk/treepkg/git.py
===================================================================
--- trunk/treepkg/git.py	2011-09-02 11:04:07 UTC (rev 530)
+++ trunk/treepkg/git.py	2011-09-02 11:19:03 UTC (rev 531)
@@ -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"""

Modified: trunk/treepkg/packager.py
===================================================================
--- trunk/treepkg/packager.py	2011-09-02 11:04:07 UTC (rev 530)
+++ trunk/treepkg/packager.py	2011-09-02 11:19:03 UTC (rev 531)
@@ -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:



More information about the Treepkg-commits mailing list