[PATCH v1 2/9] models: Add field for series dependencies

Adam Hassick ahassick at iol.unh.edu
Sat Jul 13 05:35:59 AEST 2024


On Fri, Jul 12, 2024 at 11:35 AM Stephen Finucane <stephen at that.guru> wrote:
>
> On Mon, 2024-06-17 at 18:18 -0400, Adam Hassick wrote:
> > Add a ManyToMany field to represent a dependency relationship between
> > patch series.
> >
> > Signed-off-by: Adam Hassick <ahassick at iol.unh.edu>
>
> Two comments below but LGTM.
>
> Reviewed-by: Stephen Finucane <stephen at that.guru>
>
> > ---
> >  patchwork/models.py | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >
> > diff --git a/patchwork/models.py b/patchwork/models.py
> > index 9a619bc..6f6a32d 100644
> > --- a/patchwork/models.py
> > +++ b/patchwork/models.py
> > @@ -840,6 +840,16 @@ class Series(FilenameMixin, models.Model):
> >          Cover, related_name='series', null=True, on_delete=models.CASCADE
> >      )
> >
> > +    # dependencies
> > +    dependencies = models.ManyToManyField(
> > +        'self',
> > +        symmetrical=False,
> > +        blank=True,
> > +        help_text='Optional dependencies on this patch.',
> > +        related_name='dependents',
> > +        related_query_name='dependent',
> > +    )
> > +
> >      # metadata
> >      name = models.CharField(
> >          max_length=255,
> > @@ -880,6 +890,13 @@ class Series(FilenameMixin, models.Model):
> >      def received_all(self):
> >          return self.total <= self.received_total
> >
> > +    def add_dependencies(self, dependencies):
> > +        # for dependency in dependencies:
> > +        #     dependency.dependents.add(self)
> > +        #     dependency.save()
>
> I assume this is from testing and should be dropped?

Yes, will do.

> > +        self.dependencies.add(*dependencies)
>
> I have questions around validating this to prevent e.g. linking to self, but
> that's for later.

I can add a check here to make sure the dependent is not self and is
of the same project.
I don't think it makes much sense to depend on a patch from a
different project either.

> > +        self.save()
> > +
> >      def add_cover_letter(self, cover):
> >          """Add a cover letter to the series.
> >
>


More information about the Patchwork mailing list