bitbake: fetch2/git: Clean up sortable_revision
Now we no longer try and provide increasing values from the fetcher, we can simplify the function structure for the sortable_revision pieces and move the AUTOINC handling directly into the function which needs it, simplifying the code. (Bitbake rev: fb068bee47bb1a06f02447daf16c2b2a79c03288) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
608821349c
commit
d228f9d938
|
@ -619,7 +619,10 @@ def get_srcrev(d):
|
||||||
raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI")
|
raise FetchError("SRCREV was used yet no valid SCM was found in SRC_URI")
|
||||||
|
|
||||||
if len(scms) == 1 and len(urldata[scms[0]].names) == 1:
|
if len(scms) == 1 and len(urldata[scms[0]].names) == 1:
|
||||||
return urldata[scms[0]].method.sortable_revision(scms[0], urldata[scms[0]], d, urldata[scms[0]].names[0])
|
autoinc, rev = urldata[scms[0]].method.sortable_revision(scms[0], urldata[scms[0]], d, urldata[scms[0]].names[0])
|
||||||
|
if autoinc:
|
||||||
|
return "AUTOINC+" + rev
|
||||||
|
return rev
|
||||||
|
|
||||||
#
|
#
|
||||||
# Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT
|
# Mutiple SCMs are in SRC_URI so we resort to SRCREV_FORMAT
|
||||||
|
@ -628,18 +631,14 @@ def get_srcrev(d):
|
||||||
if not format:
|
if not format:
|
||||||
raise FetchError("The SRCREV_FORMAT variable must be set when multiple SCMs are used.")
|
raise FetchError("The SRCREV_FORMAT variable must be set when multiple SCMs are used.")
|
||||||
|
|
||||||
autoinc = False
|
seenautoinc = False
|
||||||
autoinc_templ = 'AUTOINC+'
|
|
||||||
for scm in scms:
|
for scm in scms:
|
||||||
ud = urldata[scm]
|
ud = urldata[scm]
|
||||||
for name in ud.names:
|
for name in ud.names:
|
||||||
rev = ud.method.sortable_revision(scm, ud, d, name)
|
autoinc, rev = ud.method.sortable_revision(scm, ud, d, name)
|
||||||
if rev.startswith(autoinc_templ):
|
if autoinc and not seenautoinc:
|
||||||
if not autoinc:
|
rev = "AUTOINC+" + rev
|
||||||
autoinc = True
|
seenautoinc
|
||||||
format = "%s%s" % (autoinc_templ, format)
|
|
||||||
rev = rev[len(autoinc_templ):]
|
|
||||||
|
|
||||||
format = format.replace(name, rev)
|
format = format.replace(name, rev)
|
||||||
|
|
||||||
return format
|
return format
|
||||||
|
@ -1277,14 +1276,8 @@ class FetchMethod(object):
|
||||||
return rev
|
return rev
|
||||||
|
|
||||||
def sortable_revision(self, url, ud, d, name):
|
def sortable_revision(self, url, ud, d, name):
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
|
||||||
if hasattr(self, "_sortable_revision"):
|
|
||||||
return self._sortable_revision(url, ud, d)
|
|
||||||
|
|
||||||
latest_rev = self._build_revision(url, ud, d, name)
|
latest_rev = self._build_revision(url, ud, d, name)
|
||||||
return 'AUTOINC+%s' % str(latest_rev)
|
return True, str(latest_rev)
|
||||||
|
|
||||||
def generate_revision_key(self, url, ud, d, name):
|
def generate_revision_key(self, url, ud, d, name):
|
||||||
key = self._revision_key(url, ud, d, name)
|
key = self._revision_key(url, ud, d, name)
|
||||||
|
|
|
@ -132,12 +132,12 @@ class Bzr(FetchMethod):
|
||||||
|
|
||||||
return output.strip()
|
return output.strip()
|
||||||
|
|
||||||
def _sortable_revision(self, url, ud, d):
|
def sortable_revision(self, url, ud, d, name):
|
||||||
"""
|
"""
|
||||||
Return a sortable revision number which in our case is the revision number
|
Return a sortable revision number which in our case is the revision number
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self._build_revision(url, ud, d)
|
return False, self._build_revision(url, ud, d)
|
||||||
|
|
||||||
def _build_revision(self, url, ud, d):
|
def _build_revision(self, url, ud, d):
|
||||||
return ud.revision
|
return ud.revision
|
||||||
|
|
|
@ -178,12 +178,12 @@ class Svn(FetchMethod):
|
||||||
|
|
||||||
return revision
|
return revision
|
||||||
|
|
||||||
def _sortable_revision(self, url, ud, d):
|
def sortable_revision(self, url, ud, d, name):
|
||||||
"""
|
"""
|
||||||
Return a sortable revision number which in our case is the revision number
|
Return a sortable revision number which in our case is the revision number
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self._build_revision(url, ud, d)
|
return False, self._build_revision(url, ud, d)
|
||||||
|
|
||||||
def _build_revision(self, url, ud, d):
|
def _build_revision(self, url, ud, d):
|
||||||
return ud.revision
|
return ud.revision
|
||||||
|
|
Loading…
Reference in New Issue