Example #1
0
def main(argv):
    o = options.Options("crampi fake-merge", optspec)
    (opt, flags, extra) = o.parse(argv[1:])

    if len(extra):
        o.fatal("no arguments expected")
    if not opt.branch:
        o.fatal("you must specify the -b option")
    if not opt.merge:
        o.fatal("you must specify the -m option")

    g = gitdb.GitDb(opt.gitdb)

    cid = g.commitid_latest(opt.branch)
    if not cid:
        o.fatal("nonexistent commit: %r" % opt.branch)

    el = entry.load_tree_from_commit(g, cid)
    print merge.run(
        g,
        el,
        opt.branch,
        opt.merge,
        opt.verbose,
        add_contact=lambda d: None,
        update_contact=lambda lid, d, changes: None,
        commit_contacts=lambda: None,
        reload_entrylist=lambda el: el,
    )
    g.flush()
Example #2
0
def main(argv):
    o = options.Options("crampi mapi", optspec)
    (opt, flags, extra) = o.parse(argv[1:])

    if len(extra) != 1:
        o.fatal("you must provide exactly one folder name")
    fname = extra[0]

    if not opt.branch:
        o.fatal("you must specify the -b option")

    g = gitdb.GitDb(opt.gitdb)
    sess = cmapi.Session()
    f = sess.recursive_find(fname)
    el = entry.Entries(entries(f))
    el.uuids_from_commit(g, opt.branch)
    el.assign_missing_uuids(g)
    if opt.verbose:
        for e in sorted(el.entries, key=lambda x: x.uuid):
            log("%s\n" % e)
    print el.save_commit(g, opt.branch, msg="exported from mapi %r on %s" % (fname, time.asctime()))

    if opt.merge:

        def do_load(el):
            el2 = entry.Entries(entries(f))
            el2.uuids_from_entrylist(el)
            el2.assert_all_uuids()
            return el2

        print merge.run(
            g,
            el,
            opt.branch,
            opt.merge,
            opt.verbose,
            add_contact=lambda d: add_contact(f, d),
            update_contact=lambda lid, d, changes: update_contact(f, lid, d, changes),
            commit_contacts=lambda: None,
            reload_entrylist=do_load,
        )

    g.flush()
Example #3
0
def main(argv):
    o = options.Options('crampi ffcrm', optspec)
    (opt, flags, extra) = o.parse(argv[1:])

    if len(extra) != 1:
        o.fatal('exactly one argument expected')
    opt.crmdb = extra[0]

    if not opt.branch:
        o.fatal('you must specify the -b option')
    if not os.path.exists(opt.crmdb):
        o.fatal('crmdb %r does not exist' % opt.crmdb)
    if opt.merge == opt.branch:
        o.fatal('--merge parameter %r must differ from branch %r'
                % (opt.merge, opt.branch))

    g = gitdb.GitDb(opt.gitdb)
    s = sqlite3.connect(opt.crmdb)
    el = entry.Entries(entries(s))
    el.uuids_from_commit(g, opt.branch)
    el.assign_missing_uuids(g)
    if opt.verbose:
        for e in sorted(el.entries, key = lambda x: x.uuid):
            log('%s\n' % e)
    print el.save_commit(g, opt.branch, 'exported from ffcrm %r' % opt.crmdb)

    if opt.merge:
        def do_load(el):
            el2 = entry.Entries(entries(s))
            el2.uuids_from_entrylist(el)
            el2.assert_all_uuids()
            return el2
        print merge.run(g, el, opt.branch, opt.merge, opt.verbose,
                        add_contact = lambda d: add_contact(s, d),
                        update_contact = lambda lid, d, changes: 
                             update_contact(s, lid, d),
                        commit_contacts = lambda: s.commit(),
                        reload_entrylist = do_load)
    
    g.flush()
Example #4
0
 def run_merge(args):
     merge.run()