X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/1e78b00609d4d284f6316a328aa9b25c1cf2a254..925ff4a7136e29976b88a0d820fd883c6dae5b88:/stgit/config.py diff --git a/stgit/config.py b/stgit/config.py index e6c9538..a2e29bb 100644 --- a/stgit/config.py +++ b/stgit/config.py @@ -20,11 +20,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import os, ConfigParser +from stgit import basedir -if 'GIT_DIR' in os.environ: - __git_dir = os.environ['GIT_DIR'] -else: - __git_dir = '.git' config = ConfigParser.RawConfigParser() @@ -32,19 +29,46 @@ config = ConfigParser.RawConfigParser() config.add_section('stgit') config.set('stgit', 'autoresolved', 'no') config.set('stgit', 'smtpserver', 'localhost:25') -config.set('stgit', 'smtpdelay', '2') +config.set('stgit', 'smtpdelay', '5') +config.set('stgit', 'pullcmd', 'git-pull') config.set('stgit', 'merger', - 'diff3 -L local -L older -L remote -m -E ' \ + 'diff3 -L current -L ancestor -L patched -m -E ' \ '"%(branch1)s" "%(ancestor)s" "%(branch2)s" > "%(output)s"') config.set('stgit', 'keeporig', 'yes') +config.set('stgit', 'keepoptimized', 'no') +config.set('stgit', 'extensions', '.ancestor .current .patched') # Read the configuration files (if any) and override the default settings config.read('/etc/stgitrc') config.read(os.path.expanduser('~/.stgitrc')) -config.read(os.path.join(__git_dir, 'stgitrc')) +config.read(os.path.join(basedir.get(), 'stgitrc')) + +# Set the PAGER environment to the config value (if any) +if config.has_option('stgit', 'pager'): + os.environ['PAGER'] = config.get('stgit', 'pager') # [gitmergeonefile] section is deprecated. In case it exists copy the # options/values to the [stgit] one if config.has_section('gitmergeonefile'): for option, value in config.items('gitmergeonefile'): config.set('stgit', option, value) + + +# cached extensions +__extensions = None + +def file_extensions(): + """Returns a dictionary with the conflict file extensions + """ + global __extensions + + if not __extensions: + cfg_ext = config.get('stgit', 'extensions').split() + if len(cfg_ext) != 3: + raise CmdException, '"extensions" configuration error' + + __extensions = { 'ancestor': cfg_ext[0], + 'current': cfg_ext[1], + 'patched': cfg_ext[2] } + + return __extensions