예제 #1
0
파일: ignore.py 프로젝트: rhelmot/patman
def main(args, repo):
    if repo is None:
        repo = manager.resolve()
    with repo.lock:
        if len(args) == 0:
            import help as p_help

            p_help.main(["ignore"])
            return 1
        elif args[0] == "list":
            print "\n".join(repo.get_ignores())
        elif args[0] == "remove":
            ignores = repo.get_ignores()
            for pattern in args[1:]:
                if not pattern in ignores:
                    print 'Can\'t remove "%s" from ignores, not present' % pattern
                else:
                    ignores.remove(pattern)
            repo.set_ignores(ignores)
        else:
            ignores = repo.get_ignores()
            ignores += args
            repo.set_ignores(ignores)

        return 0
예제 #2
0
파일: list.py 프로젝트: rhelmot/patman
def main(args, repo):
    if repo is None: repo = manager.resolve()
    with repo.lock:
        csnap = repo.get_current_snapshot()
        for name, ctime in repo.list_snapshots():
            indic = '*' if csnap == name else ' '
            print '%20s %s %s' % (name, indic, ctime)
        return 1
예제 #3
0
파일: init.py 프로젝트: rhelmot/patman
def main(args, repo):
    if repo is not None:
        import help as p_help
        p_help.main(['init'])
        return 1

    try:
        manager.resolve()
        print 'No nested projects!'
        return 1
    except Exception:
        pass

    if not any(not x.startswith('.') for x in os.listdir('.')):
        raise Exception('Not initializing empty directory!')

    ppath = os.environ['PWD']
    phash = manager.shash(ppath)
    if len(args) < 1:
        args.append(raw_input("Give a name for this project: "))
    #if len(args) < 2:
    #    args.append(raw_input("Give the name of the executable for this project: "))
    # TODO: validate names
    #try:
    #    open(args[1])
    #except:
    #    print "Executable file doesn't exist!"
    #    print 'it was "%s"' % args[1]
    #    return 1

    cfgdir = os.path.join(manager.PATH, phash)
    os.mkdir(cfgdir)
    os.symlink(cfgdir, os.path.join(manager.PATH, args[0]))
    os.mkdir(os.path.join(cfgdir, 'snapshots'))
    os.mkdir(os.path.join(cfgdir, 'config'))
    open(os.path.join(cfgdir, 'config/destination'), 'w').write(ppath)
    repo = manager.Project(cfgdir)
    with repo.lock:
        #repo.set_executable(args[1])
        repo.set_ignores([])
        repo.snapshot('original')
        return 0
예제 #4
0
파일: __init__.py 프로젝트: rhelmot/patman
def main():
    if len(sys.argv) < 2:
        return cmd('help')
    elif sys.argv[1] in commands:
        return cmd(sys.argv[1], sys.argv[2:])
    elif len(sys.argv) < 3:
        return cmd('help')
    elif sys.argv[2] in commands:
        repo = manager.resolve(sys.argv[1])
        return cmd(sys.argv[2], sys.argv[3:], repo)
    else:
        return cmd('help')
예제 #5
0
파일: use.py 프로젝트: rhelmot/patman
def main(args, repo):
    if repo is None: repo = manager.resolve()
    with repo.lock:
        if len(args) == 0:
            import help as p_help
            p_help.main(['use'])
            return 1
        if args[0] not in zip(*repo.list_snapshots())[0]:
            print 'Argument is not a snapshot name!'
            return 1
        repo.restore(args[0])
        return 0
예제 #6
0
파일: snap.py 프로젝트: rhelmot/patman
def main(args, repo):
    if repo is None: repo = manager.resolve()
    with repo.lock:
        if len(args) == 0:
            import help as p_help
            p_help.main(['snap'])
            return 1
        if args[0] in zip(*repo.list_snapshots())[0]:
            print 'There is already a snapshot named "%s"!' % args[0]
            return 1

        repo.snapshot(args[0])
        return 0
예제 #7
0
파일: status.py 프로젝트: rhelmot/patman
def main(args, repo):
    if repo is None: repo = manager.resolve()
    with repo.lock:
        if len(args) == 0:
            snap = repo.get_current_snapshot()
        else:
            snap = args[0]
            if not snap in zip(*repo.list_snapshots())[0]:
                print '%s is not a snapshot name!' % snap
                return 1
        diffs = repo.compare_snapshot(snap)
        if len(diffs) == 0 or (len(diffs) == 1 and diffs[0] == ''):
            print 'Using snapshot %s' % snap
            return 0
        else:
            print 'Using snapshot %s, with modifications:' % snap
            print '\n'.join(diffs)
            return 1
예제 #8
0
파일: delete.py 프로젝트: rhelmot/patman
def main(args=[], repo=None):
    if repo is None: repo = manager.resolve()
    with repo.lock:
        repo.delete()
        return 0