def testpacks(): git.init_repo("pybuptest.tmp") git.verbose = 1 now = str(time.time()) # hopefully not in any packs yet w = git.PackWriter() w.write("blob", now) w.write("blob", now) w.abort() w = git.PackWriter() hashes = [] for i in range(1000): hashes.append(w.write("blob", str(i))) log("\n") nameprefix = w.close() print repr(nameprefix) WVPASS(os.path.exists(nameprefix + ".pack")) WVPASS(os.path.exists(nameprefix + ".idx")) r = git.PackIndex(nameprefix + ".idx") print repr(r.fanout) for i in range(1000): WVPASS(r.find_offset(hashes[i]) > 0) WVPASS(r.exists(hashes[99])) WVFAIL(r.exists("\0" * 20)) WVFAIL(r.find_offset("\0" * 20)) r = git.MultiPackIndex("pybuptest.tmp/objects/pack") WVPASS(r.exists(hashes[5])) WVPASS(r.exists(hashes[6])) WVFAIL(r.exists("\0" * 20))
def testpacks(): git.init_repo('pybuptest.tmp') git.verbose = 1 now = str(time.time()) # hopefully not in any packs yet w = git.PackWriter() w.write('blob', now) w.write('blob', now) w.abort() w = git.PackWriter() hashes = [] nobj = 1000 for i in range(nobj): hashes.append(w.write('blob', str(i))) log('\n') nameprefix = w.close() print repr(nameprefix) WVPASS(os.path.exists(nameprefix + '.pack')) WVPASS(os.path.exists(nameprefix + '.idx')) r = git.PackIndex(nameprefix + '.idx') print repr(r.fanout) for i in range(nobj): WVPASS(r.find_offset(hashes[i]) > 0) WVPASS(r.exists(hashes[99])) WVFAIL(r.exists('\0'*20)) pi = iter(r) for h in sorted(hashes): WVPASSEQ(str(pi.next()).encode('hex'), h.encode('hex')) WVFAIL(r.find_offset('\0'*20)) r = git.MultiPackIndex('pybuptest.tmp/objects/pack') WVPASS(r.exists(hashes[5])) WVPASS(r.exists(hashes[6])) WVFAIL(r.exists('\0'*20))
#!/usr/bin/env python import git, options, client from helpers import * optspec = """ [BUP_DIR=...] bup init [-r host:path] -- r,remote= remote repository path """ o = options.Options('bup init', optspec) (opt, flags, extra) = o.parse(sys.argv[1:]) if extra: log("bup init: no arguments expected\n") o.usage() if opt.remote: git.init_repo() # local repo git.check_repo_or_die() cli = client.Client(opt.remote, create=True) cli.close() else: git.init_repo()
def init_dir(conn, arg): git.init_repo(arg) log('bup server: bupdir initialized: %r\n' % git.repodir) conn.ok()
def new_repo(self, directory): # create the repository return git.init_repo(directory)
#!/usr/bin/env python2.5 import git, options, client from helpers import * optspec = """ [BUP_DIR=...] bup init [-r host:path] -- r,remote= remote repository path """ o = options.Options('bup init', optspec) (opt, flags, extra) = o.parse(sys.argv[1:]) if extra: log("bup init: no arguments expected\n") o.usage() if opt.remote: git.init_repo() # local repo git.check_repo_or_die() cli = client.Client(opt.remote, create=True) cli.close() exit(0) # if close() didn't throw an exception else: exit(git.init_repo())