summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm/models.py
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-07-21 14:43:30 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-26 08:10:36 +0100
commit97278fb51c3d4fe46c2a3110015e291fdc5d502d (patch)
tree2535f7584e2ccc4390ecfbaf16031e8b8886e4c5 /bitbake/lib/toaster/orm/models.py
parent8b3146007f98ba6618662cc47ed1c1491ef8945a (diff)
downloadpoky-97278fb51c3d4fe46c2a3110015e291fdc5d502d.tar.gz
bitbake: toaster: orm Remove the layerindex specific up_branch fields
We don't need to keep track of layerindex data in our database. And using branch==release is very confusing in the schema. Instead use the existing Release definition to keep track of which release a layer_version is for. Remove the Branch model and all references to it. Create a migration path to convert from up_branches to their corresponding releases. (Bitbake rev: f8f4cffe6fd371f3a7e63690c68f3fcb5dc1f297) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r--bitbake/lib/toaster/orm/models.py32
1 files changed, 8 insertions, 24 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 34ea28c270..72b9dfeaa8 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -144,7 +144,7 @@ class ProjectManager(models.Manager):
144 for rdl in release.releasedefaultlayer_set.all(): 144 for rdl in release.releasedefaultlayer_set.all():
145 lv = Layer_Version.objects.filter( 145 lv = Layer_Version.objects.filter(
146 layer__name=rdl.layer_name, 146 layer__name=rdl.layer_name,
147 up_branch__name=release.branch_name).first() 147 release=release).first()
148 148
149 if lv: 149 if lv:
150 ProjectLayer.objects.create(project=prj, 150 ProjectLayer.objects.create(project=prj,
@@ -280,7 +280,7 @@ class Project(models.Model):
280 # guard on release, as it can be null 280 # guard on release, as it can be null
281 if self.release: 281 if self.release:
282 queryset = Layer_Version.objects.filter( 282 queryset = Layer_Version.objects.filter(
283 (Q(up_branch__name=self.release.branch_name) & 283 (Q(release=self.release) &
284 Q(build=None) & 284 Q(build=None) &
285 Q(project=None)) | 285 Q(project=None)) |
286 Q(project=self)) 286 Q(project=self))
@@ -1257,22 +1257,6 @@ class ReleaseDefaultLayer(models.Model):
1257 layer_name = models.CharField(max_length=100, default="") 1257 layer_name = models.CharField(max_length=100, default="")
1258 1258
1259 1259
1260# Branch class is synced with layerindex.Branch, branches can only come
1261# from remote layer indexes
1262class Branch(models.Model):
1263 # id of branch in the layerindex
1264 up_date = models.DateTimeField(null=True, default=None)
1265
1266 name = models.CharField(max_length=50)
1267 short_description = models.CharField(max_length=50, blank=True)
1268
1269 class Meta:
1270 verbose_name_plural = "Branches"
1271
1272 def __unicode__(self):
1273 return self.name
1274
1275
1276class LayerSource(object): 1260class LayerSource(object):
1277 """ Where the layer metadata came from """ 1261 """ Where the layer metadata came from """
1278 TYPE_LOCAL = 0 1262 TYPE_LOCAL = 0
@@ -1321,7 +1305,7 @@ class Layer_Version(models.Model):
1321 """ 1305 """
1322 search_allowed_fields = ["layer__name", "layer__summary", 1306 search_allowed_fields = ["layer__name", "layer__summary",
1323 "layer__description", "layer__vcs_url", 1307 "layer__description", "layer__vcs_url",
1324 "dirpath", "up_branch__name", "commit", "branch"] 1308 "dirpath", "release__name", "commit", "branch"]
1325 1309
1326 build = models.ForeignKey(Build, related_name='layer_version_build', 1310 build = models.ForeignKey(Build, related_name='layer_version_build',
1327 default=None, null=True) 1311 default=None, null=True)
@@ -1333,8 +1317,8 @@ class Layer_Version(models.Model):
1333 1317
1334 up_date = models.DateTimeField(null=True, default=timezone.now) 1318 up_date = models.DateTimeField(null=True, default=timezone.now)
1335 1319
1336 # layerindex specific field 1320 # To which metadata release does this layer version belong to
1337 up_branch = models.ForeignKey(Branch, null=True, default=None) 1321 release = models.ForeignKey(Release, null=True, default=None)
1338 1322
1339 branch = models.CharField(max_length=80) 1323 branch = models.CharField(max_length=80)
1340 commit = models.CharField(max_length=100) 1324 commit = models.CharField(max_length=100)
@@ -1368,7 +1352,7 @@ class Layer_Version(models.Model):
1368 extra_path = self.dirpath 1352 extra_path = self.dirpath
1369 else: 1353 else:
1370 extra_path = path 1354 extra_path = path
1371 branchname = self.up_branch.name 1355 branchname = self.release.name
1372 url = base_url.replace('%branch%', branchname) 1356 url = base_url.replace('%branch%', branchname)
1373 1357
1374 # If there's a % in the path (e.g. a wildcard bbappend) we need to encode it 1358 # If there's a % in the path (e.g. a wildcard bbappend) we need to encode it
@@ -1404,8 +1388,8 @@ class Layer_Version(models.Model):
1404 def get_vcs_reference(self): 1388 def get_vcs_reference(self):
1405 if self.branch is not None and len(self.branch) > 0: 1389 if self.branch is not None and len(self.branch) > 0:
1406 return self.branch 1390 return self.branch
1407 if self.up_branch is not None: 1391 if self.release is not None:
1408 return self.up_branch.name 1392 return self.release.name
1409 if self.commit is not None and len(self.commit) > 0: 1393 if self.commit is not None and len(self.commit) > 0:
1410 return self.commit 1394 return self.commit
1411 return 'N/A' 1395 return 'N/A'