[PATCH] Added option to normalize line endings when patching (issue1019)
Matt Mackall
mpm at selenic.com
Thu Jun 4 16:29:01 CDT 2009
On Thu, 2009-06-04 at 22:24 +0100, Colin Caughie wrote:
> # HG changeset patch
> # User Colin Caughie <c.caughie at indigovision.com>
> # Date 1244149687 -3600
> # Node ID 7bccc015d8a38ac9fbfdff2d5e2569192f331822
> # Parent dd3ebf81af433e37d301b3093f7e151bb52e01f8
> Added option to normalize line endings when patching (issue1019)
>
> This adds an option patch.eol that can be used to a) normalize the line endings
> of the input file when applying a patch, and b) replace all line endings with
> a fixed value when writing the output file.
> This fixes the import command for win32text users, as well as mq, transplant
> et al. It does not attempt to fix all possible line ending issues.
>
> diff -r dd3ebf81af43 -r 7bccc015d8a3 mercurial/patch.py
> --- a/mercurial/patch.py Wed Jun 03 17:12:48 2009 -0500
> +++ b/mercurial/patch.py Thu Jun 04 22:08:07 2009 +0100
> @@ -13,6 +13,7 @@
> import sys, tempfile, zlib
>
> gitre = re.compile('diff --git a/(.*) b/(.*)')
> +eolre = re.compile('[\r\n]+')
>
> class PatchError(Exception):
> pass
> @@ -239,6 +240,15 @@
> self.ui = ui
> self.lines = []
> self.exists = False
> + eolopt = self.ui.config('patch', 'eol')
> + if eolopt:
> + if eolopt == 'crlf':
> + self.eol = '\r\n'
Seems like we'd also want a way to force lf-only. Otherwise, this seems
pretty reasonable to me.
--
http://selenic.com : development and support for Mercurial and Linux
More information about the Mercurial-devel
mailing list