Patchwork [28,of,35,V2] context: move diff from changectx

login
register
mail settings
Submitter Sean Farley
Date Aug. 7, 2013, 11:51 p.m.
Message ID <a2afb3514ab7b47e63ce.1375919502@laptop.local>
Download mbox | patch
Permalink /patch/2081/
State Accepted
Headers show

Comments

Sean Farley - Aug. 7, 2013, 11:51 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1375746072 18000
#      Mon Aug 05 18:41:12 2013 -0500
# Node ID a2afb3514ab7b47e63ceb81709c86839d1997271
# Parent  67031f96c100ab0edc3149252e508429db6e42a2
context: move diff from changectx

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -126,10 +126,20 @@ 
         r = self._repo
         return matchmod.match(r.root, r.getcwd(), pats,
                               include, exclude, default,
                               auditor=r.auditor, ctx=self)
 
+    def diff(self, ctx2=None, match=None, **opts):
+        """Returns a diff generator for the given contexts and matcher"""
+        if ctx2 is None:
+            ctx2 = self.p1()
+        if ctx2 is not None and not isinstance(ctx2, changectx):
+            ctx2 = self._repo[ctx2]
+        diffopts = patch.diffopts(self._repo.ui, opts)
+        return patch.diff(self._repo, ctx2.node(), self.node(),
+                          match=match, opts=diffopts)
+
 class changectx(context):
     """A changecontext object makes access to data related to a particular
     changeset convenient. It represents a read-only context already presnt in
     the repo."""
     def __init__(self, repo, changeid=''):
@@ -387,20 +397,10 @@ 
                 # specified pattern is a directory
                 continue
             if match.bad(fn, _('no such file in rev %s') % self) and match(fn):
                 yield fn
 
-    def diff(self, ctx2=None, match=None, **opts):
-        """Returns a diff generator for the given contexts and matcher"""
-        if ctx2 is None:
-            ctx2 = self.p1()
-        if ctx2 is not None and not isinstance(ctx2, changectx):
-            ctx2 = self._repo[ctx2]
-        diffopts = patch.diffopts(self._repo.ui, opts)
-        return patch.diff(self._repo, ctx2.node(), self.node(),
-                          match=match, opts=diffopts)
-
     @propertycache
     def _dirs(self):
         return scmutil.dirs(self._manifest)
 
     def dirs(self):