Closed Bug 1541181 Opened 6 years ago Closed 6 years ago

`hg import` incorrectly handles files without newlines

Categories

(Conduit Graveyard :: Transplant, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: glob, Assigned: smacleod)

References

Details

(Keywords: conduit-triaged)

hg import incorrectly handles files without newlines.

steps to reproduce:

  1. create a file without a trailing newline
  2. commit to a hg
  3. delete the file
  4. generate a diff
  5. revert deletion
  6. try to hg import the diff to delete the file

the diff will look like

$ hg diff
diff --git a/test-file b/test-file
deleted file mode 100644
--- a/test-file
+++ /dev/null
@@ -1,1 +0,0 @@
-content mybrowser file:chrome/content/
\ No newline at end of file

trying to apply results in

$ hg import patch
applying patch
patching file test-file
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file test-file.rej
abort: patch failed to apply

the bug is in mercurial's parsing of the hunk - it only reads the specified lines of context from the hunk header (one line as per -1,1), and never reads the \ No newline at end of file line to strip the trailing \n. this extra \n prevents the patch from applying.

Flags: needinfo?(smacleod)
Flags: needinfo?(smacleod)
See Also: → 1541190

I will file this with upstream mercurial.

Assignee: nobody → smacleod
Status: NEW → ASSIGNED
Keywords: conduit-triaged
Priority: -- → P2
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Product: Conduit → Conduit Graveyard
Regressions: 1941011
No longer regressions: 1941011
See Also: → 1941011
See Also: → 1941591
You need to log in before you can comment on or make changes to this bug.