本文整理汇总了Python中dulwich.object_store.DiskObjectStore.iter_shas方法的典型用法代码示例。如果您正苦于以下问题:Python DiskObjectStore.iter_shas方法的具体用法?Python DiskObjectStore.iter_shas怎么用?Python DiskObjectStore.iter_shas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.object_store.DiskObjectStore
的用法示例。
在下文中一共展示了DiskObjectStore.iter_shas方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Repo
# 需要导入模块: from dulwich.object_store import DiskObjectStore [as 别名]
# 或者: from dulwich.object_store.DiskObjectStore import iter_shas [as 别名]
class Repo(object):
"""A local git repository.
:ivar refs: Dictionary with the refs in this repository
:ivar object_store: Dictionary-like object for accessing
the objects
"""
def __init__(self, root):
if os.path.isdir(os.path.join(root, ".git", OBJECTDIR)):
self.bare = False
self._controldir = os.path.join(root, ".git")
elif (os.path.isdir(os.path.join(root, OBJECTDIR)) and
os.path.isdir(os.path.join(root, REFSDIR))):
self.bare = True
self._controldir = root
else:
raise NotGitRepository(root)
self.path = root
self.refs = DiskRefsContainer(self.controldir())
self.object_store = DiskObjectStore(
os.path.join(self.controldir(), OBJECTDIR))
def controldir(self):
"""Return the path of the control directory."""
return self._controldir
def index_path(self):
"""Return path to the index file."""
return os.path.join(self.controldir(), INDEX_FILENAME)
def open_index(self):
"""Open the index for this repository."""
from dulwich.index import Index
return Index(self.index_path())
def has_index(self):
"""Check if an index is present."""
return os.path.exists(self.index_path())
def fetch(self, target, determine_wants=None, progress=None):
"""Fetch objects into another repository.
:param target: The target repository
:param determine_wants: Optional function to determine what refs to
fetch.
:param progress: Optional progress function
"""
target.object_store.add_objects(
self.fetch_objects(determine_wants, target.get_graph_walker(),
progress))
return self.get_refs()
def fetch_objects(self, determine_wants, graph_walker, progress):
"""Fetch the missing objects required for a set of revisions.
:param determine_wants: Function that takes a dictionary with heads
and returns the list of heads to fetch.
:param graph_walker: Object that can iterate over the list of revisions
to fetch and has an "ack" method that will be called to acknowledge
that a revision is present.
:param progress: Simple progress function that will be called with
updated progress strings.
:return: iterator over objects, with __len__ implemented
"""
wants = determine_wants(self.get_refs())
haves = self.object_store.find_common_revisions(graph_walker)
return self.object_store.iter_shas(
self.object_store.find_missing_objects(haves, wants, progress))
def get_graph_walker(self, heads=None):
if heads is None:
heads = self.refs.as_dict('refs/heads').values()
return self.object_store.get_graph_walker(heads)
def ref(self, name):
"""Return the SHA1 a ref is pointing to."""
try:
return self.refs.follow(name)
except KeyError:
return self.get_packed_refs()[name]
def get_refs(self):
"""Get dictionary with all refs."""
ret = {}
try:
if self.head():
ret['HEAD'] = self.head()
except KeyError:
pass
ret.update(self.refs.as_dict())
ret.update(self.get_packed_refs())
return ret
def get_packed_refs(self):
"""Get contents of the packed-refs file.
:return: Dictionary mapping ref names to SHA1s
:note: Will return an empty dictionary when no packed-refs file is
#.........这里部分代码省略.........