diff --git a/authors.txt b/authors.txt index a51badd67..bdad5bdf5 100644 --- a/authors.txt +++ b/authors.txt @@ -50,3 +50,4 @@ Emanuele Aina Guillaume Poirier-Morency Scott D Phillips Gautier Pelloux-Prayer +Alexandre Foley diff --git a/manual tests/10 hg wrap/meson.build b/manual tests/10 hg wrap/meson.build new file mode 100644 index 000000000..c7ac004ca --- /dev/null +++ b/manual tests/10 hg wrap/meson.build @@ -0,0 +1,10 @@ +project('Mercurial outcheckker', 'c') + +sp = subproject('samplesubproject') + +exe = executable('gitprog', 'prog.c', +include_directories : sp.get_variable('subproj_inc'), +link_with : sp.get_variable('subproj_lib'), +) + +test('maintest', exe) diff --git a/manual tests/10 hg wrap/prog.c b/manual tests/10 hg wrap/prog.c new file mode 100644 index 000000000..df38000ec --- /dev/null +++ b/manual tests/10 hg wrap/prog.c @@ -0,0 +1,6 @@ +#include"subproj.h" + +int main(int argc, char **argv) { + subproj_function(); + return 0; +} diff --git a/manual tests/10 hg wrap/subprojects/samplesubproject.wrap b/manual tests/10 hg wrap/subprojects/samplesubproject.wrap new file mode 100644 index 000000000..6d3b3f2d4 --- /dev/null +++ b/manual tests/10 hg wrap/subprojects/samplesubproject.wrap @@ -0,0 +1,4 @@ +[wrap-hg] +directory=samplesubproject +url=https://bitbucket.org/jpakkane/samplesubproject +revision=tip diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 16293e882..e05c641c6 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