Mercurial > hg > buttercup
comparison buttercup/source.py @ 22:1378e96c65ac
git updater method
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 30 May 2011 14:06:29 -0700 |
parents | 1f54294629f9 |
children | 425a3c73ac1d |
comparison
equal
deleted
inserted
replaced
21:1f54294629f9 | 22:1378e96c65ac |
---|---|
23 | 23 |
24 def update(self): | 24 def update(self): |
25 """updates a checkout or does one if it does not exist""" | 25 """updates a checkout or does one if it does not exist""" |
26 if os.path.exists(self.directory()): | 26 if os.path.exists(self.directory()): |
27 assert os.path.exists(os.path.join(self.directory(), '.hg')) | 27 assert os.path.exists(os.path.join(self.directory(), '.hg')) |
28 call(['hg', 'pull'], cwd=self.directory) | 28 call(['hg', 'pull'], cwd=self.directory()) |
29 call(['hg', 'update'], cwd=self.directory) | 29 call(['hg', 'update'], cwd=self.directory()) |
30 else: | 30 else: |
31 if not os.path.exists(self.srcdir): | 31 if not os.path.exists(self.srcdir): |
32 os.makedirs(self.srcdir) | 32 os.makedirs(self.srcdir) |
33 call(['hg', 'clone', self.uri], cwd=self.srcdir) | 33 call(['hg', 'clone', self.uri], cwd=self.srcdir) |
34 # TODO: add a more intelligent .hg/hgrc | 34 # TODO: add a more intelligent .hg/hgrc |
43 ext = '.git' | 43 ext = '.git' |
44 if uri.endswith(uri): | 44 if uri.endswith(uri): |
45 uri = uri[:-len(ext)] | 45 uri = uri[:-len(ext)] |
46 return Source.directory_name(uri) | 46 return Source.directory_name(uri) |
47 | 47 |
48 def update(self): | |
49 """updates a checkout or does one if it does not exist""" | |
50 if os.path.exists(self.directory()): | |
51 assert os.path.exists(os.path.join(self.directory(), '.git')) | |
52 call(['git', 'pull'], cwd=self.directory()) | |
53 else: | |
54 if not os.path.exists(self.srcdir): | |
55 os.makedirs(self.srcdir) | |
56 call(['git', 'clone', self.uri], cwd=self.srcdir) | |
57 # TODO: add a more intelligent .git/config | |
58 | |
59 __call__ = update |