# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1518526371 -32400
#      Tue Feb 13 21:52:51 2018 +0900
# Node ID b5d1c234b618e7dcc7e0bed9c10b60751ab0496c
# Parent  6eb7d95f897000030b30c6e12b8df3dfeb59a52a
convert: fix line ending of mapfile and commit.desc file

Follows up 42a393ea56d2. CRLF vs LF doesn't really matter as we do strip()
or rstrip() on read, but mixing them isn't nice. So let's restore the old
behavior.

I don't know whether CVS/Root, CVS/Repository, and ~/.cvspass are written
in native line ending, so I leave them read as binary files.

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -476,7 +476,7 @@ class mapfile(dict):
                 raise error.Abort(
                     _('could not open map file %r: %s') %
                     (self.path, encoding.strtolocal(err.strerror)))
-        self.fp.write('%s %s\n' % (key, value))
+        self.fp.write(util.tonativeeol('%s %s\n' % (key, value)))
         self.fp.flush()
         super(mapfile, self).__setitem__(key, value)
 
diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -411,7 +411,8 @@ class converter(object):
             self.ui.status(_('writing author map file %s\n') % authorfile)
             ofile = open(authorfile, 'wb+')
             for author in self.authors:
-                ofile.write("%s=%s\n" % (author, self.authors[author]))
+                ofile.write(util.tonativeeol("%s=%s\n"
+                                             % (author, self.authors[author])))
             ofile.close()
 
     def readauthormap(self, authorfile):
diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -626,7 +626,7 @@ class mercurial_source(common.converter_
     def converted(self, rev, destrev):
         if self.convertfp is None:
             self.convertfp = open(self.repo.vfs.join('shamap'), 'ab')
-        self.convertfp.write('%s %s\n' % (destrev, rev))
+        self.convertfp.write(util.tonativeeol('%s %s\n' % (destrev, rev)))
         self.convertfp.flush()
 
     def before(self):
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -640,7 +640,8 @@ class svn_source(converter_source):
         if self.convertfp is None:
             self.convertfp = open(os.path.join(self.wc, '.svn', 'hg-shamap'),
                                   'ab')
-        self.convertfp.write('%s %d\n' % (destrev, self.revnum(rev)))
+        self.convertfp.write(util.tonativeeol('%s %d\n'
+                                              % (destrev, self.revnum(rev))))
         self.convertfp.flush()
 
     def revid(self, revnum, module=None):
@@ -1309,7 +1310,7 @@ class svn_sink(converter_sink, commandli
 
         fd, messagefile = tempfile.mkstemp(prefix='hg-convert-')
         fp = os.fdopen(fd, pycompat.sysstr('wb'))
-        fp.write(commit.desc)
+        fp.write(util.tonativeeol(commit.desc))
         fp.close()
         try:
             output = self.run0('commit',
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to