Mercurial > hg-stable
diff mercurial/branchmap.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 | 38117278f295 |
children | 47f36e050c2e |
line wrap: on
line diff
--- a/mercurial/branchmap.py Tue Jun 23 22:38:21 2015 -0700 +++ b/mercurial/branchmap.py Tue Jun 23 22:20:08 2015 -0700 @@ -55,7 +55,7 @@ partial._closednodes.add(node) except KeyboardInterrupt: raise - except Exception, inst: + except Exception as inst: if repo.ui.debugflag: msg = 'invalid branchheads cache' if repo.filtername is not None: @@ -203,7 +203,7 @@ repo.ui.log('branchcache', 'wrote %s branch cache with %d labels and %d nodes\n', repo.filtername, len(self), nodecount) - except (IOError, OSError, util.Abort), inst: + except (IOError, OSError, util.Abort) as inst: repo.ui.debug("couldn't write branch cache: %s\n" % inst) # Abort may be raise by read only opener pass @@ -315,7 +315,7 @@ bndata = repo.vfs.read(_rbcnames) self._rbcsnameslen = len(bndata) # for verification before writing self._names = [encoding.tolocal(bn) for bn in bndata.split('\0')] - except (IOError, OSError), inst: + except (IOError, OSError) as inst: if readonly: # don't try to use cache - fall back to the slow path self.branchinfo = self._branchinfo @@ -324,7 +324,7 @@ try: data = repo.vfs.read(_rbcrevs) self._rbcrevs.fromstring(data) - except (IOError, OSError), inst: + except (IOError, OSError) as inst: repo.ui.debug("couldn't read revision branch cache: %s\n" % inst) # remember number of good records on disk @@ -418,7 +418,7 @@ for b in self._names[self._rbcnamescount:])) self._rbcsnameslen = f.tell() f.close() - except (IOError, OSError, util.Abort), inst: + except (IOError, OSError, util.Abort) as inst: repo.ui.debug("couldn't write revision branch cache names: " "%s\n" % inst) return @@ -436,7 +436,7 @@ end = revs * _rbcrecsize f.write(self._rbcrevs[start:end]) f.close() - except (IOError, OSError, util.Abort), inst: + except (IOError, OSError, util.Abort) as inst: repo.ui.debug("couldn't write revision branch cache: %s\n" % inst) return