diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2012-10-23 20:39:03 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2012-10-23 20:39:03 -0400 |
commit | 1747a08955d6db3c7ad4403128501ea13d48ac40 (patch) | |
tree | 8a821daaedc549900dda506e6e13503040451422 /setuptools/package_index.py | |
parent | 89efff76bc23c4859bfc21e6d4522cf5396a12b3 (diff) | |
parent | fa1318a4b29050341b5397685bc26ecf6ed57d52 (diff) | |
download | external_python_setuptools-1747a08955d6db3c7ad4403128501ea13d48ac40.tar.gz external_python_setuptools-1747a08955d6db3c7ad4403128501ea13d48ac40.tar.bz2 external_python_setuptools-1747a08955d6db3c7ad4403128501ea13d48ac40.zip |
Merged in pkoch/distribute (pull request #21)
--HG--
branch : distribute
extra : rebase_source : 1e4ad7f02d0718b3665aa2e2405721d64e42fc1b
Diffstat (limited to 'setuptools/package_index.py')
-rwxr-xr-x | setuptools/package_index.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py index ffbffa99..7a954e21 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -657,6 +657,10 @@ class PackageIndex(Environment): # if scheme=='svn' or scheme.startswith('svn+'): return self._download_svn(url, filename) + elif scheme=='git' or scheme.startswith('git+'): + return self._download_git(url, filename) + elif scheme.startswith('hg+'): + return self._download_hg(url, filename) elif scheme=='file': return urllib.url2pathname(urlparse.urlparse(url)[2]) else: @@ -697,6 +701,55 @@ class PackageIndex(Environment): os.system("svn checkout -q %s %s" % (url, filename)) return filename + def _vcs_split_rev_from_url(self, url, pop_prefix=False): + scheme, netloc, path, query, frag = urlparse.urlsplit(url) + + scheme = scheme.split('+', 1)[-1] + + # Some fragment identification fails + path = path.split('#',1)[0] + + rev = None + if '@' in path: + path, rev = path.rsplit('@', 1) + + # Also, discard fragment + url = urlparse.urlunsplit((scheme, netloc, path, query, '')) + + return url, rev + + def _download_git(self, url, filename): + filename = filename.split('#',1)[0] + url, rev = self._vcs_split_rev_from_url(url, pop_prefix=True) + + self.info("Doing git clone from %s to %s", url, filename) + os.system("git clone --quiet %s %s" % (url, filename)) + + if rev is not None: + self.info("Checking out %s", rev) + os.system("(cd %s && git checkout --quiet %s)" % ( + filename, + rev, + )) + + return filename + + def _download_hg(self, url, filename): + filename = filename.split('#',1)[0] + url, rev = self._vcs_split_rev_from_url(url, pop_prefix=True) + + self.info("Doing hg clone from %s to %s", url, filename) + os.system("hg clone --quiet %s %s" % (url, filename)) + + if rev is not None: + self.info("Updating to %s", rev) + os.system("(cd %s && hg up -C -r %s >&-)" % ( + filename, + rev, + )) + + return filename + def debug(self, msg, *args): log.debug(msg, *args) |