monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone.cat-garbling-newlines: 11b4f


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone.cat-garbling-newlines: 11b4f6eb2fd4f6fbc706532838ce90074141f642
Date: Sat, 8 Sep 2012 02:08:36 +0200 (CEST)

revision:            11b4f6eb2fd4f6fbc706532838ce90074141f642
date:                2012-09-08T00:06:58
author:              Richard Hopkins <address@hidden>
branch:              net.venge.monotone.cat-garbling-newlines
changelog:
Add new test to check for garbled output from `mtn cat`

The original issue was found using Java to read from the monotone
process stdout on a Windows XP system, but was also reproduced
using `mtn cat FILENAME > FILENAME`. However, on Linux (only
tested on SUSE so far) no lines are garbled, even with newlines.

I think the culprit is 'dump_file' which uses '<<', and the
documentation states it performs formatting, where as 'put/write'
perform no formatting.

Whilst `mtn cat FILENAME > FILENAME` can be expressed as `mtn revert FILENAME`
which works correctly and does not garble new lines (even on Windows),
my opinion is that it should still work. The intention is to get the
full original version, and `mtn cat FILENAME` is quicker to type
and more efficient than using automate commands to fetch the workspace
manifest, then request the content given a file_id.

An example usage is using `mtn cat FILENAME` from a NetBeans IDE
integration plugin, as NetBeans only needs the full original text
of a file and automatically works out a diff, shows editor markers
in the margin etc when in an editor window. The current plugin
uses `mtn cat FILENAME` which works on Linux regardless of newlines
in files, but fails on Windows when the file has Windows newlines (CRLF).

manifest:
format_version "1"

new_manifest [dae869aa483b303af1418882d516617f664382c7]

old_revision [54bbe85d3580d04a212337c11f075a2b96dabefb]

add_dir "test/func/cat_does_not_alter_newlines"

add_file "test/func/cat_does_not_alter_newlines/__driver__.lua"
 content [b09baedec27314e362e115ef8bc40b9a2d6bfd86]
============================================================
--- /dev/null	
+++ test/func/cat_does_not_alter_newlines/__driver__.lua	b09baedec27314e362e115ef8bc40b9a2d6bfd86
@@ -0,0 +1,18 @@
+-- Add a file with Windows newlines (CRLF) then commit.
+-- An `mtn cat FILENAME > FILENAME` should result in having
+-- exactly the same file.
+-- On Windows XP cmd.exe (and probably other Windows systems),
+-- the above results in the newlines being garbled and viewing the
+-- file in some text editors has extra newlines added. It's not
+-- specific to cmd.exe and '>' redirection either, anything that
+-- reads from the mtn process stdout will see the text garbled.
+
+mtn_setup()
+
+addfile("numbers", "1\r\n2\r\n")
+commit()
+
+check(mtn("cat", "numbers"), 0, true, false)
+writefile("expected", "1\r\n2\r\n")
+check(samefile("stdout",  "expected"))
+

reply via email to

[Prev in Thread] Current Thread [Next in Thread]