# Path: dgitcore/helper.py
# def run(cmd):
#     """
#     Run a shell command
#     """
#     cmd = [pipes.quote(c) for c in cmd]
#     cmd = " ".join(cmd)
#     cmd += "; exit 0"
#     # print("Running {} in {}".format(cmd, os.getcwd()))
#     try:
#         output = subprocess.check_output(cmd,
#                                          stderr=subprocess.STDOUT,
#                                          shell=True)
#     except subprocess.CalledProcessError as e:
#             output = e.output
# 
#     output = output.decode('utf-8')
#     output = output.strip()
#     return output
# 
# class cd:
#     """Context manager for changing the current working directory"""
#     def __init__(self, newPath):
#         self.newPath = os.path.expanduser(newPath)
# 
#     def __enter__(self):
#         self.savedPath = os.getcwd()
#         os.chdir(self.newPath)
# 
#     def __exit__(self, etype, value, traceback):
#         os.chdir(self.savedPath)
# 
# Path: dgitcore/plugins/common.py
# def plugins_get_mgr():
#     """
#     Get the global plugin manager
#     """
#     global pluginmgr
#     return pluginmgr


import os, sys, parse, shutil 
import traceback 
import subprocess, pipes
import tempfile 
import json
import daff
from collections import OrderedDict
from ..helper import run, cd
from ..plugins.common import plugins_get_mgr
            })
        else:
            raise Exception("Could not construct tree")

        branches[commit] = d

        # print("updated branches with", d)

    for i in range(len(history)):
        commit = history[i]['commit']
        if commit not in branches:
            raise Exception("Missing branch information for " + commit)
        history[i]['action'] = branches[commit]['action']
        history[i]['branch'] = branches[commit]['branch']
        history[i]['parent-branches'] = branches[commit]['parent-branches']

    # print(json.dumps(branches, indent=4))
    #values = branches.values()
    #values = sorted(values, key=lambda k: k['timestamp'], reverse=True)
    #print(json.dumps(values, indent=4))

    return history


def get_diffs(history):
    """
    Look at files and compute the diffs intelligently
    """

    # First get all possible representations

# Path: dgitcore/helper.py
# def run(cmd):
#     """
#     Run a shell command
#     """
#     cmd = [pipes.quote(c) for c in cmd]
#     cmd = " ".join(cmd)
#     cmd += "; exit 0"
#     # print("Running {} in {}".format(cmd, os.getcwd()))
#     try:
#         output = subprocess.check_output(cmd,
#                                          stderr=subprocess.STDOUT,
#                                          shell=True)
#     except subprocess.CalledProcessError as e:
#             output = e.output
# 
#     output = output.decode('utf-8')
#     output = output.strip()
#     return output
# 
# class cd:
#     """Context manager for changing the current working directory"""
#     def __init__(self, newPath):
#         self.newPath = os.path.expanduser(newPath)
# 
#     def __enter__(self):
#         self.savedPath = os.getcwd()
#         os.chdir(self.newPath)
# 
#     def __exit__(self, etype, value, traceback):
#         os.chdir(self.savedPath)
# 
# Path: dgitcore/plugins/common.py
# def plugins_get_mgr():
#     """
#     Get the global plugin manager
#     """
#     global pluginmgr
#     return pluginmgr


# Path: dgitcore/datasets/history.py
import os, sys, parse, shutil 
import traceback 
import subprocess, pipes
import tempfile 
import json
import daff
from collections import OrderedDict
from ..helper import run, cd
from ..plugins.common import plugins_get_mgr

            })
        else:
            raise Exception("Could not construct tree")

        branches[commit] = d

        # print("updated branches with", d)

    for i in range(len(history)):
        commit = history[i]['commit']
        if commit not in branches:
            raise Exception("Missing branch information for " + commit)
        history[i]['action'] = branches[commit]['action']
        history[i]['branch'] = branches[commit]['branch']
        history[i]['parent-branches'] = branches[commit]['parent-branches']

    # print(json.dumps(branches, indent=4))
    #values = branches.values()
    #values = sorted(values, key=lambda k: k['timestamp'], reverse=True)
    #print(json.dumps(values, indent=4))

    return history


def get_diffs(history):
    """
    Look at files and compute the diffs intelligently
    """

    # First get all possible representations

    mgr = plugins_get_mgr() 