Patchwork [02,of,10] diffhelpers: port docstrings from cext to pure

login
register
mail settings
Submitter Yuya Nishihara
Date April 11, 2018, 3:33 p.m.
Message ID <35a82b6cd55528b0aa00.1523460832@mimosa>
Download mbox | patch
Permalink /patch/30696/
State Accepted
Headers show

Comments

Yuya Nishihara - April 11, 2018, 3:33 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1523274463 -32400
#      Mon Apr 09 20:47:43 2018 +0900
# Node ID 35a82b6cd55528b0aa0028321c69756d41175b54
# Parent  da53a21e2b96040ca2005d627b6c69a91e83f938
diffhelpers: port docstrings from cext to pure

I'll remove the C implementation.

Patch

diff --git a/mercurial/pure/diffhelpers.py b/mercurial/pure/diffhelpers.py
--- a/mercurial/pure/diffhelpers.py
+++ b/mercurial/pure/diffhelpers.py
@@ -8,6 +8,12 @@ 
 from __future__ import absolute_import
 
 def addlines(fp, hunk, lena, lenb, a, b):
+    """Read lines from fp into the hunk
+
+    The hunk is parsed into two arrays, a and b. a gets the old state of
+    the text, b gets the new state. The control char from the hunk is saved
+    when inserting into a, but not b (for performance while deleting files.)
+    """
     while True:
         todoa = lena - len(a)
         todob = lenb - len(b)
@@ -34,6 +40,7 @@  def addlines(fp, hunk, lena, lenb, a, b)
     return 0
 
 def fix_newline(hunk, a, b):
+    """Fix up the last lines of a and b when the patch has no newline at EOF"""
     l = hunk[-1]
     # tolerate CRLF in last line
     if l.endswith('\r\n'):
@@ -50,6 +57,11 @@  def fix_newline(hunk, a, b):
 
 
 def testhunk(a, b, bstart):
+    """Compare the lines in a with the lines in b
+
+    a is assumed to have a control char at the start of each line, this char
+    is ignored in the compare.
+    """
     alen = len(a)
     blen = len(b)
     if alen > blen - bstart: