Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master-1, master-0, and 0.9.4

Merge support for ref argument to do_commit, with some tweaks.

Changeset 60ed7858ca6d

Parents ac2521f5fe40

Parents 03c0b858c475

by Jelmer Vernooij

Changes to 3 files · Browse files at 60ed7858ca6d Showing diff from parent ac2521f5fe40 03c0b858c475 Diff from another changeset...

Change 1 of 1 Show Entire File NEWS Stacked
 
1
 
 
 
 
2
3
4
 
1
2
3
4
5
6
7
8
@@ -1,4 +1,8 @@
 0.8.1 UNRELEASED + + FEATURES + + * Repo.do_commit has a new argument 'ref'.    0.8.0 2011-08-07  
Change 1 of 3 Show Entire File dulwich/​repo.py Stacked
 
1004
1005
1006
1007
 
 
1008
1009
1010
 
1018
1019
1020
 
1021
1022
1023
 
1053
1054
1055
1056
 
1057
1058
1059
 
1060
1061
1062
1063
 
1064
1065
1066
1067
 
1068
1069
1070
 
1004
1005
1006
 
1007
1008
1009
1010
1011
 
1019
1020
1021
1022
1023
1024
1025
 
1055
1056
1057
 
1058
1059
1060
 
1061
1062
1063
1064
 
1065
1066
1067
1068
 
1069
1070
1071
1072
@@ -1004,7 +1004,8 @@
  def do_commit(self, message, committer=None,   author=None, commit_timestamp=None,   commit_timezone=None, author_timestamp=None, - author_timezone=None, tree=None, encoding=None): + author_timezone=None, tree=None, encoding=None, + ref='HEAD'):   """Create a new commit.     :param message: Commit message @@ -1018,6 +1019,7 @@
  :param tree: SHA1 of the tree root to use (if not specified the   current index will be committed).   :param encoding: Encoding + :param ref: Ref to commit to   :return: New commit SHA1   """   import time @@ -1053,18 +1055,18 @@
  c.encoding = encoding   c.message = message   try: - old_head = self.refs["HEAD"] + old_head = self.refs[ref]   c.parents = [old_head]   self.object_store.add_object(c) - ok = self.refs.set_if_equals("HEAD", old_head, c.id) + ok = self.refs.set_if_equals(ref, old_head, c.id)   except KeyError:   c.parents = []   self.object_store.add_object(c) - ok = self.refs.add_if_new("HEAD", c.id) + ok = self.refs.add_if_new(ref, c.id)   if not ok:   # Fail if the atomic compare-and-swap failed, leaving the commit and   # all its objects as garbage. - raise CommitError("HEAD changed during commit") + raise CommitError("%s changed during commit" % (ref,))     return c.id  
 
445
446
447
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
449
450
 
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
@@ -445,6 +445,32 @@
  self.assertEqual(r[self._root_commit].tree, new_commit.tree)   self.assertEqual('failed commit', new_commit.message)   + def test_commit_branch(self): + r = self._repo + + commit_sha = r.do_commit('commit to branch', + committer='Test Committer <test@nodomain.com>', + author='Test Author <test@nodomain.com>', + commit_timestamp=12395, commit_timezone=0, + author_timestamp=12395, author_timezone=0, + ref="refs/heads/new_branch") + self.assertEqual(self._root_commit, r["HEAD"].id) + self.assertEqual(commit_sha, r["refs/heads/new_branch"].id) + self.assertEqual([], r[commit_sha].parents) + self.assertTrue("refs/heads/new_branch" in r) + + new_branch_head = commit_sha + + commit_sha = r.do_commit('commit to branch 2', + committer='Test Committer <test@nodomain.com>', + author='Test Author <test@nodomain.com>', + commit_timestamp=12395, commit_timezone=0, + author_timestamp=12395, author_timezone=0, + ref="refs/heads/new_branch") + self.assertEqual(self._root_commit, r["HEAD"].id) + self.assertEqual(commit_sha, r["refs/heads/new_branch"].id) + self.assertEqual([new_branch_head], r[commit_sha].parents) +   def test_stage_deleted(self):   r = self._repo   os.remove(os.path.join(r.path, 'a'))