# HG changeset patch # User Jeff Hammel # Date 1321330797 28800 # Node ID e628ce3ae49ffef87bd644abcd18322edb4e4d36 # Parent b1f65f3bd1bcb376e2d11b8593ec8dbe2b40de70 more stubbing diff -r b1f65f3bd1bc -r e628ce3ae49f fetch.py --- a/fetch.py Thu Nov 10 08:16:48 2011 -0800 +++ b/fetch.py Mon Nov 14 20:19:57 2011 -0800 @@ -29,6 +29,8 @@ self.subpath = None if '#' in url: url, self.subpath = url.rsplit('#') + if self.subpath: + self.subpath = self.subpath.split('/') self.url = url self.clobber = clobber @@ -49,6 +51,7 @@ class FileFetcher(Fetcher): """fetch a single file""" + # Note: subpath for files is ignored type = 'file' @@ -57,6 +60,7 @@ return urllib2.urlopen(url).read() def __call__(self, dest): + if os.path.isdir(dest): filename = self.url.rsplit('/', 1)[-1] dest = os.path.join(dest, filename) @@ -109,8 +113,30 @@ self.export = export def __call__(self, dest): + + if self.subpath or self.export: + # can only export with a subpath + + + if os.path.exists(dest): + assert os.path.isdir(dest) + + def export(self, dest): + """ + export a clone of the directory + """ + tmpdir = tempfile.mkdtmp() + self.clone(tmpdir) + + shutil.rmtree(tmpdir) + + def clone(self, dest): + """ + clones into a directory + """ raise NotImplementedError("Abstract base class") + if which('hg'): class HgFetcher(VCSFetcher): @@ -120,6 +146,7 @@ def __init__(self, url, export=True): VCSFetcher.__init__(self, url, export=True) self.hg = which('hg') + assert self.hg, "'hg' command not found" def __call__(self, dest): if os.path.exists(dest):