Skip to content

Commit

Permalink
Bug 1308625 : Preventing same release row data from getting inserted …
Browse files Browse the repository at this point in the history
…twice in the sql dump file (#226). r=bhearsum
  • Loading branch information
aksareen authored and bhearsum committed Jan 27, 2017
1 parent 0be79bb commit 897c391
Show file tree
Hide file tree
Showing 4 changed files with 1,009 additions and 14 deletions.
114 changes: 114 additions & 0 deletions auslib/blobs/apprelease.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,20 @@ def getApplicationVersion(self, platform, locale):
may have been a pretty version for users to see"""
return self.getExtv(platform, locale)

def getReferencedReleases(self):
"""
:return: Returns set of names of partially referenced releases that the current
release references
"""
referencedReleases = set()
for platform in self.get('platforms', {}):
for locale in self['platforms'][platform].get('locales', {}):
if self['platforms'][platform]['locales'][locale].get('partial'):
referencedReleases.add(
self['platforms'][platform]['locales'][locale]['partial']['from']
)
return referencedReleases

# TODO: kill me when aus3.m.o is dead, and snippet tests have been
# converted to unit tests.
def createSnippets(self, updateQuery, update_type, whitelistedDomains, specialForceHosts):
Expand Down Expand Up @@ -536,6 +550,20 @@ def createSnippets(self, updateQuery, update_type, whitelistedDomains, specialFo
self.log.debug('%s\n%s' % (s, snippets[s].rstrip()))
return snippets

def getReferencedReleases(self):
"""
:return: Returns set of names of partially referenced releases that the current
release references
"""
referencedReleases = set()
for platform in self.get('platforms', {}):
for locale in self['platforms'][platform].get('locales', {}):
if self['platforms'][platform]['locales'][locale].get('partial'):
referencedReleases.add(
self['platforms'][platform]['locales'][locale]['partial']['from']
)
return referencedReleases


class MultipleUpdatesXMLMixin(object):

Expand Down Expand Up @@ -585,6 +613,20 @@ def createSnippets(self, updateQuery, update_type, whitelistedDomains, specialFo
# We have no tests that require this, probably not worthwhile to implement.
return {}

def getReferencedReleases(self):
"""
:return: Returns set of names of partially referenced releases that the current
release references
"""
referencedReleases = set()
for platform in self.get('platforms', {}):
for locale in self['platforms'][platform].get('locales', {}):
for partial in self['platforms'][platform]['locales'][locale].get('partials', {}):
referencedReleases.add(
partial['from']
)
return referencedReleases


class UnifiedFileUrlsMixin(object):

Expand Down Expand Up @@ -696,6 +738,24 @@ def fromV3(cls, v3Blob):

return v4Blob

def getReferencedReleases(self):
"""
:return: Returns set of names of partially referenced releases that the current
release references
"""
referencedReleases = set()
for platform in self.get('platforms', {}):
for locale in self['platforms'][platform].get('locales', {}):
for partial in self['platforms'][platform]['locales'][locale].get('partials', {}):
referencedReleases.add(
partial['from']
)
for fileUrlKey in self.get('fileUrls', {}):
for partial in self['fileUrls'][fileUrlKey].get('partials', {}):
referencedReleases.add(partial)

return referencedReleases


class ReleaseBlobV5(ReleaseBlobBase, NewStyleVersionsMixin, MultipleUpdatesXMLMixin, UnifiedFileUrlsMixin):
""" Compatible with Gecko 19.0 and above, ie Firefox/Thunderbird 19.0 and above.
Expand All @@ -721,6 +781,24 @@ def __init__(self, **kwargs):
if 'schema_version' not in self.keys():
self['schema_version'] = 5

def getReferencedReleases(self):
"""
:return: Returns set of names of partially referenced releases that the current
release references
"""
referencedReleases = set()
for platform in self.get('platforms', {}):
for locale in self['platforms'][platform].get('locales', {}):
for partial in self['platforms'][platform]['locales'][locale].get('partials', {}):
referencedReleases.add(
partial['from']
)
for fileUrlKey in self.get('fileUrls', {}):
for partial in self['fileUrls'][fileUrlKey].get('partials', {}):
referencedReleases.add(partial)

return referencedReleases


class ReleaseBlobV6(ReleaseBlobBase, NewStyleVersionsMixin, MultipleUpdatesXMLMixin, UnifiedFileUrlsMixin):
""" Compatible with Gecko 51.0 and above, ie Firefox/Thunderbird 51.0 and above.
Expand All @@ -747,6 +825,24 @@ def __init__(self, **kwargs):
if 'schema_version' not in self.keys():
self['schema_version'] = 6

def getReferencedReleases(self):
"""
:return: Returns set of names of partially referenced releases that the current
release references
"""
referencedReleases = set()
for platform in self.get('platforms', {}):
for locale in self['platforms'][platform].get('locales', {}):
for partial in self['platforms'][platform]['locales'][locale].get('partials', {}):
referencedReleases.add(
partial['from']
)
for fileUrlKey in self.get('fileUrls', {}):
for partial in self['fileUrls'][fileUrlKey].get('partials', {}):
referencedReleases.add(partial)

return referencedReleases


class ReleaseBlobV7(ReleaseBlobBase, NewStyleVersionsMixin, MultipleUpdatesXMLMixin, UnifiedFileUrlsMixin):
""" Compatible with Gecko 50.0 and above, ie Firefox/Thunderbird 50.0 and above.
Expand All @@ -773,6 +869,24 @@ def __init__(self, **kwargs):
if 'schema_version' not in self.keys():
self['schema_version'] = 7

def getReferencedReleases(self):
"""
:return: Returns set of names of partially referenced releases that the current
release references
"""
referencedReleases = set()
for platform in self.get('platforms', {}):
for locale in self['platforms'][platform].get('locales', {}):
for partial in self['platforms'][platform]['locales'][locale].get('partials', {}):
referencedReleases.add(
partial['from']
)
for fileUrlKey in self.get('fileUrls', {}):
for partial in self['fileUrls'][fileUrlKey].get('partials', {}):
referencedReleases.add(partial)

return referencedReleases


class DesupportBlob(Blob):
""" This blob is used to inform users that their OS is no longer supported. This is available
Expand Down
7 changes: 7 additions & 0 deletions auslib/blobs/base.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,10 @@ def getFooterXML(self):
"""
footer = '</updates>'
return footer

def getReferencedReleases(self):
"""
:return: Returns set of names of partially referenced releases that the current
release references
"""
return set()

0 comments on commit 897c391

Please sign in to comment.