mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
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>
This commit is contained in:
parent
13cc30cd7d
commit
b68ed05be6
|
@ -322,16 +322,13 @@ class Git(FetchMethod):
|
||||||
def download(self, ud, d):
|
def download(self, ud, d):
|
||||||
"""Fetch url"""
|
"""Fetch url"""
|
||||||
|
|
||||||
no_clone = not os.path.exists(ud.clonedir)
|
|
||||||
need_update = no_clone or self.need_update(ud, d)
|
|
||||||
|
|
||||||
# A current clone is preferred to either tarball, a shallow tarball is
|
# A current clone is preferred to either tarball, a shallow tarball is
|
||||||
# preferred to an out of date clone, and a missing clone will use
|
# preferred to an out of date clone, and a missing clone will use
|
||||||
# either tarball.
|
# either tarball.
|
||||||
if ud.shallow and os.path.exists(ud.fullshallow) and need_update:
|
if ud.shallow and os.path.exists(ud.fullshallow) and self.need_update(ud, d):
|
||||||
ud.localpath = ud.fullshallow
|
ud.localpath = ud.fullshallow
|
||||||
return
|
return
|
||||||
elif os.path.exists(ud.fullmirror) and no_clone:
|
elif os.path.exists(ud.fullmirror) and not os.path.exists(ud.clonedir):
|
||||||
bb.utils.mkdirhier(ud.clonedir)
|
bb.utils.mkdirhier(ud.clonedir)
|
||||||
runfetchcmd("tar -xzf %s" % ud.fullmirror, d, workdir=ud.clonedir)
|
runfetchcmd("tar -xzf %s" % ud.fullmirror, d, workdir=ud.clonedir)
|
||||||
|
|
||||||
|
@ -353,6 +350,8 @@ class Git(FetchMethod):
|
||||||
for name in ud.names:
|
for name in ud.names:
|
||||||
if not self._contains_ref(ud, d, name, ud.clonedir):
|
if not self._contains_ref(ud, d, name, ud.clonedir):
|
||||||
needupdate = True
|
needupdate = True
|
||||||
|
break
|
||||||
|
|
||||||
if needupdate:
|
if needupdate:
|
||||||
try:
|
try:
|
||||||
runfetchcmd("%s remote rm origin" % ud.basecmd, d, workdir=ud.clonedir)
|
runfetchcmd("%s remote rm origin" % ud.basecmd, d, workdir=ud.clonedir)
|
||||||
|
@ -373,6 +372,7 @@ class Git(FetchMethod):
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
if exc.errno != errno.ENOENT:
|
if exc.errno != errno.ENOENT:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
for name in ud.names:
|
for name in ud.names:
|
||||||
if not self._contains_ref(ud, d, name, ud.clonedir):
|
if not self._contains_ref(ud, d, name, ud.clonedir):
|
||||||
raise bb.fetch2.FetchError("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[name]))
|
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):
|
||||||
if os.path.exists(destdir):
|
if os.path.exists(destdir):
|
||||||
bb.utils.prunedir(destdir)
|
bb.utils.prunedir(destdir)
|
||||||
|
|
||||||
if ud.shallow and (not os.path.exists(ud.clonedir) or self.need_update(ud, d)):
|
if ud.shallow and self.need_update(ud, d):
|
||||||
bb.utils.mkdirhier(destdir)
|
bb.utils.mkdirhier(destdir)
|
||||||
runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=destdir)
|
runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=destdir)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user