[PATCH] Fix transplant to generate diffs in text mode

Andrei Vermel avermel at mail.ru
Mon Dec 25 15:18:30 CST 2006


Attached is an alternative fix that I think serves the same purpose,
but also works properly with files containing crlf.

According to man, parameter --binary of 'patch' utility  does nothing on
unix but helps to handle crlf on windows.

Regards,

Andrei


# HG changeset patch
# User "Andrei Vermel <avermel at mail.ru>"
# Date 1167081073 -10800
# Node ID e95e7fb1ce59e318418b1262ae962ee12e710fe1
# Parent  2b87d3c5ab8e2ac79479c643c30e3949ca64690e
Make transplant work on windows

diff -r 2b87d3c5ab8e -r e95e7fb1ce59 hgext/transplant.py
--- a/hgext/transplant.py Fri Dec 22 17:59:40 2006 -0600
+++ b/hgext/transplant.py Tue Dec 26 00:11:13 2006 +0300
@@ -138,7 +138,7 @@ class transplanter:
                     patchfile = None
                 else:
                     fd, patchfile = tempfile.mkstemp(prefix='hg-transplant-')
-                    fp = os.fdopen(fd, 'w')
+                    fp = os.fdopen(fd, 'wb')
                     patch.diff(source, parents[0], node, fp=fp, opts=diffopts)
                     fp.close()

diff -r 2b87d3c5ab8e -r e95e7fb1ce59 mercurial/patch.py
--- a/mercurial/patch.py Fri Dec 22 17:59:40 2006 -0600
+++ b/mercurial/patch.py Tue Dec 26 00:11:13 2006 +0300
@@ -283,7 +283,8 @@ def patch(patchname, ui, strip=1, cwd=No
         args = []
         if cwd:
             args.append('-d %s' % util.shellquote(cwd))
-        fp = os.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
+
+        fp = os.popen('%s %s --binary -p%d < %s' % (patcher, ' '.join(args), strip,
                                            util.shellquote(patchname)))

         for line in fp:





----- Original Message ----- 
From: "Patrick Mezard" <pmezard at gmail.com>
To: <mercurial-devel at selenic.com>
Sent: Monday, December 25, 2006 9:47 PM
Subject: [PATCH] Fix transplant to generate diffs in text mode


># HG changeset patch
> # User Patrick Mezard <pmezard at gmail.com>
> # Date 1167075961 -3600
> # Node ID f75741f8c1b230f3e4ba75ae39cb81adf1ddea01
> # Parent  2b87d3c5ab8e2ac79479c643c30e3949ca64690e
> Fix transplant to generate diffs in text mode.
>
> diff -r 2b87d3c5ab8e -r f75741f8c1b2 hgext/transplant.py
> --- a/hgext/transplant.py Fri Dec 22 17:59:40 2006 -0600
> +++ b/hgext/transplant.py Mon Dec 25 20:46:01 2006 +0100
> @@ -137,7 +137,7 @@ class transplanter:
>                                  % (rev, revlog.short(node)))
>                     patchfile = None
>                 else:
> -                    fd, patchfile = tempfile.mkstemp(prefix='hg-transplant-')
> +                    fd, patchfile = tempfile.mkstemp(prefix='hg-transplant-', 
> text=True)
>                     fp = os.fdopen(fd, 'w')
>                     patch.diff(source, parents[0], node, fp=fp, opts=diffopts)
>                     fp.close()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: export_transp
Type: application/octet-stream
Size: 1363 bytes
Desc: not available
Url : http://www.selenic.com/pipermail/mercurial-devel/attachments/20061226/12992e04/export_transp.obj


More information about the Mercurial-devel mailing list