# Python interface to Hope, Harlequin's version control system.
#
# This was written in order to extract MLWorks, including all of its
# history, from a collection of "compounds" sold by Xanalys to
# Ravenbrook.
# 
# Nick Barnes, Ravenbrook Limited, 2015-01-13.
#
# $Id: //info.ravenbrook.com/project/mlworks/import/2013-04-25/xanalys-tarball/mlworks.py#2 $
#
# To run:
# >>> hope.compound('MLW').extract()

import os
import hope

base = 'hope'

def MLW():
    hope.get_compounds(base)
    return hope.compound('MLW')

def add(units, dir='MLWorks', git_branch='master'):
    for u in units:
        # TODO: Do something!
        pass

def export(dir='MLWorks'):
    os.makedirs(dir)
    os.system('cd %s && git init' % dir)
    revsets = list(hope.slide(base, count=99999999999999, slack=600, noisy=0))
    unit_branches = {}
    for rs in revsets:
        rst = rs.first
        for r in rs:
            t = r.timestamp
            f = r.rcsfile
            if isinstance(f, hope.HopeUnit):
                unit_branches[(f.compound, f.name)
                pass
            else: # hope.HopeMetadata
                pass
                
    
                   



