242
242
"""Check if an index is present."""
243
243
return os.path.exists(self.index_path())
245
def fetch(self, target, determine_wants=None, progress=None):
246
"""Fetch objects into another repository.
248
:param target: The target repository
249
:param determine_wants: Optional function to determine what refs to
251
:param progress: Optional progress function
253
target.object_store.add_objects(
254
self.fetch_objects(determine_wants, target.get_graph_walker(),
256
return self.get_refs()
245
258
def fetch_objects(self, determine_wants, graph_walker, progress):
246
259
"""Fetch the missing objects required for a set of revisions.
396
409
del self.refs[name]
397
410
raise ValueError(name)
412
def do_commit(self, committer, message,
413
author=None, commit_timestamp=None,
414
commit_timezone=None, author_timestamp=None,
415
author_timezone=None, tree=None):
416
"""Create a new commit.
418
:param committer: Committer fullname
419
:param message: Commit message
420
:param author: Author fullname (defaults to committer)
421
:param commit_timestamp: Commit timestamp (defaults to now)
422
:param commit_timezone: Commit timestamp timezone (defaults to GMT)
423
:param author_timestamp: Author timestamp (defaults to commit timestamp)
424
:param author_timezone: Author timestamp timezone
425
(defaults to commit timestamp timezone)
426
:param tree: SHA1 of the tree root to use (if not specified the current index will be committed).
427
:return: New commit SHA1
429
from dulwich.index import commit_index
431
index = self.open_index()
434
c.tree = commit_index(self.object_store, index)
437
c.committer = committer
438
if commit_timestamp is None:
439
commit_timestamp = time.time()
440
c.commit_time = int(commit_timestamp)
441
if commit_timezone is None:
443
c.commit_timezone = commit_timezone
447
if author_timestamp is None:
448
author_timestamp = commit_timestamp
449
c.author_time = int(author_timestamp)
450
if author_timezone is None:
451
author_timezone = commit_timezone
452
c.author_timezone = author_timezone
454
self.object_store.add_object(c)
455
self.refs["HEAD"] = c.id
400
459
def init(cls, path, mkdir=True):
401
460
controldir = os.path.join(path, ".git")