diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-12-29 16:23:14 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-12-29 16:29:00 -0700 |
commit | 8c0afc13ad5eefea62b0b136f5b66792ba4e44cb (patch) | |
tree | cbd4a1da67150987f961e25acf25ca007465abf6 /lib/bb/fetch | |
parent | 683894e3a9be25b060e60be900a5bc1271d450d2 (diff) | |
download | bitbake-8c0afc13ad5eefea62b0b136f5b66792ba4e44cb.tar.gz |
fetch: resurrect branch inclusion in git revision key
This is similar to Richard Purdie's commit, but falls back to checking the
persist_data database for the old key if the new does not exist, so as to
retain compatibility for at least one bitbake minor version.
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb/fetch')
-rw-r--r-- | lib/bb/fetch/git.py | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/bb/fetch/git.py b/lib/bb/fetch/git.py index 5fd775025..05be55ccf 100644 --- a/lib/bb/fetch/git.py +++ b/lib/bb/fetch/git.py @@ -22,6 +22,7 @@ BitBake 'Fetch' git implementation import os import bb +import bb.persist_data from bb import data from bb.fetch import Fetch from bb.fetch import runfetchcmd @@ -206,11 +207,19 @@ class Git(Fetch): output = runfetchcmd("%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (basecmd, tag), d, quiet=True) return output.split()[0] != "0" - def _revision_key(self, url, ud, d): + def _revision_key(self, url, ud, d, branch=False): """ Return a unique key for the url """ - return "git:" + ud.host + ud.path.replace('/', '.') + key = 'git:' + ud.host + ud.path.replace('/', '.') + if branch: + return key + ud.branch + else: + return key + + def generate_revision_key(self, url, ud, d, branch=False): + key = self._revision_key(url, ud, d, branch) + return "%s-%s" % (key, bb.data.getVar("PN", d, True) or "") def _latest_revision(self, url, ud, d): """ @@ -228,6 +237,27 @@ class Git(Fetch): raise bb.fetch.FetchError("Fetch command %s gave empty output\n" % (cmd)) return output.split()[0] + def latest_revision(self, url, ud, d): + """ + Look in the cache for the latest revision, if not present ask the SCM. + """ + persisted = bb.persist_data.persist(d) + revs = persisted['BB_URI_HEADREVS'] + + key = self.generate_revision_key(url, ud, d, branch=True) + rev = revs[key] + if rev is None: + # Compatibility with old key format, no branch included + oldkey = self.generate_revision_key(url, ud, d, branch=False) + rev = revs[oldkey] + if rev is not None: + del revs[oldkey] + else: + rev = self._latest_revision(url, ud, d) + revs[key] = rev + + return str(rev) + def _build_revision(self, url, ud, d): return ud.tag |