~ubuntu-branches/ubuntu/natty/dulwich/natty

« back to all changes in this revision

Viewing changes to dulwich/repo.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-01-03 16:40:19 UTC
  • mfrom: (1.2.8 upstream) (8.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100103164019-45gd3x1l2rovu24a
Tags: 0.4.1-1
* New upstream release.
 + Supports time-less tags. Closes: #543240
* Rebuilt against newer version of python-central. Closes: #551893

Show diffs side-by-side

added added

removed removed

Lines of Context:
242
242
        """Check if an index is present."""
243
243
        return os.path.exists(self.index_path())
244
244
 
 
245
    def fetch(self, target, determine_wants=None, progress=None):
 
246
        """Fetch objects into another repository.
 
247
 
 
248
        :param target: The target repository
 
249
        :param determine_wants: Optional function to determine what refs to 
 
250
            fetch.
 
251
        :param progress: Optional progress function
 
252
        """
 
253
        target.object_store.add_objects(
 
254
            self.fetch_objects(determine_wants, target.get_graph_walker(),
 
255
                progress))
 
256
        return self.get_refs()
 
257
 
245
258
    def fetch_objects(self, determine_wants, graph_walker, progress):
246
259
        """Fetch the missing objects required for a set of revisions.
247
260
 
396
409
            del self.refs[name]
397
410
        raise ValueError(name)
398
411
 
 
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.
 
417
 
 
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
 
428
        """
 
429
        from dulwich.index import commit_index
 
430
        import time
 
431
        index = self.open_index()
 
432
        c = Commit()
 
433
        if tree is None:
 
434
            c.tree = commit_index(self.object_store, index)
 
435
        else:
 
436
            c.tree = tree
 
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:
 
442
            commit_timezone = 0
 
443
        c.commit_timezone = commit_timezone
 
444
        if author is None:
 
445
            author = committer
 
446
        c.author = author
 
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
 
453
        c.message = message
 
454
        self.object_store.add_object(c)
 
455
        self.refs["HEAD"] = c.id
 
456
        return c.id
 
457
 
399
458
    @classmethod
400
459
    def init(cls, path, mkdir=True):
401
460
        controldir = os.path.join(path, ".git")