Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.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 | f0745da75056 |
children | 0d37b9b21467 |
comparison
equal
deleted
inserted
replaced
25659:d60678a567a9 | 25660:328739ea70c3 |
---|---|
200 destvfs.makedir() | 200 destvfs.makedir() |
201 | 201 |
202 requirements = '' | 202 requirements = '' |
203 try: | 203 try: |
204 requirements = srcrepo.vfs.read('requires') | 204 requirements = srcrepo.vfs.read('requires') |
205 except IOError, inst: | 205 except IOError as inst: |
206 if inst.errno != errno.ENOENT: | 206 if inst.errno != errno.ENOENT: |
207 raise | 207 raise |
208 | 208 |
209 requirements += 'shared\n' | 209 requirements += 'shared\n' |
210 destvfs.write('requires', requirements) | 210 destvfs.write('requires', requirements) |
386 # only clean up directories we create ourselves | 386 # only clean up directories we create ourselves |
387 cleandir = hgdir | 387 cleandir = hgdir |
388 try: | 388 try: |
389 destpath = hgdir | 389 destpath = hgdir |
390 util.makedir(destpath, notindexed=True) | 390 util.makedir(destpath, notindexed=True) |
391 except OSError, inst: | 391 except OSError as inst: |
392 if inst.errno == errno.EEXIST: | 392 if inst.errno == errno.EEXIST: |
393 cleandir = None | 393 cleandir = None |
394 raise util.Abort(_("destination '%s' already exists") | 394 raise util.Abort(_("destination '%s' already exists") |
395 % dest) | 395 % dest) |
396 raise | 396 raise |
426 node=node.hex(node.nullid)) | 426 node=node.hex(node.nullid)) |
427 else: | 427 else: |
428 try: | 428 try: |
429 destpeer = peer(srcrepo or ui, peeropts, dest, create=True) | 429 destpeer = peer(srcrepo or ui, peeropts, dest, create=True) |
430 # only pass ui when no srcrepo | 430 # only pass ui when no srcrepo |
431 except OSError, inst: | 431 except OSError as inst: |
432 if inst.errno == errno.EEXIST: | 432 if inst.errno == errno.EEXIST: |
433 cleandir = None | 433 cleandir = None |
434 raise util.Abort(_("destination '%s' already exists") | 434 raise util.Abort(_("destination '%s' already exists") |
435 % dest) | 435 % dest) |
436 raise | 436 raise |