# Path: wikked/scm/base.py
# class SourceControl(object):
#     def __init__(self):
#         pass
# 
#     def start(self, wiki):
#         pass
# 
#     def init(self, wiki):
#         pass
# 
#     def postInit(self):
#         pass
# 
#     def getSpecialFilenames(self):
#         raise NotImplementedError()
# 
#     def getHistory(self, path=None, limit=10, after_rev=None):
#         raise NotImplementedError()
# 
#     def getState(self, path):
#         raise NotImplementedError()
# 
#     def getRevision(self, path, rev):
#         raise NotImplementedError()
# 
#     def diff(self, path, rev1, rev2):
#         raise NotImplementedError()
# 
#     def commit(self, paths, op_meta):
#         pass
# 
#     def revert(self, paths=None):
#         pass
# 
# STATE_NEW = 2
# 
# STATE_MODIFIED = 1
# 
# STATE_COMMITTED = 0


import os
import os.path
import logging
import subprocess
    import pygit2
from .base import (
        SourceControl,
        STATE_NEW, STATE_MODIFIED, STATE_COMMITTED)

try:
    SUPPORTS_GIT = True
except ImportError:
    SUPPORTS_GIT = False


logger = logging.getLogger(__name__)


class GitBaseSourceControl(SourceControl):
    def __init__(self, root):
        SourceControl.__init__(self)
        self.root = root

    def start(self, wiki):
        # Make a Git repo if there's none.
        if not os.path.isdir(os.path.join(self.root, '.git')):
            logger.info("Creating Git repository at: " + self.root)
            self._initRepo(self.root)

        # Create a `.gitignore` file there's none.
        ignore_path = os.path.join(self.root, '.gitignore')
        if not os.path.isfile(ignore_path):
            logger.info("Creating `.gitignore` file.")
            with open(ignore_path, 'w') as f:
                f.write('.wiki')
            self._add(ignore_path)
            self._commit('Created .gitignore.', [ignore_path])


# Path: wikked/scm/base.py
# class SourceControl(object):
#     def __init__(self):
#         pass
# 
#     def start(self, wiki):
#         pass
# 
#     def init(self, wiki):
#         pass
# 
#     def postInit(self):
#         pass
# 
#     def getSpecialFilenames(self):
#         raise NotImplementedError()
# 
#     def getHistory(self, path=None, limit=10, after_rev=None):
#         raise NotImplementedError()
# 
#     def getState(self, path):
#         raise NotImplementedError()
# 
#     def getRevision(self, path, rev):
#         raise NotImplementedError()
# 
#     def diff(self, path, rev1, rev2):
#         raise NotImplementedError()
# 
#     def commit(self, paths, op_meta):
#         pass
# 
#     def revert(self, paths=None):
#         pass
# 
# STATE_NEW = 2
# 
# STATE_MODIFIED = 1
# 
# STATE_COMMITTED = 0


# Path: wikked/scm/git.py
import os
import os.path
import logging
import subprocess
    import pygit2
from .base import (
        SourceControl,
        STATE_NEW, STATE_MODIFIED, STATE_COMMITTED)


try:
    SUPPORTS_GIT = True
except ImportError:
    SUPPORTS_GIT = False


logger = logging.getLogger(__name__)


class GitBaseSourceControl(SourceControl):
    def __init__(self, root):
        SourceControl.__init__(self)
        self.root = root

    def start(self, wiki):
        # Make a Git repo if there's none.
        if not os.path.isdir(os.path.join(self.root, '.git')):
            logger.info("Creating Git repository at: " + self.root)
            self._initRepo(self.root)

        # Create a `.gitignore` file there's none.
        ignore_path = os.path.join(self.root, '.gitignore')
        if not os.path.isfile(ignore_path):
            logger.info("Creating `.gitignore` file.")
            with open(ignore_path, 'w') as f:
                f.write('.wiki')
            self._add(ignore_path)
            self._commit('Created .gitignore.', [ignore_path])


    def getSpecialFilenames(self):