# HG changeset patch # User Jeff Hammel # Date 1306789589 25200 # Node ID 1378e96c65acbdcab5347cdf27e0879d31c7fcb6 # Parent 1f54294629f923891bd82e68621227014972cbc3 git updater method diff -r 1f54294629f9 -r 1378e96c65ac buttercup/source.py --- 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