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

Stephen Finucane stephen at that.guru
Sat Jul 13 01:35:04 AEST 2024


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?

> +        self.dependencies.add(*dependencies)

I have questions around validating this to prevent e.g. linking to self, but
that's for later.

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



More information about the Patchwork mailing list