summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAndre McCurdy <armccurdy@gmail.com>2018-05-07 18:02:12 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-05-22 13:13:19 +0100
commitb68ed05be66eb045cb3fc74b201ce798766c3d1a (patch)
treebf804c511404c7f745655c08b177f99cd73320e7 /bitbake
parent13cc30cd7de4841990b600e83e1249c81a5171dd (diff)
downloadpoky-b68ed05be66eb045cb3fc74b201ce798766c3d1a.tar.gz
bitbake: fetch/git: make fewer calls to _contains_ref() from download()
Updating a local git repo clone currently results in multiple calls to self._contains_ref(), some of which appear to be redundant and can be eliminated by minor tweaks to the logic in download(). Also drop redundant calls to os.path.exists(ud.clonedir) before self.need_update(), since need_update() includes its own built-in check for the existance of ud.clonedir. (Bitbake rev: 61b0df5523afc8f805043f3adc9c106690e6f133) Signed-off-by: Andre McCurdy <armccurdy@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/git.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 3de83bed17..b733be9f38 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -322,16 +322,13 @@ class Git(FetchMethod):
322 def download(self, ud, d): 322 def download(self, ud, d):
323 """Fetch url""" 323 """Fetch url"""
324 324
325 no_clone = not os.path.exists(ud.clonedir)
326 need_update = no_clone or self.need_update(ud, d)
327
328 # A current clone is preferred to either tarball, a shallow tarball is 325 # A current clone is preferred to either tarball, a shallow tarball is
329 # preferred to an out of date clone, and a missing clone will use 326 # preferred to an out of date clone, and a missing clone will use
330 # either tarball. 327 # either tarball.
331 if ud.shallow and os.path.exists(ud.fullshallow) and need_update: 328 if ud.shallow and os.path.exists(ud.fullshallow) and self.need_update(ud, d):
332 ud.localpath = ud.fullshallow 329 ud.localpath = ud.fullshallow
333 return 330 return
334 elif os.path.exists(ud.fullmirror) and no_clone: 331 elif os.path.exists(ud.fullmirror) and not os.path.exists(ud.clonedir):
335 bb.utils.mkdirhier(ud.clonedir) 332 bb.utils.mkdirhier(ud.clonedir)
336 runfetchcmd("tar -xzf %s" % ud.fullmirror, d, workdir=ud.clonedir) 333 runfetchcmd("tar -xzf %s" % ud.fullmirror, d, workdir=ud.clonedir)
337 334
@@ -353,6 +350,8 @@ class Git(FetchMethod):
353 for name in ud.names: 350 for name in ud.names:
354 if not self._contains_ref(ud, d, name, ud.clonedir): 351 if not self._contains_ref(ud, d, name, ud.clonedir):
355 needupdate = True 352 needupdate = True
353 break
354
356 if needupdate: 355 if needupdate:
357 try: 356 try:
358 runfetchcmd("%s remote rm origin" % ud.basecmd, d, workdir=ud.clonedir) 357 runfetchcmd("%s remote rm origin" % ud.basecmd, d, workdir=ud.clonedir)
@@ -373,6 +372,7 @@ class Git(FetchMethod):
373 except OSError as exc: 372 except OSError as exc:
374 if exc.errno != errno.ENOENT: 373 if exc.errno != errno.ENOENT:
375 raise 374 raise
375
376 for name in ud.names: 376 for name in ud.names:
377 if not self._contains_ref(ud, d, name, ud.clonedir): 377 if not self._contains_ref(ud, d, name, ud.clonedir):
378 raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name])) 378 raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
@@ -472,7 +472,7 @@ class Git(FetchMethod):
472 if os.path.exists(destdir): 472 if os.path.exists(destdir):
473 bb.utils.prunedir(destdir) 473 bb.utils.prunedir(destdir)
474 474
475 if ud.shallow and (not os.path.exists(ud.clonedir) or self.need_update(ud, d)): 475 if ud.shallow and self.need_update(ud, d):
476 bb.utils.mkdirhier(destdir) 476 bb.utils.mkdirhier(destdir)
477 runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=destdir) 477 runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=destdir)
478 else: 478 else: