Mercurial > hg
changeset 36132:42a393ea56d2
convert: open all files in binary mode
Differential Revision: https://phab.mercurial-scm.org/D2220
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 12 Feb 2018 23:50:58 -0500 |
parents | ce9f1c32810b |
children | 6df206ef4b10 |
files | hgext/convert/common.py hgext/convert/convcmd.py hgext/convert/cvs.py hgext/convert/cvsps.py hgext/convert/filemap.py hgext/convert/hg.py hgext/convert/subversion.py |
diffstat | 7 files changed, 18 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/common.py Mon Feb 12 22:29:36 2018 -0500 +++ b/hgext/convert/common.py Mon Feb 12 23:50:58 2018 -0500 @@ -447,7 +447,7 @@ if not self.path: return try: - fp = open(self.path, 'r') + fp = open(self.path, 'rb') except IOError as err: if err.errno != errno.ENOENT: raise @@ -471,7 +471,7 @@ def __setitem__(self, key, value): if self.fp is None: try: - self.fp = open(self.path, 'a') + self.fp = open(self.path, 'ab') except IOError as err: raise error.Abort( _('could not open map file %r: %s') %
--- a/hgext/convert/convcmd.py Mon Feb 12 22:29:36 2018 -0500 +++ b/hgext/convert/convcmd.py Mon Feb 12 23:50:58 2018 -0500 @@ -202,7 +202,7 @@ return {} m = {} try: - fp = open(path, 'r') + fp = open(path, 'rb') for i, line in enumerate(util.iterfile(fp)): line = line.splitlines()[0].rstrip() if not line: @@ -407,13 +407,13 @@ authorfile = self.authorfile if authorfile: self.ui.status(_('writing author map file %s\n') % authorfile) - ofile = open(authorfile, 'w+') + ofile = open(authorfile, 'wb+') for author in self.authors: ofile.write("%s=%s\n" % (author, self.authors[author])) ofile.close() def readauthormap(self, authorfile): - afile = open(authorfile, 'r') + afile = open(authorfile, 'rb') for line in afile: line = line.strip()
--- a/hgext/convert/cvs.py Mon Feb 12 22:29:36 2018 -0500 +++ b/hgext/convert/cvs.py Mon Feb 12 23:50:58 2018 -0500 @@ -46,8 +46,8 @@ self.tags = {} self.lastbranch = {} self.socket = None - self.cvsroot = open(os.path.join(cvs, "Root")).read()[:-1] - self.cvsrepo = open(os.path.join(cvs, "Repository")).read()[:-1] + self.cvsroot = open(os.path.join(cvs, "Root"), 'rb').read()[:-1] + self.cvsrepo = open(os.path.join(cvs, "Repository"), 'rb').read()[:-1] self.encoding = encoding.encoding self._connect() @@ -141,7 +141,7 @@ passw = "A" cvspass = os.path.expanduser("~/.cvspass") try: - pf = open(cvspass) + pf = open(cvspass, 'rb') for line in pf.read().splitlines(): part1, part2 = line.split(' ', 1) # /1 :pserver:user@example.com:2401/cvsroot/foo
--- a/hgext/convert/cvsps.py Mon Feb 12 22:29:36 2018 -0500 +++ b/hgext/convert/cvsps.py Mon Feb 12 23:50:58 2018 -0500 @@ -132,7 +132,7 @@ # Get the real directory in the repository try: - prefix = open(os.path.join('CVS','Repository')).read().strip() + prefix = open(os.path.join('CVS','Repository'), 'rb').read().strip() directory = prefix if prefix == ".": prefix = "" @@ -144,7 +144,7 @@ # Use the Root file in the sandbox, if it exists try: - root = open(os.path.join('CVS','Root')).read().strip() + root = open(os.path.join('CVS','Root'), 'rb').read().strip() except IOError: pass @@ -177,7 +177,7 @@ if cache == 'update': try: ui.note(_('reading cvs log cache %s\n') % cachefile) - oldlog = pickle.load(open(cachefile)) + oldlog = pickle.load(open(cachefile, 'rb')) for e in oldlog: if not (util.safehasattr(e, 'branchpoints') and util.safehasattr(e, 'commitid') and @@ -486,7 +486,7 @@ # write the new cachefile ui.note(_('writing cvs log cache %s\n') % cachefile) - pickle.dump(log, open(cachefile, 'w')) + pickle.dump(log, open(cachefile, 'wb')) else: log = oldlog
--- a/hgext/convert/filemap.py Mon Feb 12 22:29:36 2018 -0500 +++ b/hgext/convert/filemap.py Mon Feb 12 23:50:58 2018 -0500 @@ -71,7 +71,7 @@ (lex.infile, lex.lineno, listname, name)) return 1 return 0 - lex = shlex.shlex(open(path), path, True) + lex = shlex.shlex(open(path, 'rb'), path, True) lex.wordchars += '!@#$%^&*()-=+[]{}|;:,./<>?' cmd = lex.get_token() while cmd:
--- a/hgext/convert/hg.py Mon Feb 12 22:29:36 2018 -0500 +++ b/hgext/convert/hg.py Mon Feb 12 23:50:58 2018 -0500 @@ -625,7 +625,7 @@ def converted(self, rev, destrev): if self.convertfp is None: - self.convertfp = open(self.repo.vfs.join('shamap'), 'a') + self.convertfp = open(self.repo.vfs.join('shamap'), 'ab') self.convertfp.write('%s %s\n' % (destrev, rev)) self.convertfp.flush()
--- a/hgext/convert/subversion.py Mon Feb 12 22:29:36 2018 -0500 +++ b/hgext/convert/subversion.py Mon Feb 12 23:50:58 2018 -0500 @@ -231,7 +231,7 @@ def httpcheck(ui, path, proto): try: opener = urlreq.buildopener() - rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path)) + rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path), 'rb') data = rsp.read() except urlerr.httperror as inst: if inst.code != 404: @@ -639,7 +639,7 @@ return if self.convertfp is None: self.convertfp = open(os.path.join(self.wc, '.svn', 'hg-shamap'), - 'a') + 'ab') self.convertfp.write('%s %d\n' % (destrev, self.revnum(rev))) self.convertfp.flush() @@ -1158,7 +1158,7 @@ if created: hook = os.path.join(created, 'hooks', 'pre-revprop-change') - fp = open(hook, 'w') + fp = open(hook, 'wb') fp.write(pre_revprop_change) fp.close() util.setflags(hook, False, True) @@ -1308,7 +1308,7 @@ self.setexec = [] fd, messagefile = tempfile.mkstemp(prefix='hg-convert-') - fp = os.fdopen(fd, pycompat.sysstr('w')) + fp = os.fdopen(fd, pycompat.sysstr('wb')) fp.write(commit.desc) fp.close() try: