Page MenuHomePhabricator

Don't choke on blame of files with whitespace-only trailing lines
ClosedPublic

Authored by epriestley on Jan 27 2014, 6:52 PM.
Tags
None
Referenced Files
F13178864: D8078.diff
Wed, May 8, 8:45 PM
Unknown Object (File)
Sat, May 4, 6:21 PM
Unknown Object (File)
Tue, Apr 30, 11:15 PM
Unknown Object (File)
Sat, Apr 27, 10:15 AM
Unknown Object (File)
Mon, Apr 22, 10:31 PM
Unknown Object (File)
Apr 12 2024, 1:46 PM
Unknown Object (File)
Apr 12 2024, 4:39 AM
Unknown Object (File)
Apr 12 2024, 4:39 AM
Subscribers

Details

Summary

Fixes T4349. Two issues:

  • As discussed in T4349, we would trim the entire output and then require spaces when matching. This choked incorrectly if the last line of a file contained only whitespace. Use phutil_split_lines() instead, and regexp things more reasonably.
  • We were capturing the line text, not the commit, as "revision". This isn't actually used elsewhere, but was obviously wrong. Make this consistent with Git/SVN.
Test Plan

Rigged a call up and saw reasonable output after the patch, on a working copy which threw before the patch.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

durham added inline comments.
src/repository/api/ArcanistMercurialAPI.php
326

Why bother with $retain_line_endings if the only thing lines are used for is to check against the regex?

Mostly just force of habit, at this point. Generally, in the past, we did a lot of newline stripping and eventually hit bugs where "\r\n" newlines were getting corrupted or not handled correctly. Retaining the endings is more correct, in that if we were actually capturing the text we should capture the endings as they are printed, so callers can retain unusual endings.