diff options
Diffstat (limited to 'mesonbuild/wrap/wrap.py')
-rw-r--r-- | mesonbuild/wrap/wrap.py | 25 |
1 files changed, 15 insertions, 10 deletions
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], |