Patchwork [2,of,4] context: also take all other arguments than `patch.diff` accept

login
register
mail settings
Submitter Boris Feld
Date May 24, 2018, 8:38 a.m.
Message ID <2f2232e5f0b60a3dd591.1527151135@FB>
Download mbox | patch
Permalink /patch/31827/
State New
Headers show

Comments

Boris Feld - May 24, 2018, 8:38 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1527082300 -7200
#      Wed May 23 15:31:40 2018 +0200
# Node ID 2f2232e5f0b60a3dd591ea16dfffc3c0a050acdc
# Parent  4e013ebfa2c64f1849cb3a4242c47da981b35198
# EXP-Topic diff-cleanup
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2f2232e5f0b6
context: also take all other arguments than `patch.diff` accept

This is needed to use `context.diff` as a full replacement of `patch.diff`
Yuya Nishihara - May 24, 2018, 1:37 p.m.
On Thu, 24 May 2018 10:38:55 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1527082300 -7200
> #      Wed May 23 15:31:40 2018 +0200
> # Node ID 2f2232e5f0b60a3dd591ea16dfffc3c0a050acdc
> # Parent  4e013ebfa2c64f1849cb3a4242c47da981b35198
> # EXP-Topic diff-cleanup
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2f2232e5f0b6
> context: also take all other arguments than `patch.diff` accept
> 
> This is needed to use `context.diff` as a full replacement of `patch.diff`
> 
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -294,14 +294,19 @@ class basectx(object):
>                                auditor=r.nofsauditor, ctx=self,
>                                listsubrepos=listsubrepos, badfn=badfn)
>  
> -    def diff(self, ctx2=None, match=None, opts=None):
> +    def diff(self, ctx2=None, match=None, changes=None, opts=None,
> +            losedatafn=None, prefix='', relroot='', copy=None,
> +            hunksfilterfn=None, diffopts=None):

Unused 'diffopts'.

And I'm not sure if 'changes' and 'losedatafn' are useful as changectx APIs.
They look quite low-level.
Boris Feld - June 15, 2018, 8:41 a.m.
On 24/05/2018 15:37, Yuya Nishihara wrote:
> On Thu, 24 May 2018 10:38:55 +0200, Boris Feld wrote:
>> # HG changeset patch
>> # User Boris Feld <boris.feld@octobus.net>
>> # Date 1527082300 -7200
>> #      Wed May 23 15:31:40 2018 +0200
>> # Node ID 2f2232e5f0b60a3dd591ea16dfffc3c0a050acdc
>> # Parent  4e013ebfa2c64f1849cb3a4242c47da981b35198
>> # EXP-Topic diff-cleanup
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 2f2232e5f0b6
>> context: also take all other arguments than `patch.diff` accept
>>
>> This is needed to use `context.diff` as a full replacement of `patch.diff`
>>
>> diff --git a/mercurial/context.py b/mercurial/context.py
>> --- a/mercurial/context.py
>> +++ b/mercurial/context.py
>> @@ -294,14 +294,19 @@ class basectx(object):
>>                                 auditor=r.nofsauditor, ctx=self,
>>                                 listsubrepos=listsubrepos, badfn=badfn)
>>   
>> -    def diff(self, ctx2=None, match=None, opts=None):
>> +    def diff(self, ctx2=None, match=None, changes=None, opts=None,
>> +            losedatafn=None, prefix='', relroot='', copy=None,
>> +            hunksfilterfn=None, diffopts=None):
> Unused 'diffopts'.

Good catch.
>
> And I'm not sure if 'changes' and 'losedatafn' are useful as changectx APIs.
> They look quite low-level.

The goal of this series is to replace the call used by the diff 
commands. That call uses the changes argument, so we cannot drop it.

losedatafn could be dropped but it feels strange to just be one 
parameter different than patch.diff.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -294,14 +294,19 @@  class basectx(object):
                               auditor=r.nofsauditor, ctx=self,
                               listsubrepos=listsubrepos, badfn=badfn)
 
-    def diff(self, ctx2=None, match=None, opts=None):
+    def diff(self, ctx2=None, match=None, changes=None, opts=None,
+            losedatafn=None, prefix='', relroot='', copy=None,
+            hunksfilterfn=None, diffopts=None):
         """Returns a diff generator for the given contexts and matcher"""
         if ctx2 is None:
             ctx2 = self.p1()
         if ctx2 is not None:
             ctx2 = self._repo[ctx2]
         diffopts = patch.diffopts(self._repo.ui, pycompat.byteskwargs(opts))
-        return patch.diff(self._repo, ctx2, self, match=match, opts=diffopts)
+        return patch.diff(self._repo, ctx2, self, match=match, changes=changes,
+                          opts=diffopts, losedatafn=losedatafn, prefix=prefix,
+                          relroot=relroot, copy=copy,
+                          hunksfilterfn=hunksfilterfn)
 
     def dirs(self):
         return self._manifest.dirs()