changeset 22:1378e96c65ac

git updater method
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 30 May 2011 14:06:29 -0700
parents 1f54294629f9
children 425a3c73ac1d
files buttercup/source.py
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/buttercup/source.py	Mon May 30 13:56:45 2011 -0700
+++ b/buttercup/source.py	Mon May 30 14:06:29 2011 -0700
@@ -25,8 +25,8 @@
         """updates a checkout or does one if it does not exist"""
         if os.path.exists(self.directory()):
             assert os.path.exists(os.path.join(self.directory(), '.hg'))
-            call(['hg', 'pull'], cwd=self.directory)
-            call(['hg', 'update'], cwd=self.directory)
+            call(['hg', 'pull'], cwd=self.directory())
+            call(['hg', 'update'], cwd=self.directory())
         else:
             if not os.path.exists(self.srcdir):
                 os.makedirs(self.srcdir)
@@ -45,3 +45,15 @@
             uri = uri[:-len(ext)]
         return Source.directory_name(uri)
 
+    def update(self):
+        """updates a checkout or does one if it does not exist"""
+        if os.path.exists(self.directory()):
+            assert os.path.exists(os.path.join(self.directory(), '.git'))
+            call(['git', 'pull'], cwd=self.directory())
+        else:
+            if not os.path.exists(self.srcdir):
+                os.makedirs(self.srcdir)
+            call(['git', 'clone', self.uri], cwd=self.srcdir)
+            # TODO: add a more intelligent .git/config
+
+    __call__ = update