fetch: Drop multiple branch/revision support for single git urls
PATCH 1/1 fetch: Drop multiple branch/revision support for single git urls
We used to use this for bare clones where a single git url could handle multiple revisions (which implied multiple branches).
We don't use this any more and I doubt we'd want to go back to it. If we remove it, we can simplfy the looping in the code which seems desireable.
This patch does change the warning for missing branch parameters to a error. The message has hinted about that for long enough.
Some test cases are removed since they are no longer needed.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/fetch2/__init__.py | 44 ++++---- lib/bb/fetch2/git.py | 217 +++++++++++++++++--------------------- lib/bb/fetch2/gitsm.py | 51 +++++---- lib/bb/fetch2/gomod.py | 7 +- lib/bb/tests/fetch.py | 122 +-------------------- 5 files changed, 149 insertions(+), 292 deletions(-)
lib/bb/fetch2/__init__.py +22 -22
@@ -806,8 +806,8 @@ def _get_srcrev(d, method_name='sortable_revision'): return "", revs - if len(scms) == 1 and len(urldata[scms[0]].names) == 1: - autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].names[0]) + if len(scms) == 1: + autoinc, rev = getattr(urldata[scms[0]].method, method_name)(urldata[scms[0]], d, urldata[scms[0]].name) revs.append(rev) if len(rev) > 10: rev = rev[:10]
@@ -828,13 +828,12 @@ def _get_srcrev(d, method_name='sortable_revision'): seenautoinc = False for scm in scms: ud = urldata[scm] - for name in ud.names: - autoinc, rev = getattr(ud.method, method_name)(ud, d, name) - revs.append(rev) - seenautoinc = seenautoinc or autoinc - if len(rev) > 10: - rev = rev[:10] - name_to_rev[name] = rev + autoinc, rev = getattr(ud.method, method_name)(ud, d, ud.name) + revs.append(rev) + seenautoinc = seenautoinc or autoinc + if len(rev) > 10: + rev = rev[:10] + name_to_rev[ud.name] = rev # Replace names by revisions in the SRCREV_FORMAT string. The approach used # here can handle names being prefixes of other names and names appearing # as substrings in revisions (in which case the name should not be
@@ -1314,8 +1313,6 @@ class FetchData(object): self.localpath = None self.lockfile = None self.mirrortarballs = [] - self.basename = None - self.basepath = None (self.type, self.host, self.path, self.user, self.pswd, self.parm) = decodeurl(d.expand(url)) self.date = self.getSRCDate(d) self.url = url
@@ -1345,7 +1342,9 @@ class FetchData(object): setattr(self, "%s_name" % checksum_id, checksum_name) setattr(self, "%s_expected" % checksum_id, checksum_expected) - self.names = self.parm.get("name",'default').split(',') + self.name = self.parm.get("name",'default') + if "," in self.name: + raise ParameterError("The fetcher no longer supports multiple name parameters in a single url", self.url) self.method = None for m in methods:
@@ -1371,10 +1370,17 @@ class FetchData(object): self.ignore_checksums = False + if not self.localfile and self.needdonestamp: + if 'downloadfilename' in self.parm: + self.localfile = self.parm['downloadfilename'] + else: + self.localfile = os.path.basename(self.path) + if not os.path.basename(self.localfile): + self.localfile = self.host + self.path.replace("/", ".") + if "localpath" in self.parm: # if user sets localpath for file, use it instead. self.localpath = self.parm["localpath"] - self.basename = os.path.basename(self.localpath) elif self.localfile: self.localpath = self.method.localpath(self, d)
@@ -1388,8 +1394,8 @@ class FetchData(object): basepath = self.localpath elif self.localpath: basepath = dldir + os.sep + os.path.basename(self.localpath) - elif self.basepath or self.basename: - basepath = dldir + os.sep + (self.basepath or self.basename) + elif self.localfile: + basepath = dldir + os.sep + self.localfile else: bb.fatal("Can't determine lock path for url %s" % url)
@@ -1397,13 +1403,7 @@ class FetchData(object): self.lockfile = basepath + '.lock' def setup_revisions(self, d): - self.revisions = {} - for name in self.names: - self.revisions[name] = srcrev_internal_helper(self, d, name) - - # add compatibility code for non name specified case - if len(self.names) == 1: - self.revision = self.revisions[self.names[0]] + self.revision = srcrev_internal_helper(self, d, self.name) def setup_localpath(self, d): if not self.localpath:
lib/bb/fetch2/git.py +94 -123
359 lines not on this page · raw message
lib/bb/fetch2/gitsm.py +25 -26
61 lines not on this page · raw message
lib/bb/fetch2/gomod.py +3 -4
@@ -190,15 +190,14 @@ class GoModGit(Git): ud.path = '' if 'protocol' not in ud.parm: ud.parm['protocol'] = 'https' - name = f"{module}@{ud.parm['version']}" - ud.names = [name] - srcrev = d.getVar('SRCREV_' + name) + ud.name = f"{module}@{ud.parm['version']}" + srcrev = d.getVar('SRCREV_' + ud.name) if srcrev: if 'srcrev' not in ud.parm: ud.parm['srcrev'] = srcrev else: if 'srcrev' in ud.parm: - d.setVar('SRCREV_' + name, ud.parm['srcrev']) + d.setVar('SRCREV_' + ud.name, ud.parm['srcrev']) if 'branch' not in ud.parm: ud.parm['nobranch'] = '1'
lib/bb/tests/fetch.py +5 -117
170 lines not on this page · raw message