> = Bug 435699 =
>
> To fix crashes in the translations auto-approver last cycle, I rewrote
> POTemplateSet.getPOTemplateByPathAndOrigin. Where the old version would
> crash if multiple templates matched (which happened rarely, fortunately)
> the new version detected the condition and logged it.
>
> Now, post-rollout, I find that it logs far too much. As it turns out,
> the new version forgets to match on distroseries, so any template that
> exists unchanged between Ubuntu releases will seem to have multiple
> matches!
OK - at first I thought - why's this an rc? But yes, with the info in your
last para - it makes more sense!
>
> This branch fixes that. A test broke in the process, but that seems to
> be from using a fixed name for a package, and then not _passing_ the
> distroseries argument to getPOTemplateByPathAndOrigin. To stay faithful
> to the known interface, which does not require the distroseries argument
> (even if it's probably always given in practice), I fixed it by using a
> unique name for the package.
>
> What I test for is not the logging, but the more serious consequence of
> the condition that's beeing seen (and logged) where it isn't supposed to
> be: multiple matches mean that templates are not found, and so uploads
> are not approved.
>
> Test:
> {{{
> ./bin/test test_autoapproval
> }}}
>
> No lint.
>
>
> Jeroen
You probably already know, but just in case, another way to do this
is to use a list of extra expressions and just append to it (rather than
wrapping further conditions in And exprs (for eg., Archive.getBuildCounters()).
So this is the regression test right? Ensuring that the distroseries
is respected. OK, I verified that it fails without the change in potemplate
- great.
Hi Jeroen,
r=me
Thanks for the details in the MP!
> = Bug 435699 = getPOTemplateBy PathAndOrigin. Where the old version would
>
> To fix crashes in the translations auto-approver last cycle, I rewrote
> POTemplateSet.
> crash if multiple templates matched (which happened rarely, fortunately)
> the new version detected the condition and logged it.
>
> Now, post-rollout, I find that it logs far too much. As it turns out,
> the new version forgets to match on distroseries, so any template that
> exists unchanged between Ubuntu releases will seem to have multiple
> matches!
OK - at first I thought - why's this an rc? But yes, with the info in your
last para - it makes more sense!
> PathAndOrigin. To stay faithful
> This branch fixes that. A test broke in the process, but that seems to
> be from using a fixed name for a package, and then not _passing_ the
> distroseries argument to getPOTemplateBy
> to the known interface, which does not require the distroseries argument
> (even if it's probably always given in practice), I fixed it by using a
> unique name for the package.
>
> What I test for is not the logging, but the more serious consequence of
> the condition that's beeing seen (and logged) where it isn't supposed to
> be: multiple matches mean that templates are not found, and so uploads
> are not approved.
>
> Test:
> {{{
> ./bin/test test_autoapproval
> }}}
>
> No lint.
>
>
> Jeroen
> === modified file 'lib/lp/ translations/ model/potemplat e.py' translations/ model/potemplat e.py 2009-09-17 04:51:07 +0000 translations/ model/potemplat e.py 2009-09-24 09:48:24 +0000 from_sourcepack agename == sourcepackagename, sourcepackagena me == sourcepackagename)) distroseries == distroseries)
> --- lib/lp/
> +++ lib/lp/
> @@ -1225,6 +1225,10 @@
> POTemplate.
> POTemplate.
>
> + if distroseries:
> + conditions = And(
> + conditions, POTemplate.
> +
You probably already know, but just in case, another way to do this getBuildCounter s()).
is to use a list of extra expressions and just append to it (rather than
wrapping further conditions in And exprs (for eg., Archive.
> store = IStore(POTemplate) shortlist( store.find( POTemplate, conditions)) translations/ tests/test_ autoapproval. py' translations/ tests/test_ autoapproval. py 2009-09-15 05:25:13 +0000 translations/ tests/test_ autoapproval. py 2009-09-24 09:48:24 +0000 plate2 = product_subset.new( rDistroSeries( self, distroseries, name): distroseries, sourcepackagena me=self. packagename) subset. new(name, name, 'test.pot', self.distro.owner)
> matches = helpers.
>
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -272,6 +272,12 @@
> self.producttem
> 'test2', 'test2', 'test.pot', self.product.owner)
>
> + def _makeTemplateFo
> + """Create a template in the given `DistroSeries`."""
> + distro_subset = POTemplateSubset(
> + distroseries=
> + return distro_
> +
Great.
> def _setUpDistro(self): makeDistributio n() self.distro) meSet() .new('package' ) packagename = SourcePackageNa meSet() .new('from' ) self.distroseri es, me=self. packagename) late1 = distro_subset.new( late2 = distro_subset.new( late1 = self._makeTempl ateForDistroSer ies( late2 = self._makeTempl ateForDistroSer ies(
> """Set up a `Distribution` with two templates."""
> self.distro = self.factory.
> @@ -279,13 +285,10 @@
> distribution=
> self.packagename = SourcePackageNa
> self.from_
> - distro_subset = POTemplateSubset(
> - distroseries=
> - sourcepackagena
> - self.distrotemp
> - 'test1', 'test1', 'test.pot', self.distro.owner)
> - self.distrotemp
> - 'test2', 'test2', 'test.pot', self.distro.owner)
> + self.distrotemp
> + self.distroseries, 'test1')
> + self.distrotemp
> + self.distroseries, 'test2')
So this has not changed right? It's just easier to read. Or is it now
that a separate POTemplateSubset is instantiated with each call now?
OK, we clarified on IRC:
<jtv> noodles775: it's purely a refactoring, yes. POTemplateSubset is stateless.
> rigin_product_ duplicate( self): me=self. from_packagenam e) l(None, guessed_template) rigin_similar_ between_ distroseries( self): PathAndOrigin disregards templates from other makeDistroRelea se( self.distro) ateForDistroSer ies( late1.iscurrent = False late2.iscurrent = True late1.from_ sourcepackagena me = None late2.from_ sourcepackagena me = None t.getPOTemplate ByPathAndOrigin ( self.distroseri es, me=self. packagename) l(self. distrotemplate2 , guessed_template)
> def test_ByPathAndO
> # When multiple templates match for a product series,
> @@ -311,11 +314,29 @@
> 'test.pot', sourcepackagena
> self.assertEqua
>
> + def test_ByPathAndO
> + # getPOTemplateBy
> + # distroseries.
> + self._setUpDistro()
> + other_series = self.factory.
> + distribution=
> + other_template = self._makeTempl
> + other_series, 'test1')
> + self.distrotemp
> + self.distrotemp
> + self.distrotemp
> + self.distrotemp
> + guessed_template = self.templatese
> + 'test.pot', distroseries=
> + sourcepackagena
> + self.assertEqua
> +
So this is the regression test right? Ensuring that the distroseries
is respected. OK, I verified that it fails without the change in potemplate
- great.
> def test_ByPathAndO rigin_preferred _match( self): PathAndOrigin prefers from_sourcepack agename meSet() .new('match- package' ) meSet() .new( getUniqueString ())
> # getPOTemplateBy
> # matches over sourcepackagename matches.
> self._setUpDistro()
> - match_package = SourcePackageNa
> + match_package = SourcePackageNa
> + self.factory.
Thanks for the explanation in your MP! I would have been left guessing
here otherwise!
> self.distrotemp late1.sourcepac kagename = match_package late2.from_ sourcepackagena me = match_package
> self.distrotemp
>
--
Michael