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

Boris Feld boris.feld at octobus.net
Tue Jul 3 06:32:22 EDT 2018


# HG changeset patch
# User Boris Feld <boris.feld at 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.

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,


More information about the Mercurial-devel mailing list