moving branch nick recording out of Commit, into WorkingTree
Robert Collins
robertc at robertcollins.net
Mon Jan 9 05:55:46 GMT 2006
It should be possible to record commits with no branch nickname - not an
empty one, a non existent one.
I think the easiest way is to think of recording the nick as policy and
move it up to the WorkingTree commit wrapper. Then tools like baz2bzr
that both have no nickname and no good way to set it can commit without
one by creating a Commit() object directly.
Rob
=== modified file 'bzrlib/commit.py'
--- bzrlib/commit.py
+++ bzrlib/commit.py
-206,8 +206,8 @@
self.rev_id = rev_id
self.specific_files = specific_files
self.allow_pointless = allow_pointless
- self.revprops = {'branch-nick': branch.nick}
- if revprops:
+ self.revprops = {}
+ if revprops is not None:
self.revprops.update(revprops)
self.work_tree = WorkingTree(branch.base, branch)
=== modified file 'bzrlib/workingtree.py'
--- bzrlib/workingtree.py
+++ bzrlib/workingtree.py
-287,9 +287,14 @@
return self.abspath(self.id2path(file_id))
@needs_write_lock
- def commit(self, *args, **kw):
+ def commit(self, message=None, revprops=None, *args, **kw):
+ # avoid circular imports
from bzrlib.commit import Commit
- Commit().commit(self.branch, *args, **kw)
+ if revprops is None:
+ revprops = {}
+ if not 'branch-nick' in revprops:
+ revprops['branch-nick'] = self.branch.nick
+ Commit().commit(self.branch, message=message,
revprops=revprops, *args, **kw)
self._set_inventory(self.read_working_inventory())
def id2abspath(self, file_id):
=== modified file 'bzrlib/tests/test_commit.py'
--- bzrlib/tests/test_commit.py
+++ bzrlib/tests/test_commit.py
-352,3 +352,11 @@
self.assertEqual(['called', 'called'], calls)
finally:
del bzrlib.ahook
+
+ def test_commit_object_doesnt_set_nick(self):
+ # using the Commit object directly does not set the branch
nick.
+ b = Branch.initialize(u'.')
+ c = Commit()
+ c.commit(branch=b, message='empty tree', allow_pointless=True)
+ self.assertEquals(b.revno(), 1)
+ self.assertEqual({},
b.get_revision(b.last_revision()).properties)
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060109/22f409bd/attachment.pgp
More information about the bazaar
mailing list