# Path: git_trac/git_error.py
# class GitError(RuntimeError):
#     r"""
#     Error raised when git exits with a non-zero exit code.
# 
#     EXAMPLES::
# 
#         sage: from git_trac.git_error import GitError
#         sage: raise GitError({'exit_code':128, 'stdout':'', 'stderr':'', 'cmd':'command'})
#         Traceback (most recent call last):
#         ...
#         GitError: git returned with 
#         non-zero exit code (128) when executing "command"
#     """
#     def __init__(self, result, explain=None, advice=None):
#         r"""
#         Initialization.
# 
#         TESTS::
# 
#             sage: from git_trac.git_error import GitError
#             sage: type(GitError({'exit_code':128, 'stdout':'', 'stderr':'', 'cmd':'command'}))
#             <class 'git_trac.git_error.GitError'>
#         """
#         self.exit_code = result['exit_code']
#         self.cmd = result['cmd'].strip()
#         def prefix(string, prefix):
#             return '\n'.join([prefix + ': ' + line.rstrip() for line in string.splitlines()])
#         self.stdout = prefix(result['stdout'], '    STDOUT')
#         self.stderr = prefix(result['stderr'], '    STDERR')
#         self.explain = explain
#         self.advice = advice
#         template = 'git returned with non-zero exit code ({0}) when executing "{1}"'
#         msg = template.format(self.exit_code, self.cmd)
#         if len(self.stdout) != 0:
#             msg += '\n' + self.stdout
#         if len(self.stderr) != 0:
#             msg += '\n' + self.stderr
#         RuntimeError.__init__(self, msg)


import os
from .git_error import GitError
#  The "git trac ..." command extension for git
#  Copyright (C) 2013  Volker Braun <vbraun.name@gmail.com>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
##############################################################################





class Config(object):

    def __init__(self, git):
        self._git = git
        self._debug = False

    def _save(self, config_option, value):
        try:
            self._git.config('--local', '--unset-all', config_option)

# Path: git_trac/git_error.py
# class GitError(RuntimeError):
#     r"""
#     Error raised when git exits with a non-zero exit code.
# 
#     EXAMPLES::
# 
#         sage: from git_trac.git_error import GitError
#         sage: raise GitError({'exit_code':128, 'stdout':'', 'stderr':'', 'cmd':'command'})
#         Traceback (most recent call last):
#         ...
#         GitError: git returned with 
#         non-zero exit code (128) when executing "command"
#     """
#     def __init__(self, result, explain=None, advice=None):
#         r"""
#         Initialization.
# 
#         TESTS::
# 
#             sage: from git_trac.git_error import GitError
#             sage: type(GitError({'exit_code':128, 'stdout':'', 'stderr':'', 'cmd':'command'}))
#             <class 'git_trac.git_error.GitError'>
#         """
#         self.exit_code = result['exit_code']
#         self.cmd = result['cmd'].strip()
#         def prefix(string, prefix):
#             return '\n'.join([prefix + ': ' + line.rstrip() for line in string.splitlines()])
#         self.stdout = prefix(result['stdout'], '    STDOUT')
#         self.stderr = prefix(result['stderr'], '    STDERR')
#         self.explain = explain
#         self.advice = advice
#         template = 'git returned with non-zero exit code ({0}) when executing "{1}"'
#         msg = template.format(self.exit_code, self.cmd)
#         if len(self.stdout) != 0:
#             msg += '\n' + self.stdout
#         if len(self.stderr) != 0:
#             msg += '\n' + self.stderr
#         RuntimeError.__init__(self, msg)


# Path: git_trac/config.py
import os
from .git_error import GitError

#  The "git trac ..." command extension for git
#  Copyright (C) 2013  Volker Braun <vbraun.name@gmail.com>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
##############################################################################





class Config(object):

    def __init__(self, git):
        self._git = git
        self._debug = False

    def _save(self, config_option, value):
        try:
            self._git.config('--local', '--unset-all', config_option)

        except GitError: