本文整理汇总了Python中dulwich.pack.PackData.calculate_checksum方法的典型用法代码示例。如果您正苦于以下问题:Python PackData.calculate_checksum方法的具体用法?Python PackData.calculate_checksum怎么用?Python PackData.calculate_checksum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.pack.PackData
的用法示例。
在下文中一共展示了PackData.calculate_checksum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply_pack
# 需要导入模块: from dulwich.pack import PackData [as 别名]
# 或者: from dulwich.pack.PackData import calculate_checksum [as 别名]
def apply_pack(self, refs, read):
""" apply pack from client to current repository """
fd, path = tempfile.mkstemp(suffix=".pack")
f = os.fdopen(fd, 'w')
f.write(read())
f.close()
p = PackData(path)
entries = p.sorted_entries()
write_pack_index_v2(path[:-5]+".idx", entries, p.calculate_checksum())
def get_objects():
pack = Pack(path[:-5])
for obj in pack.iterobjects():
yield obj
target = Repository.open(self.directory)
target.lock_write()
try:
target.start_write_group()
try:
import_git_objects(target, self.mapping, iter(get_objects()))
finally:
target.commit_write_group()
finally:
target.unlock()
for oldsha, sha, ref in refs:
if ref[:11] == 'refs/heads/':
branch_nick = ref[11:]
try:
target_dir = BzrDir.open(self.directory + "/" + branch_nick)
except:
target_dir = BzrDir.create(self.directory + "/" + branch_nick)
try:
target_branch = target_dir.open_branch()
except:
target_branch = target_dir.create_branch()
rev_id = self.mapping.revision_id_foreign_to_bzr(sha)
target_branch.generate_revision_history(rev_id)