Mercurial > hg
comparison hgext/convert/subversion.py @ 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 | 671aba341d90 |
children | 0f9e52f900c4 |
comparison
equal
deleted
inserted
replaced
36131:ce9f1c32810b | 36132:42a393ea56d2 |
---|---|
229 # this by requesting a version-controlled URL we know can't exist and looking | 229 # this by requesting a version-controlled URL we know can't exist and looking |
230 # for the svn-specific "not found" XML. | 230 # for the svn-specific "not found" XML. |
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: |
238 # Except for 404 we cannot know for sure this is not an svn repo | 238 # Except for 404 we cannot know for sure this is not an svn repo |
239 ui.warn(_('svn: cannot probe remote repository, assume it could ' | 239 ui.warn(_('svn: cannot probe remote repository, assume it could ' |
637 def converted(self, rev, destrev): | 637 def converted(self, rev, destrev): |
638 if not self.wc: | 638 if not self.wc: |
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 |
646 def revid(self, revnum, module=None): | 646 def revid(self, revnum, module=None): |
647 return 'svn:%s%s@%s' % (self.uuid, module or self.module, revnum) | 647 return 'svn:%s%s@%s' % (self.uuid, module or self.module, revnum) |
1156 else: | 1156 else: |
1157 self.is_exec = None | 1157 self.is_exec = None |
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) |
1165 | 1165 |
1166 output = self.run0('info') | 1166 output = self.run0('info') |
1306 if self.setexec: | 1306 if self.setexec: |
1307 self.xargs(self.setexec, 'propset', 'svn:executable', '*') | 1307 self.xargs(self.setexec, 'propset', 'svn:executable', '*') |
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: |
1315 output = self.run0('commit', | 1315 output = self.run0('commit', |
1316 username=util.shortuser(commit.author), | 1316 username=util.shortuser(commit.author), |