From 228adaa287517015a5ec86d36fbd60b4bb031a31 Mon Sep 17 00:00:00 2001 From: Alexandre Foley Date: Mon, 5 Dec 2016 17:25:36 -0500 Subject: =?UTF-8?q?Wrap.py:=20Made=20it=20so=20using=20an=20already=20down?= =?UTF-8?q?loaded=20subproject=20is=20only=20for=20the=20wrap-file=20case.?= =?UTF-8?q?=20Git=20and=20Mercurial=20can=20update=20the=20repository=20if?= =?UTF-8?q?=20it=20the=20wrap=20is=20one.=20Also=20did=20a=20bit=20of=20cl?= =?UTF-8?q?eanup.=20interpreter.py:=20There=E2=80=99s=20a=20catch=20all=20?= =?UTF-8?q?except=20clause=20at=20the=20line=201928,=20it=20didn=E2=80=99t?= =?UTF-8?q?=20give=20the=20user=20any=20information=20whatsoever=20about?= =?UTF-8?q?=20the=20exception=20it=20caught.=20Now=20it=20at=20least=20pri?= =?UTF-8?q?nt=20it=20to=20the=20log=20as=20a=20warning.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mesonbuild/interpreter.py | 5 +++-- mesonbuild/wrap/wrap.py | 25 +++++++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index e9273e4..9ab68be 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1925,8 +1925,9 @@ requirements use the version keyword argument instead.''') raise # If the subproject execution failed in a non-fatal way, don't raise an # exception; let the caller handle things. - except: - mlog.log('Also couldn\'t find a fallback subproject in', + except Exception as e: + mlog.warning(e) + mlog.log('Couldn\'t find a fallback subproject in', mlog.bold(os.path.join(self.subproject_dir, dirname)), 'for the dependency', mlog.bold(name)) return None diff --git a/mesonbuild/wrap/wrap.py b/mesonbuild/wrap/wrap.py index 37d6df7..1ebff3c 100644 --- a/mesonbuild/wrap/wrap.py +++ b/mesonbuild/wrap/wrap.py @@ -94,13 +94,10 @@ class Resolver: fname = os.path.join(self.subdir_root, packagename + '.wrap') dirname = os.path.join(self.subdir_root, packagename) try: - if os.listdir(dirname): - # The directory is there and not empty? Great, use it. - return packagename - else: - mlog.warning('Subproject directory %s is empty, possibly because of an unfinished' - 'checkout, removing to reclone' % dirname) - os.rmdir(checkoutdir) + if not os.listdir(dirname): + mlog.warning('Subproject directory %s is empty, removing to' + ' ensure clean download' % dirname) + os.rmdir(dirname) except NotADirectoryError: raise RuntimeError('%s is not a directory, can not use as subproject.' % dirname) except FileNotFoundError: @@ -111,6 +108,11 @@ class Resolver: return None p = PackageDefinition(fname) if p.type == 'file': + if os.path.isdir(dirname): + # project already there? great, use it! + # only for the file case because otherwise we prevent git + # and hg from updating the subproject. or doing that fancy git push feature that doesn't belong + return packagename if not os.path.isdir(self.cachedir): os.mkdir(self.cachedir) self.download(p, packagename) @@ -130,12 +132,11 @@ class Resolver: if is_there: try: subprocess.check_call(['git', 'rev-parse']) - is_there = True except subprocess.CalledProcessError: raise RuntimeError('%s is not empty but is not a valid ' 'git repository, we can not work with it' - ' as a subproject directory.' % ( - checkoutdir)) + ' as a subproject directory.' + % (checkoutdir)) if revno.lower() == 'head': # Failure to do pull is not a fatal error, @@ -163,12 +164,16 @@ class Resolver: revno = p.get('revision') is_there = os.path.isdir(checkoutdir) if is_there: + #Need to add a check that the directory is a valid HG repo 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) + subprocess.call(['hg','update','tip'],cwd = checkoutdir) else: + #check that the tag/branch/revision we want is available in the + # repo, if not, pull and update. if subprocess.call(['hg', 'checkout', revno], cwd=checkoutdir) != 0: subprocess.check_call(['hg', 'pull'], cwd=checkoutdir) subprocess.check_call(['hg', 'checkout', revno], -- cgit v1.1