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.
--- a/hgext/convert/common.py Sun Feb 11 18:34:22 2018 -0800
+++ b/hgext/convert/common.py Tue Feb 13 21:52:51 2018 +0900
@@ -476,7 +476,7 @@
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)
--- a/hgext/convert/convcmd.py Sun Feb 11 18:34:22 2018 -0800
+++ b/hgext/convert/convcmd.py Tue Feb 13 21:52:51 2018 +0900
@@ -411,7 +411,8 @@
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):
--- a/hgext/convert/hg.py Sun Feb 11 18:34:22 2018 -0800
+++ b/hgext/convert/hg.py Tue Feb 13 21:52:51 2018 +0900
@@ -626,7 +626,7 @@
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):
--- a/hgext/convert/subversion.py Sun Feb 11 18:34:22 2018 -0800
+++ b/hgext/convert/subversion.py Tue Feb 13 21:52:51 2018 +0900
@@ -640,7 +640,8 @@
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 @@
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',