Patchwork [2,of,3,STABLE] diffhelper: rename module to avoid conflicts with ancient C module (issue5846)

login
register
mail settings
Submitter Yuya Nishihara
Date April 20, 2018, 12:10 p.m.
Message ID <cb673b653e017e6e596f.1524226233@mimosa>
Download mbox | patch
Permalink /patch/31205/
State Accepted
Headers show

Comments

Yuya Nishihara - April 20, 2018, 12:10 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1524224890 -32400
#      Fri Apr 20 20:48:10 2018 +0900
# Branch stable
# Node ID cb673b653e017e6e596f8d233fc8e7ad56e21b73
# Parent  171c91d2e6fb2ce686d24b34da5cc81482e0223d
diffhelper: rename module to avoid conflicts with ancient C module (issue5846)

Historically we had had C extensions in mercurial/, which shadows the pure
Python modules of the same name forever unless we do clean build/install.

I'm sloppy to think about new name, so just dropped the "s".

Patch

diff --git a/mercurial/diffhelpers.py b/mercurial/diffhelper.py
rename from mercurial/diffhelpers.py
rename to mercurial/diffhelper.py
--- a/mercurial/diffhelpers.py
+++ b/mercurial/diffhelper.py
@@ -1,4 +1,4 @@ 
-# diffhelpers.py - helper routines for patch
+# diffhelper.py - helper routines for patch
 #
 # Copyright 2009 Matt Mackall <mpm@selenic.com> and others
 #
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -28,7 +28,7 @@  from .node import (
 )
 from . import (
     copies,
-    diffhelpers,
+    diffhelper,
     encoding,
     error,
     mail,
@@ -800,7 +800,7 @@  class patchfile(object):
         # if there's skew we want to emit the "(offset %d lines)" even
         # when the hunk cleanly applies at start + skew, so skip the
         # fast case code
-        if self.skew == 0 and diffhelpers.testhunk(old, self.lines, oldstart):
+        if self.skew == 0 and diffhelper.testhunk(old, self.lines, oldstart):
             if self.remove:
                 self.backend.unlink(self.fname)
             else:
@@ -827,7 +827,7 @@  class patchfile(object):
                     cand = [oldstart]
 
                 for l in cand:
-                    if not old or diffhelpers.testhunk(old, self.lines, l):
+                    if not old or diffhelper.testhunk(old, self.lines, l):
                         self.lines[l : l + len(old)] = new
                         self.offset += len(new) - len(old)
                         self.skew = l - orig_start
@@ -1259,8 +1259,8 @@  class hunk(object):
         self.starta = int(self.starta)
         self.startb = int(self.startb)
         try:
-            diffhelpers.addlines(lr, self.hunk, self.lena, self.lenb,
-                                 self.a, self.b)
+            diffhelper.addlines(lr, self.hunk, self.lena, self.lenb,
+                                self.a, self.b)
         except error.ParseError as e:
             raise PatchError(_("bad hunk #%d: %s") % (self.number, e))
         # if we hit eof before finishing out the hunk, the last line will
@@ -1379,7 +1379,7 @@  class hunk(object):
     def _fixnewline(self, lr):
         l = lr.readline()
         if l.startswith('\ '):
-            diffhelpers.fixnewline(self.hunk, self.a, self.b)
+            diffhelper.fixnewline(self.hunk, self.a, self.b)
         else:
             lr.push(l)