[bitbake-devel] [PATCH] fetch2/git: Clean up sortable_revision
Richard Purdie
richard.purdie at linuxfoundation.org
Sun May 19 10:17:58 UTC 2013
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.
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index dd1cc93..f8f8244 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -616,7 +616,10 @@ def get_srcrev(d):
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:
- 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
@@ -625,18 +628,14 @@ def get_srcrev(d):
if not format:
raise FetchError("The SRCREV_FORMAT variable must be set when multiple SCMs are used.")
- autoinc = False
- autoinc_templ = 'AUTOINC+'
+ seenautoinc = False
for scm in scms:
ud = urldata[scm]
for name in ud.names:
- rev = ud.method.sortable_revision(scm, ud, d, name)
- if rev.startswith(autoinc_templ):
- if not autoinc:
- autoinc = True
- format = "%s%s" % (autoinc_templ, format)
- rev = rev[len(autoinc_templ):]
-
+ autoinc, rev = ud.method.sortable_revision(scm, ud, d, name)
+ if autoinc and not seenautoinc:
+ rev = "AUTOINC+" + rev
+ seenautoinc
format = format.replace(name, rev)
return format
@@ -1280,14 +1279,8 @@ class FetchMethod(object):
return rev
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)
- return 'AUTOINC+%s' % str(latest_rev)
+ return True, str(latest_rev)
def generate_revision_key(self, url, ud, d, name):
key = self._revision_key(url, ud, d, name)
diff --git a/bitbake/lib/bb/fetch2/bzr.py b/bitbake/lib/bb/fetch2/bzr.py
index 58e80c8..5d9e5f9 100644
--- a/bitbake/lib/bb/fetch2/bzr.py
+++ b/bitbake/lib/bb/fetch2/bzr.py
@@ -132,12 +132,12 @@ class Bzr(FetchMethod):
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 self._build_revision(url, ud, d)
+ return False, self._build_revision(url, ud, d)
def _build_revision(self, url, ud, d):
return ud.revision
diff --git a/bitbake/lib/bb/fetch2/svn.py b/bitbake/lib/bb/fetch2/svn.py
index cbf929e..9a779d2 100644
--- a/bitbake/lib/bb/fetch2/svn.py
+++ b/bitbake/lib/bb/fetch2/svn.py
@@ -178,12 +178,12 @@ class Svn(FetchMethod):
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 self._build_revision(url, ud, d)
+ return False, self._build_revision(url, ud, d)
def _build_revision(self, url, ud, d):
return ud.revision
More information about the bitbake-devel
mailing list