Patchwork [03,of,12,V2] context: also accept diff option directly

login
register
mail settings
Submitter Boris Feld
Date July 3, 2018, 10:32 a.m.
Message ID <9d94a3118a9c253a09bd.1530613942@FB-lair>
Download mbox | patch
Permalink /patch/32570/
State Accepted
Headers show

Comments

Boris Feld - July 3, 2018, 10:32 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1529756343 -3600
#      Sat Jun 23 13:19:03 2018 +0100
# Node ID 9d94a3118a9c253a09bdf48258548dca92e35018
# Parent  e6ba698b9c7354f21e2ae764a11e043872990d79
# EXP-Topic diff-cleanup
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 9d94a3118a9c
context: also accept diff option directly

For now we accept both diff option and dictionary. This will let us upgrade
internal users gradually before we drop the old API at the end of this series.
Yuya Nishihara - July 3, 2018, 11:48 a.m.
On Tue, 03 Jul 2018 12:32:22 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1529756343 -3600
> #      Sat Jun 23 13:19:03 2018 +0100
> # Node ID 9d94a3118a9c253a09bdf48258548dca92e35018
> # Parent  e6ba698b9c7354f21e2ae764a11e043872990d79
> # EXP-Topic diff-cleanup
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 9d94a3118a9c
> context: also accept diff option directly

Queued up to this patch, thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -30,6 +30,7 @@  from . import (
     error,
     fileset,
     match as matchmod,
+    mdiff,
     obsolete as obsmod,
     patch,
     pathutil,
@@ -302,7 +303,11 @@  class basectx(object):
             ctx2 = self.p1()
         if ctx2 is not None:
             ctx2 = self._repo[ctx2]
-        diffopts = patch.diffopts(self._repo.ui, opts)
+
+        if isinstance(opts, mdiff.diffopts):
+            diffopts = opts
+        else:
+            diffopts = patch.diffopts(self._repo.ui, opts)
         return patch.diff(self._repo, ctx2, self, match=match, changes=changes,
                           opts=diffopts, losedatafn=losedatafn, prefix=prefix,
                           relroot=relroot, copy=copy,