D6356: mdiff: prepare mdiff to be used for run-tests to replace unidiff

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed May 15 12:00:26 EDT 2019


pulkit added a comment.


  > Patch 1/2
  
  we don't add that to commit messages.

INLINE COMMENTS

> mdiff.py:531
> +
> +def prepare_mdiff(expected, output):
> +    """Prepare the inputs for the mdiff.unidiff function"""

may be worth to rename it to `prepare_mdiff_input`.

> mdiff.py:540
> +    opts = diffopts(noprefix=True)
> +    return exp, date1, out, date2, opts
> +

We can do

  date = datetime.datetime.now().strftime("%a %b %d %y %H:%M:%S %Y %z")
  return "".join(expected), date, "".join(output), date, diffopts(noprefix=True)

> mdiff.py:544
> +    """Process the output of mdiff into a list of lines,
> +    to be used by getdiff"""
> +    # the hunklines are in the hunks generator

I was unable to find any `getdiff` in this file.

> mdiff.py:552
> +    difflines = itertools.chain.from_iterable(hunklines)
> +    return difflines
> +

nit: `return itertools.chain.from_iterable(hunklines)`

> mdiff.py:557
> +    The API of new_diff is designed to be same as difflib.unified_diff.
> +    This is done for backwards compatibility and resuing existing code.
> +    """

backwards compatibility with what?

> mdiff.py:562
> +                            ref, err, binary=False, opts=opts)
> +    difflines = process_mdiff(uheaders, hunks)
> +    return difflines

nit: `return process_mdiff(uheaders, hunks)`

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6356

To: sangeet259, #hg-reviewers
Cc: durin42, pulkit, martinvonz, mercurial-devel


More information about the Mercurial-devel mailing list