# Path: nbdiff/adapter/vcs_adapter.py
# class VcsAdapter(object):
# 
#     def get_modified_notebooks(self):
#         raise NotImplementedError("Subclass must implement abstract method")
# 
#     def filter_modified_notebooks(self, file_hooks):
#         modified_notebooks = []
#         for item in file_hooks:
#             if re.search('.ipynb$', item[2]):
#                 modified_notebooks.append(item)
# 
#         return modified_notebooks
# 
#     def get_unmerged_notebooks(self):
#         raise NotImplementedError("Subclass must implement abstract method")
# 
#     def filter_unmerged_notebooks(self, file_hooks):
#         unmerged_notebooks = []
#         for item in file_hooks:
#             if re.search('.ipynb$', item[3]):
#                 unmerged_notebooks.append(item)
# 
#         return unmerged_notebooks
# 
#     def stage_file(self, file, contents=None):
#         raise NotImplementedError("Subclass must implement abstract method")
# 
# Path: nbdiff/adapter/vcs_adapter.py
# class NoVCSError(Exception):
#     def __init__(self, value):
#         self.value = value
# 
#     def __str__(self):
#         return repr(self.value)


import hglib
import os
import StringIO
from .vcs_adapter import VcsAdapter
from .vcs_adapter import NoVCSError
__author__ = 'root'



# A deliberate copy of GitAdapter's error message:
ERR_MSG = "fatal: Not a hg  repository (or any of the parent directories): .hg"


def get_hlib_client_and_path():
    try:
        client = hglib.open()
        repopath = client.root()
        return client, repopath
    except Exception:

# Path: nbdiff/adapter/vcs_adapter.py
# class VcsAdapter(object):
# 
#     def get_modified_notebooks(self):
#         raise NotImplementedError("Subclass must implement abstract method")
# 
#     def filter_modified_notebooks(self, file_hooks):
#         modified_notebooks = []
#         for item in file_hooks:
#             if re.search('.ipynb$', item[2]):
#                 modified_notebooks.append(item)
# 
#         return modified_notebooks
# 
#     def get_unmerged_notebooks(self):
#         raise NotImplementedError("Subclass must implement abstract method")
# 
#     def filter_unmerged_notebooks(self, file_hooks):
#         unmerged_notebooks = []
#         for item in file_hooks:
#             if re.search('.ipynb$', item[3]):
#                 unmerged_notebooks.append(item)
# 
#         return unmerged_notebooks
# 
#     def stage_file(self, file, contents=None):
#         raise NotImplementedError("Subclass must implement abstract method")
# 
# Path: nbdiff/adapter/vcs_adapter.py
# class NoVCSError(Exception):
#     def __init__(self, value):
#         self.value = value
# 
#     def __str__(self):
#         return repr(self.value)


# Path: nbdiff/adapter/hg_adapter.py
import hglib
import os
import StringIO
from .vcs_adapter import VcsAdapter
from .vcs_adapter import NoVCSError

__author__ = 'root'



# A deliberate copy of GitAdapter's error message:
ERR_MSG = "fatal: Not a hg  repository (or any of the parent directories): .hg"


def get_hlib_client_and_path():
    try:
        client = hglib.open()
        repopath = client.root()
        return client, repopath
    except Exception:

        raise NoVCSError(ERR_MSG)