Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/merge.py @ 25660:328739ea70c3
global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".
This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.
This patch was produced by running `2to3 -f except -w -n .`.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 23 Jun 2015 22:20:08 -0700 |
parents | 6eb4bdad198f |
children | 19cc443aac34 |
comparison
equal
deleted
inserted
replaced
25659:d60678a567a9 | 25660:328739ea70c3 |
---|---|
143 if i == 0: | 143 if i == 0: |
144 records.append(('L', l[:-1])) | 144 records.append(('L', l[:-1])) |
145 else: | 145 else: |
146 records.append(('F', l[:-1])) | 146 records.append(('F', l[:-1])) |
147 f.close() | 147 f.close() |
148 except IOError, err: | 148 except IOError as err: |
149 if err.errno != errno.ENOENT: | 149 if err.errno != errno.ENOENT: |
150 raise | 150 raise |
151 return records | 151 return records |
152 | 152 |
153 def _readrecordsv2(self): | 153 def _readrecordsv2(self): |
168 off += 4 | 168 off += 4 |
169 record = data[off:(off + length)] | 169 record = data[off:(off + length)] |
170 off += length | 170 off += length |
171 records.append((rtype, record)) | 171 records.append((rtype, record)) |
172 f.close() | 172 f.close() |
173 except IOError, err: | 173 except IOError as err: |
174 if err.errno != errno.ENOENT: | 174 if err.errno != errno.ENOENT: |
175 raise | 175 raise |
176 return records | 176 return records |
177 | 177 |
178 def active(self): | 178 def active(self): |
658 if verbose: | 658 if verbose: |
659 repo.ui.note(_("removing %s\n") % f) | 659 repo.ui.note(_("removing %s\n") % f) |
660 audit(f) | 660 audit(f) |
661 try: | 661 try: |
662 unlink(wjoin(f), ignoremissing=True) | 662 unlink(wjoin(f), ignoremissing=True) |
663 except OSError, inst: | 663 except OSError as inst: |
664 repo.ui.warn(_("update failed to remove %s: %s!\n") % | 664 repo.ui.warn(_("update failed to remove %s: %s!\n") % |
665 (f, inst.strerror)) | 665 (f, inst.strerror)) |
666 if i == 100: | 666 if i == 100: |
667 yield i, f | 667 yield i, f |
668 i = 0 | 668 i = 0 |