Mercurial > hg > fetch
comparison fetch.py @ 23:12ad9ab11860
stubbing
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 09 Nov 2011 20:21:14 -0800 |
parents | 0706968f01bb |
children | b1f65f3bd1bc |
comparison
equal
deleted
inserted
replaced
22:63ff1b00ec05 | 23:12ad9ab11860 |
---|---|
3 """ | 3 """ |
4 fetch stuff from the interwebs | 4 fetch stuff from the interwebs |
5 """ | 5 """ |
6 | 6 |
7 import os | 7 import os |
8 import shutil | |
8 import sys | 9 import sys |
9 import optparse | 10 import optparse |
10 | 11 |
11 __all__ = ['Fetcher', 'Fetch', 'main'] | 12 __all__ = ['Fetcher', 'Fetch', 'main'] |
12 | 13 |
22 | 23 |
23 @classmethod | 24 @classmethod |
24 def match(cls, _type): | 25 def match(cls, _type): |
25 return _type == cls.type | 26 return _type == cls.type |
26 | 27 |
27 def __init__(self, url, clobber=False): | 28 def __init__(self, url, clobber=True): |
28 self.subpath = None | 29 self.subpath = None |
29 if '#' in url: | 30 if '#' in url: |
30 url, self.subpath = url.rsplit('#') | 31 url, self.subpath = url.rsplit('#') |
31 self.url = url | 32 self.url = url |
32 # self.clobber = clobber # unused | 33 self.clobber = clobber |
33 | 34 |
34 def __call__(self, dest): | 35 def __call__(self, dest): |
35 raise NotImplementedError("Should be called by implementing class") | 36 raise NotImplementedError("Should be called by implementing class") |
36 | 37 |
37 @classmethod | 38 @classmethod |
106 def __init__(self, url, export=True): | 107 def __init__(self, url, export=True): |
107 VCSFetcher.__init__(self, url, export=True) | 108 VCSFetcher.__init__(self, url, export=True) |
108 self.hg = which('hg') | 109 self.hg = which('hg') |
109 | 110 |
110 def __call__(self, dest): | 111 def __call__(self, dest): |
111 if os.path.exits(dest): | 112 if os.path.exists(dest): |
112 assert os.path.isdir(dest) and os.path.exists(os.path.join(dest, '.hg')) | 113 assert os.path.isdir(dest) and os.path.exists(os.path.join(dest, '.hg')) |
113 call([self.hg, 'pull', self.url], cwd=dest) | 114 call([self.hg, 'pull', self.url], cwd=dest) |
114 call([self.hg, 'update'], cwd=dest) | 115 call([self.hg, 'update'], cwd=dest) |
115 else: | 116 else: |
116 pass | 117 if not os.path.exists(dest): |
117 raise NotImplementedError("TODO! Sorry!") | 118 os.mkdirs(dest) |
119 call([self.hg, 'clone', self.url, dest]) | |
118 | 120 |
119 fetchers.append(HgFetcher) | 121 fetchers.append(HgFetcher) |
120 | 122 |
121 if which('git'): | 123 if which('git'): |
122 | 124 |
124 """checkout a git repository""" | 126 """checkout a git repository""" |
125 type = 'git' | 127 type = 'git' |
126 | 128 |
127 def __init__(self, url, export=True): | 129 def __init__(self, url, export=True): |
128 VCSFetcher.__init__(self, url, export=True) | 130 VCSFetcher.__init__(self, url, export=True) |
129 self.hg = which('git') | 131 self.git = which('git') |
132 | |
133 def __call__(self, url | |
130 | 134 |
131 fetchers.append(GitFetcher) | 135 fetchers.append(GitFetcher) |
132 | 136 |
133 __all__ += [i.__name__ for i in fetchers] | 137 __all__ += [i.__name__ for i in fetchers] |
134 | 138 |