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.
This commit is contained in:
AlexandreFoley 2016-10-19 17:10:00 -04:00 committed by Jussi Pakkanen
parent e908910187
commit 263cb6a5f0
5 changed files with 46 additions and 1 deletions

View File

@ -50,3 +50,4 @@ Emanuele Aina
Guillaume Poirier-Morency
Scott D Phillips
Gautier Pelloux-Prayer
Alexandre Foley

View File

@ -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)

View File

@ -0,0 +1,6 @@
#include"subproj.h"
int main(int argc, char **argv) {
subproj_function();
return 0;
}

View File

@ -0,0 +1,4 @@
[wrap-hg]
directory=samplesubproject
url=https://bitbucket.org/jpakkane/samplesubproject
revision=tip

View File

@ -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