aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/wrap/wrap.py
diff options
context:
space:
mode:
authorAlexandreFoley <alexandre.foley@usherbrooke.ca>2016-10-19 17:10:00 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2016-10-20 00:10:00 +0300
commit263cb6a5f0dcbffdf25e159b3bfa07988838aae9 (patch)
treedf61ed2dccd681c7f593af38e325b6ff881ec4e5 /mesonbuild/wrap/wrap.py
parente9089101876e4a6ce9192199f9193720ef6bb816 (diff)
downloadmeson-263cb6a5f0dcbffdf25e159b3bfa07988838aae9.zip
meson-263cb6a5f0dcbffdf25e159b3bfa07988838aae9.tar.gz
meson-263cb6a5f0dcbffdf25e159b3bfa07988838aae9.tar.bz2
add support of mercurial repo for wrap,… (#937)
* add support for wrap of mercurial repo, and a test with a clone of the sample subproject used for the git test into a mercuriel repo. * Added myself to author list, and switched the URL of the sample subproject in the wrap file to one under the control of the project's maintainers.
Diffstat (limited to 'mesonbuild/wrap/wrap.py')
-rw-r--r--mesonbuild/wrap/wrap.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py
index 16293e8..e05c641 100644
--- a/mesonbuild/wrap/wrap.py
+++ b/mesonbuild/wrap/wrap.py
@@ -66,6 +66,8 @@ class PackageDefinition:
self.type = 'file'
elif first == '[wrap-git]':
self.type = 'git'
+ elif first == '[wrap-hg]':
+ self.type = 'hg'
else:
raise RuntimeError('Invalid format of package file')
for line in ifile:
@@ -105,6 +107,8 @@ class Resolver:
self.extract_package(p)
elif p.type == 'git':
self.get_git(p)
+ elif p.type == "hg":
+ self.get_hg(p)
else:
raise RuntimeError('Unreachable code.')
return p.get('directory')
@@ -130,7 +134,27 @@ class Resolver:
if revno.lower() != 'head':
subprocess.check_call(['git', 'checkout', revno],
cwd=checkoutdir)
-
+ def get_hg(self, p):
+ checkoutdir = os.path.join(self.subdir_root, p.get('directory'))
+ revno = p.get('revision')
+ is_there = os.path.isdir(checkoutdir)
+ if is_there:
+ if revno.lower() == 'tip':
+ # Failure to do pull is not a fatal error,
+ # because otherwise you can't develop without
+ # a working net connection.
+ subprocess.call(['hg', 'pull'], cwd=checkoutdir)
+ else:
+ if subprocess.call(['hg', 'checkout', revno], cwd=checkoutdir) != 0:
+ subprocess.check_call(['hg', 'pull'], cwd=checkoutdir)
+ subprocess.check_call(['hg', 'checkout', revno],
+ cwd=checkoutdir)
+ else:
+ subprocess.check_call(['hg', 'clone', p.get('url'),
+ p.get('directory')], cwd=self.subdir_root)
+ if revno.lower() != 'tip':
+ subprocess.check_call(['hg', 'checkout', revno],
+ cwd=checkoutdir)
def get_data(self, url):
blocksize = 10*1024