##// END OF EJS Templates
convert: open all files in binary mode...
Augie Fackler -
r36149:42a393ea default
parent child Browse files
Show More
@@ -447,7 +447,7 b' class mapfile(dict):'
447 if not self.path:
447 if not self.path:
448 return
448 return
449 try:
449 try:
450 fp = open(self.path, 'r')
450 fp = open(self.path, 'rb')
451 except IOError as err:
451 except IOError as err:
452 if err.errno != errno.ENOENT:
452 if err.errno != errno.ENOENT:
453 raise
453 raise
@@ -471,7 +471,7 b' class mapfile(dict):'
471 def __setitem__(self, key, value):
471 def __setitem__(self, key, value):
472 if self.fp is None:
472 if self.fp is None:
473 try:
473 try:
474 self.fp = open(self.path, 'a')
474 self.fp = open(self.path, 'ab')
475 except IOError as err:
475 except IOError as err:
476 raise error.Abort(
476 raise error.Abort(
477 _('could not open map file %r: %s') %
477 _('could not open map file %r: %s') %
@@ -202,7 +202,7 b' class converter(object):'
202 return {}
202 return {}
203 m = {}
203 m = {}
204 try:
204 try:
205 fp = open(path, 'r')
205 fp = open(path, 'rb')
206 for i, line in enumerate(util.iterfile(fp)):
206 for i, line in enumerate(util.iterfile(fp)):
207 line = line.splitlines()[0].rstrip()
207 line = line.splitlines()[0].rstrip()
208 if not line:
208 if not line:
@@ -407,13 +407,13 b' class converter(object):'
407 authorfile = self.authorfile
407 authorfile = self.authorfile
408 if authorfile:
408 if authorfile:
409 self.ui.status(_('writing author map file %s\n') % authorfile)
409 self.ui.status(_('writing author map file %s\n') % authorfile)
410 ofile = open(authorfile, 'w+')
410 ofile = open(authorfile, 'wb+')
411 for author in self.authors:
411 for author in self.authors:
412 ofile.write("%s=%s\n" % (author, self.authors[author]))
412 ofile.write("%s=%s\n" % (author, self.authors[author]))
413 ofile.close()
413 ofile.close()
414
414
415 def readauthormap(self, authorfile):
415 def readauthormap(self, authorfile):
416 afile = open(authorfile, 'r')
416 afile = open(authorfile, 'rb')
417 for line in afile:
417 for line in afile:
418
418
419 line = line.strip()
419 line = line.strip()
@@ -46,8 +46,8 b' class convert_cvs(converter_source):'
46 self.tags = {}
46 self.tags = {}
47 self.lastbranch = {}
47 self.lastbranch = {}
48 self.socket = None
48 self.socket = None
49 self.cvsroot = open(os.path.join(cvs, "Root")).read()[:-1]
49 self.cvsroot = open(os.path.join(cvs, "Root"), 'rb').read()[:-1]
50 self.cvsrepo = open(os.path.join(cvs, "Repository")).read()[:-1]
50 self.cvsrepo = open(os.path.join(cvs, "Repository"), 'rb').read()[:-1]
51 self.encoding = encoding.encoding
51 self.encoding = encoding.encoding
52
52
53 self._connect()
53 self._connect()
@@ -141,7 +141,7 b' class convert_cvs(converter_source):'
141 passw = "A"
141 passw = "A"
142 cvspass = os.path.expanduser("~/.cvspass")
142 cvspass = os.path.expanduser("~/.cvspass")
143 try:
143 try:
144 pf = open(cvspass)
144 pf = open(cvspass, 'rb')
145 for line in pf.read().splitlines():
145 for line in pf.read().splitlines():
146 part1, part2 = line.split(' ', 1)
146 part1, part2 = line.split(' ', 1)
147 # /1 :pserver:user@example.com:2401/cvsroot/foo
147 # /1 :pserver:user@example.com:2401/cvsroot/foo
@@ -132,7 +132,7 b' def createlog(ui, directory=None, root="'
132
132
133 # Get the real directory in the repository
133 # Get the real directory in the repository
134 try:
134 try:
135 prefix = open(os.path.join('CVS','Repository')).read().strip()
135 prefix = open(os.path.join('CVS','Repository'), 'rb').read().strip()
136 directory = prefix
136 directory = prefix
137 if prefix == ".":
137 if prefix == ".":
138 prefix = ""
138 prefix = ""
@@ -144,7 +144,7 b' def createlog(ui, directory=None, root="'
144
144
145 # Use the Root file in the sandbox, if it exists
145 # Use the Root file in the sandbox, if it exists
146 try:
146 try:
147 root = open(os.path.join('CVS','Root')).read().strip()
147 root = open(os.path.join('CVS','Root'), 'rb').read().strip()
148 except IOError:
148 except IOError:
149 pass
149 pass
150
150
@@ -177,7 +177,7 b' def createlog(ui, directory=None, root="'
177 if cache == 'update':
177 if cache == 'update':
178 try:
178 try:
179 ui.note(_('reading cvs log cache %s\n') % cachefile)
179 ui.note(_('reading cvs log cache %s\n') % cachefile)
180 oldlog = pickle.load(open(cachefile))
180 oldlog = pickle.load(open(cachefile, 'rb'))
181 for e in oldlog:
181 for e in oldlog:
182 if not (util.safehasattr(e, 'branchpoints') and
182 if not (util.safehasattr(e, 'branchpoints') and
183 util.safehasattr(e, 'commitid') and
183 util.safehasattr(e, 'commitid') and
@@ -486,7 +486,7 b' def createlog(ui, directory=None, root="'
486
486
487 # write the new cachefile
487 # write the new cachefile
488 ui.note(_('writing cvs log cache %s\n') % cachefile)
488 ui.note(_('writing cvs log cache %s\n') % cachefile)
489 pickle.dump(log, open(cachefile, 'w'))
489 pickle.dump(log, open(cachefile, 'wb'))
490 else:
490 else:
491 log = oldlog
491 log = oldlog
492
492
@@ -71,7 +71,7 b' class filemapper(object):'
71 (lex.infile, lex.lineno, listname, name))
71 (lex.infile, lex.lineno, listname, name))
72 return 1
72 return 1
73 return 0
73 return 0
74 lex = shlex.shlex(open(path), path, True)
74 lex = shlex.shlex(open(path, 'rb'), path, True)
75 lex.wordchars += '!@#$%^&*()-=+[]{}|;:,./<>?'
75 lex.wordchars += '!@#$%^&*()-=+[]{}|;:,./<>?'
76 cmd = lex.get_token()
76 cmd = lex.get_token()
77 while cmd:
77 while cmd:
@@ -625,7 +625,7 b' class mercurial_source(common.converter_'
625
625
626 def converted(self, rev, destrev):
626 def converted(self, rev, destrev):
627 if self.convertfp is None:
627 if self.convertfp is None:
628 self.convertfp = open(self.repo.vfs.join('shamap'), 'a')
628 self.convertfp = open(self.repo.vfs.join('shamap'), 'ab')
629 self.convertfp.write('%s %s\n' % (destrev, rev))
629 self.convertfp.write('%s %s\n' % (destrev, rev))
630 self.convertfp.flush()
630 self.convertfp.flush()
631
631
@@ -231,7 +231,7 b' def filecheck(ui, path, proto):'
231 def httpcheck(ui, path, proto):
231 def httpcheck(ui, path, proto):
232 try:
232 try:
233 opener = urlreq.buildopener()
233 opener = urlreq.buildopener()
234 rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path))
234 rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path), 'rb')
235 data = rsp.read()
235 data = rsp.read()
236 except urlerr.httperror as inst:
236 except urlerr.httperror as inst:
237 if inst.code != 404:
237 if inst.code != 404:
@@ -639,7 +639,7 b' class svn_source(converter_source):'
639 return
639 return
640 if self.convertfp is None:
640 if self.convertfp is None:
641 self.convertfp = open(os.path.join(self.wc, '.svn', 'hg-shamap'),
641 self.convertfp = open(os.path.join(self.wc, '.svn', 'hg-shamap'),
642 'a')
642 'ab')
643 self.convertfp.write('%s %d\n' % (destrev, self.revnum(rev)))
643 self.convertfp.write('%s %d\n' % (destrev, self.revnum(rev)))
644 self.convertfp.flush()
644 self.convertfp.flush()
645
645
@@ -1158,7 +1158,7 b' class svn_sink(converter_sink, commandli'
1158
1158
1159 if created:
1159 if created:
1160 hook = os.path.join(created, 'hooks', 'pre-revprop-change')
1160 hook = os.path.join(created, 'hooks', 'pre-revprop-change')
1161 fp = open(hook, 'w')
1161 fp = open(hook, 'wb')
1162 fp.write(pre_revprop_change)
1162 fp.write(pre_revprop_change)
1163 fp.close()
1163 fp.close()
1164 util.setflags(hook, False, True)
1164 util.setflags(hook, False, True)
@@ -1308,7 +1308,7 b' class svn_sink(converter_sink, commandli'
1308 self.setexec = []
1308 self.setexec = []
1309
1309
1310 fd, messagefile = tempfile.mkstemp(prefix='hg-convert-')
1310 fd, messagefile = tempfile.mkstemp(prefix='hg-convert-')
1311 fp = os.fdopen(fd, pycompat.sysstr('w'))
1311 fp = os.fdopen(fd, pycompat.sysstr('wb'))
1312 fp.write(commit.desc)
1312 fp.write(commit.desc)
1313 fp.close()
1313 fp.close()
1314 try:
1314 try:
General Comments 0
You need to be logged in to leave comments. Login now