Patchwork [1,of,5,V2] context: move importing patch into the diff method

login
register
mail settings
Submitter Sean Farley
Date Aug. 6, 2014, 11:20 p.m.
Message ID <db7d8fec711c7d5469bd.1407367222@laptop.local>
Download mbox | patch
Permalink /patch/5302/
State Changes Requested
Headers show

Comments

Sean Farley - Aug. 6, 2014, 11:20 p.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1407367046 18000
#      Wed Aug 06 18:17:26 2014 -0500
# Node ID db7d8fec711c7d5469bd351628029dbd27d9a82a
# Parent  ba5fc3f81f1588507a5a84ac2b43679705ceec7b
context: move importing patch into the diff method

This is needed to avoid an import cycle and being that 'diff' is the only
method that needs the patch module, we move importing it into the method.
Pierre-Yves David - Aug. 7, 2014, 7:42 a.m.
On 08/06/2014 04:20 PM, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1407367046 18000
> #      Wed Aug 06 18:17:26 2014 -0500
> # Node ID db7d8fec711c7d5469bd351628029dbd27d9a82a
> # Parent  ba5fc3f81f1588507a5a84ac2b43679705ceec7b
> context: move importing patch into the diff method
>
> This is needed to avoid an import cycle and being that 'diff' is the only
> method that needs the patch module, we move importing it into the method.

This does not solve the breakage. Did you ran the test?
Sean Farley - Aug. 7, 2014, 4:56 p.m.
Pierre-Yves David writes:

> On 08/06/2014 04:20 PM, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean.michael.farley@gmail.com>
>> # Date 1407367046 18000
>> #      Wed Aug 06 18:17:26 2014 -0500
>> # Node ID db7d8fec711c7d5469bd351628029dbd27d9a82a
>> # Parent  ba5fc3f81f1588507a5a84ac2b43679705ceec7b
>> context: move importing patch into the diff method
>>
>> This is needed to avoid an import cycle and being that 'diff' is the only
>> method that needs the patch module, we move importing it into the method.
>
> This does not solve the breakage. Did you ran the test?

Sigh. I ran the test on the wrong commit.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -5,11 +5,11 @@ 
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
 from node import nullid, nullrev, short, hex, bin
 from i18n import _
-import mdiff, error, util, scmutil, subrepo, patch, encoding, phases
+import mdiff, error, util, scmutil, subrepo, encoding, phases
 import match as matchmod
 import os, errno, stat
 import obsolete as obsmod
 import repoview
 import fileset
@@ -260,10 +260,12 @@  class basectx(object):
                               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"""
+        # need to break an import cycle
+        import patch
         if ctx2 is None:
             ctx2 = self.p1()
         if ctx2 is not None:
             ctx2 = self._repo[ctx2]
         diffopts = patch.diffopts(self._repo.ui, opts)