Closed Bug 1675648 Opened 5 years ago Closed 5 years ago

moz-phab incorrectly handles commits with CARRIAGE RETURNs and creates unlandable diffs

Categories

(Conduit :: moz-phab, defect, P2)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Kwan, Assigned: zeid)

References

Details

(Keywords: conduit-triaged)

Attachments

(2 files)

See D95451 (Lando) and the related #conduit:mozilla.org Matrix discussion.

I think it might be because it seems like moz-phab is processing the diffs with python's splitlines(), which includes lone \rs, instead of just doing split("\n"), which seems to be what arcanist does

The result is extra - prefixed lines that shouldn't be.
Attached picture shows what moz-phab diffs read from Phabricator looks like on the left, with the errors on lines 14 and 16, and the correct diff on the right.

Blocks: remove-arc
Assignee: nobody → zeid

WIP DO NOT LAND

This change improves line separator support on different OSes by:

  • Determining linesep character based on current OS (e.g. \n or \r\n)
  • Splitting lines that are generated by hg cat only on linesep instead
    of on any whitespace or newline character
    • This has the side-effect of preventing stray characters such as
      carriage returns from triggering a line split

This change also combines the functionality that is shared between
methods into a new _generate_lines static method.

TODO: add a test specific to _generate_lines.

Keywords: conduit-triaged
Priority: -- → P2
Regressions: 1686998
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
See Also: → 1695847
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: