# HG changeset patch # User Patrick Mezard # Date 1254666691 -7200 # Node ID 9e722e8d001d1629243b935bd6421deb8f5b0db9 # Parent f5441510cbb05b8b0f067da6caa606d4d77655de Replace ConfigParser with mercurial.config when available Mercurial >= 1.3 no longer uses ConfigParser, so the module is no longer shipped by Windows py2exe binaries, which means forest no longer works with them. Use mercurial.config instead. diff -r f5441510cbb0 -r 9e722e8d001d forest.py --- a/forest.py Sun Oct 04 16:21:00 2009 +0200 +++ b/forest.py Sun Oct 04 16:31:31 2009 +0200 @@ -49,7 +49,6 @@ """ -import ConfigParser import errno import os import re @@ -109,16 +108,34 @@ if not hasattr(hgweb, 'protocol'): hgweb.protocol = hgweb.hgweb_mod.hgweb -ConfigError = ConfigParser.Error - -class SnapshotError(ConfigParser.NoSectionError): - pass +# There are no issues with backward compatibility and ConfigParser. +# But since it was replaced in mercurial >= 1.3, the module is not +# longer shipped by Windows binary packages. In this case, use +# mercurial.config instead. +try: + from mercurial import config + ConfigError = error.ConfigError -def readconfig(path): - cfg = ConfigParser.RawConfigParser() - if not cfg.read([path]): - return None - return cfg + def readconfig(path): + cfg = config.config() + try: + cfg.read(path) + return cfg + except IOError: + return None + +except (ImportError, AttributeError): + import ConfigParser + ConfigError = ConfigParser.Error + + def readconfig(path): + cfg = ConfigParser.RawConfigParser() + if not cfg.read([path]): + return None + return cfg + +class SnapshotError(ConfigError): + pass def cmd_options(ui, cmd, remove=None, table=commands.table): aliases, spec = findcmd(ui, cmd, table)