Rev 121: Change from using nick=thread to _set_nick(thread) in loom internals and tests. in http://bazaar.launchpad.net/~bzr-loom-devs/bzr-loom/trunk/
Robert Collins
robertc at robertcollins.net
Fri Jul 2 05:27:23 BST 2010
At http://bazaar.launchpad.net/~bzr-loom-devs/bzr-loom/trunk/
------------------------------------------------------------
revno: 121
revision-id: robertc at robertcollins.net-20100702042717-vmrmbshreukz3091
parent: robertc at robertcollins.net-20100701041808-swb8fvzbh2d1aj74
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Fri 2010-07-02 14:27:17 +1000
message:
Change from using nick=thread to _set_nick(thread) in loom internals and tests.
=== modified file 'HOWTO'
--- a/HOWTO 2010-07-01 04:18:08 +0000
+++ b/HOWTO 2010-07-02 04:27:17 +0000
@@ -47,6 +47,10 @@
This will convert your branch to a loom - at this point you will require the
loom plugin to use bzr on it. It will also create a thread called 'upstream'.
+
+The bzr ``nick`` is used to index into the threads in the loom. The current
+thread is the bzr nick for the branch and is recorded in commits as such.
+
If you do 'bzr push' to a new branch now, it will make the remote branch be a
loom as well. If you push to an existing normal bzr branch, then the current
thread of your loom is what will be pushed. You can use this to publish
=== modified file 'branch.py'
--- a/branch.py 2010-06-23 08:42:54 +0000
+++ b/branch.py 2010-07-02 04:27:17 +0000
@@ -52,7 +52,7 @@
loom.lock_write()
try:
loom.new_thread(thread_name, loom.nick)
- loom.nick = thread_name
+ loom._set_nick(thread_name)
finally:
loom.unlock()
@@ -198,14 +198,14 @@
if len(threads) <= current_index:
# removed the end
# take the new end thread
- self.nick = threads[-1][0]
+ self._set_nick(threads[-1][0])
new_rev = threads[-1][1]
if new_rev == EMPTY_REVISION:
new_rev = bzrlib.revision.NULL_REVISION
self.generate_revision_history(new_rev)
return
# non-end thread removed.
- self.nick = threads[current_index][0]
+ self._set_nick(threads[current_index][0])
new_rev = threads[current_index][1]
if new_rev == EMPTY_REVISION:
new_rev = bzrlib.revision.NULL_REVISION
@@ -375,6 +375,15 @@
result.append((name, rev_id))
return result
+ def _loom_get_nick(self):
+ return self._get_nick(local=True)
+
+ def _rename_thread(self, nick):
+ """Rename the current thread to nick."""
+ return self._set_nick(nick)
+
+ nick = property(_loom_get_nick, _rename_thread)
+
@needs_read_lock
def push(self, target, overwrite=False, stop_revision=None,
_override_hook_source_branch=None):
@@ -659,7 +668,7 @@
# and save the state.
self.target._set_last_loom(my_state)
# set the branch nick.
- self.target.nick = threads[-1][0]
+ self.target._set_nick(threads[-1][0])
# and position the branch on the top loom
new_rev = threads[-1][1]
if new_rev == EMPTY_REVISION:
@@ -970,7 +979,7 @@
if parent:
self.target.set_parent(parent)
if threads:
- self.target.nick = threads[-1][0]
+ self.target._set_nick(threads[-1][0])
@needs_write_lock
def pull(self, overwrite=False, stop_revision=None,
=== modified file 'tests/blackbox.py'
--- a/tests/blackbox.py 2010-06-29 07:25:49 +0000
+++ b/tests/blackbox.py 2010-07-02 04:27:17 +0000
@@ -35,7 +35,7 @@
def _add_patch(self, tree, name):
"""Add a patch to a new thread, returning the revid of te commit."""
tree.branch.new_thread(name)
- tree.branch.nick = name
+ tree.branch._set_nick(name)
self.build_tree([name])
tree.add(name)
return tree.commit(name)
@@ -147,11 +147,11 @@
self.assertShowLoom(['vendor'], 'vendor')
tree.branch.new_thread('debian')
self.assertShowLoom(['vendor', 'debian'], 'vendor')
- tree.branch.nick = 'debian'
+ tree.branch._set_nick('debian')
self.assertShowLoom(['vendor', 'debian'], 'debian')
tree.branch.new_thread('patch A', 'vendor')
self.assertShowLoom(['vendor', 'patch A', 'debian'], 'debian')
- tree.branch.nick = 'patch A'
+ tree.branch._set_nick('patch A')
self.assertShowLoom(['vendor', 'patch A', 'debian'], 'patch A')
def test_show_loom_with_location(self):
@@ -292,7 +292,7 @@
"""Adding a new thread is enough to allow recording."""
tree = self.get_vendor_loom()
tree.branch.new_thread('feature')
- tree.branch.nick = 'feature'
+ tree.branch._set_nick('feature')
out, err = self.run_bzr(['record', 'add feature branch.'])
self.assertEqual('Loom recorded.\n', out)
self.assertEqual('', err)
@@ -314,7 +314,7 @@
"""moving down when the revision is unchanged should work."""
tree = self.get_vendor_loom()
tree.branch.new_thread('patch')
- tree.branch.nick = 'patch'
+ tree.branch._set_nick('patch')
rev = tree.last_revision()
out, err = self.run_bzr(['down-thread'])
self.assertEqual('', out)
@@ -325,7 +325,7 @@
def test_down_thread_removes_changes_between_threads(self):
tree = self.get_vendor_loom()
tree.branch.new_thread('patch')
- tree.branch.nick = 'patch'
+ tree.branch._set_nick('patch')
rev = tree.last_revision()
self.build_tree(['afile'])
tree.add('afile')
@@ -347,7 +347,7 @@
"""Do a down thread when the lower patch is not in the r-h of the old."""
tree = self.get_vendor_loom()
tree.branch.new_thread('patch')
- tree.branch.nick = 'vendor'
+ tree.branch._set_nick('vendor')
# do a null change in vendor - a new release.
vendor_release = tree.commit('new vendor release.', allow_pointless=True)
# pop up, then down
@@ -400,7 +400,7 @@
"""Trying to down-thread with changes causes an error."""
tree = self.get_vendor_loom()
tree.branch.new_thread('upper-thread')
- tree.branch.nick = 'upper-thread'
+ tree.branch._set_nick('upper-thread')
self.build_tree(['new-file'])
tree.add('new-file')
out, err = self.run_bzr('down-thread', retcode=3)
@@ -421,7 +421,7 @@
"""moving up when the revision is unchanged should work."""
tree = self.get_vendor_loom()
tree.branch.new_thread('patch')
- tree.branch.nick = 'vendor'
+ tree.branch._set_nick('vendor')
rev = tree.last_revision()
out, err = self.run_bzr(['up-thread'])
self.assertEqual('', out)
@@ -432,7 +432,7 @@
def test_up_thread_manual_preserves_changes(self):
tree = self.get_vendor_loom()
tree.branch.new_thread('patch')
- tree.branch.nick = 'vendor'
+ tree.branch._set_nick('vendor')
patch_rev = tree.last_revision()
# add a change in vendor - a new release.
self.build_tree(['afile'])
@@ -466,7 +466,7 @@
"""Do a change in both the baseline and the next patch up."""
tree = self.get_vendor_loom()
tree.branch.new_thread('patch')
- tree.branch.nick = 'patch'
+ tree.branch._set_nick('patch')
# add a change in patch - a new release.
self.build_tree(['afile'])
tree.add('afile')
@@ -525,7 +525,7 @@
tree.add('afile')
patch_rev = tree.commit('add afile in base')
tree.branch.new_thread('patch')
- tree.branch.nick = 'patch'
+ tree.branch._set_nick('patch')
# make a change to afile in patch.
f = open('afile', 'wb')
try:
@@ -670,7 +670,7 @@
# not in, so we can revert that by name,
tree = self.get_vendor_loom()
tree.branch.new_thread('after-vendor')
- tree.branch.nick = 'after-vendor'
+ tree.branch._set_nick('after-vendor')
tree.commit('after-vendor commit', allow_pointless=True)
tree.branch.record_loom('save loom with vendor and after-vendor')
old_threads = tree.branch.get_loom_state().get_threads()
=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py 2010-06-14 06:59:18 +0000
+++ b/tests/test_branch.py 2010-07-02 04:27:17 +0000
@@ -188,9 +188,9 @@
tree.branch.new_thread('baseline')
tree.branch.new_thread('middlepoint')
tree.branch.new_thread('endpoint')
- tree.branch.nick = 'middlepoint'
+ tree.branch._set_nick('middlepoint')
rev_id2 = tree.commit('middle', allow_pointless=True)
- tree.branch.nick = 'endpoint'
+ tree.branch._set_nick('endpoint')
rev_id3 = tree.commit('end', allow_pointless=True)
tree.branch.new_thread('afterbase', 'baseline')
tree.branch.new_thread('aftermiddle', 'middlepoint')
@@ -213,7 +213,7 @@
tree = self.get_tree_with_one_commit()
tree.branch.new_thread('baseline')
tree.branch.new_thread('tail')
- tree.branch.nick = 'baseline'
+ tree.branch._set_nick('baseline')
first_rev = tree.last_revision()
# lock the tree to prevent unlock triggering implicit record
tree.lock_write()
@@ -234,7 +234,7 @@
def test_clone_empty_loom(self):
source_tree = self.get_tree_with_loom('source')
- source_tree.branch.nick = 'source'
+ source_tree.branch._set_nick('source')
target_tree = source_tree.bzrdir.clone('target').open_workingtree()
self.assertLoomSproutedOk(source_tree, target_tree)
@@ -248,7 +248,7 @@
source_tree = self.get_tree_with_one_commit('source')
source_tree.branch.new_thread('bottom')
source_tree.branch.new_thread('top')
- source_tree.branch.nick = 'top'
+ source_tree.branch._set_nick('top')
source_tree.commit('phwoar', allow_pointless=True)
source_tree.branch.record_loom('commit to loom')
target_tree = source_tree.bzrdir.clone('target').open_workingtree()
@@ -262,7 +262,7 @@
source_tree = self.get_tree_with_one_commit('source')
source_tree.branch.new_thread('bottom')
source_tree.branch.new_thread('top')
- source_tree.branch.nick = 'top'
+ source_tree.branch._set_nick('top')
source_tree.commit('phwoar', allow_pointless=True)
source_tree.branch.record_loom('commit to loom')
LoomTreeDecorator(source_tree).down_thread()
@@ -282,7 +282,7 @@
source_tree = self.get_tree_with_one_commit('source')
source_tree.branch.new_thread('bottom')
source_tree.branch.new_thread('top')
- source_tree.branch.nick = 'top'
+ source_tree.branch._set_nick('top')
source_tree.commit('phwoar', allow_pointless=True)
source_tree.branch.record_loom('commit to loom')
LoomTreeDecorator(source_tree).down_thread()
@@ -336,10 +336,10 @@
source = self.get_tree_with_loom('source')
source.branch.new_thread('bottom')
source.branch.new_thread('top')
- source.branch.nick = 'bottom'
+ source.branch._set_nick('bottom')
source.branch.record_loom('commit to loom')
target = source.bzrdir.sprout('target').open_branch()
- target.nick = 'top'
+ target._set_nick('top')
# put a commit in the bottom and top of this loom
bottom_rev1 = source.commit('commit my arse')
source_loom_tree = LoomTreeDecorator(source)
@@ -375,7 +375,7 @@
source = self.get_tree_with_loom('source')
target = source.bzrdir.sprout('target').open_branch()
source.branch.new_thread('a thread')
- source.branch.nick = 'a thread'
+ source.branch._set_nick('a thread')
# put a commit in the thread for source.
bottom_rev1 = source.commit('commit a thread')
source.branch.record_loom('commit to loom')
@@ -404,7 +404,7 @@
source = self.get_tree_with_loom('source')
target = source.bzrdir.sprout('target').open_branch()
source.branch.new_thread('a thread')
- source.branch.nick = 'a thread'
+ source.branch._set_nick('a thread')
source.branch.record_loom('commit to loom')
target.pull(source.branch)
# check loom threads
@@ -423,10 +423,10 @@
source = self.get_tree_with_loom('source')
source.branch.new_thread('bottom')
source.branch.new_thread('top')
- source.branch.nick = 'bottom'
+ source.branch._set_nick('bottom')
source.branch.record_loom('commit to loom')
target = source.bzrdir.sprout('target').open_branch()
- target.nick = 'top'
+ target._set_nick('top')
# put a commit in the bottom and top of this loom
bottom_rev1 = source.commit('commit bottom')
source_loom_tree = LoomTreeDecorator(source)
@@ -457,7 +457,7 @@
def test_implicit_record(self):
tree = self.get_tree_with_loom('source')
tree.branch.new_thread('bottom')
- tree.branch.nick = 'bottom'
+ tree.branch._set_nick('bottom')
tree.lock_write()
try:
bottom_rev1 = tree.commit('commit my arse')
@@ -478,7 +478,7 @@
self.assertEqual([], tree.branch.loom_parents())
# add a thread and record it.
tree.branch.new_thread('bottom')
- tree.branch.nick = 'bottom'
+ tree.branch._set_nick('bottom')
rev_id = tree.branch.record_loom('Setup test loom.')
# after recording, the parents list should have changed.
self.assertEqual([rev_id], tree.branch.loom_parents())
@@ -489,7 +489,7 @@
# new threads
tree.branch.new_thread('foo')
tree.branch.new_thread('bar')
- tree.branch.nick = 'bar'
+ tree.branch._set_nick('bar')
last_rev = tree.branch.last_revision()
# and a change to the revision history of this thread
tree.commit('change bar', allow_pointless=True)
@@ -503,7 +503,7 @@
# new threads
tree.branch.new_thread('foo')
tree.branch.new_thread('bar')
- tree.branch.nick = 'bar'
+ tree.branch._set_nick('bar')
# and a change to the revision history of this thread
tree.commit('change bar', allow_pointless=True)
# now record
@@ -528,7 +528,7 @@
# new threads
tree.branch.new_thread('base')
tree.branch.new_thread('top')
- tree.branch.nick = 'top'
+ tree.branch._set_nick('top')
# and a change to the revision history of this thread
tree.tree.commit('change top', allow_pointless=True)
last_rev = tree.branch.last_revision()
@@ -552,7 +552,7 @@
tree.branch.new_thread('foo')
tree.branch.new_thread('bar')
# do a commit, so the last_revision should change.
- tree.branch.nick = 'bar'
+ tree.branch._set_nick('bar')
tree.commit('bar-ness', allow_pointless=True)
tree.branch.revert_thread('bar')
self.assertEqual(
@@ -565,11 +565,11 @@
# ensure we have some stuff to revert
tree.branch.new_thread('foo')
tree.branch.new_thread('bar')
- tree.branch.nick = 'foo'
+ tree.branch._set_nick('foo')
# record the loom to put the threads in the basis
tree.branch.record_loom('record it!')
# do a commit, so the last_revision should change.
- tree.branch.nick = 'bar'
+ tree.branch._set_nick('bar')
tree.commit('bar-ness', allow_pointless=True)
tree.branch.revert_thread('bar')
self.assertEqual(
@@ -583,7 +583,7 @@
tree = self.get_tree_with_loom()
tree.branch.new_thread('bar')
tree.branch.new_thread('foo')
- tree.branch.nick = 'bar'
+ tree.branch._set_nick('bar')
tree.branch.remove_thread('foo')
state = tree.branch.get_loom_state()
self.assertEqual([('bar', 'empty:', [])], state.get_threads())
@@ -594,17 +594,17 @@
self.assertEqual([], tree.branch.get_threads(NULL_REVISION))
# and loom history should make no difference:
tree.branch.new_thread('foo')
- tree.branch.nick = 'foo'
+ tree.branch._set_nick('foo')
tree.branch.record_loom('foo')
self.assertEqual([], tree.branch.get_threads(NULL_REVISION))
def get_multi_threaded(self):
tree = self.get_tree_with_loom()
tree.branch.new_thread('thread1')
- tree.branch.nick = 'thread1'
+ tree.branch._set_nick('thread1')
tree.commit('thread1', rev_id='thread1-id')
tree.branch.new_thread('thread2', 'thread1')
- tree.branch.nick = 'thread2'
+ tree.branch._set_nick('thread2')
tree.commit('thread2', rev_id='thread2-id')
return tree
=== modified file 'tests/test_revspec.py'
--- a/tests/test_revspec.py 2010-07-01 04:18:08 +0000
+++ b/tests/test_revspec.py 2010-07-02 04:27:17 +0000
@@ -32,7 +32,7 @@
tree = self.get_tree_with_loom('source')
tree.branch.new_thread('bottom')
tree.branch.new_thread('top')
- tree.branch.nick = 'bottom'
+ tree.branch._set_nick('bottom')
rev_id_bottom = tree.commit('change bottom')
loom_tree = bzrlib.plugins.loom.tree.LoomTreeDecorator(tree)
loom_tree.up_thread()
=== modified file 'tests/test_tree.py'
--- a/tests/test_tree.py 2010-06-16 03:37:23 +0000
+++ b/tests/test_tree.py 2010-07-02 04:27:17 +0000
@@ -38,14 +38,14 @@
tree = self.get_tree_with_loom('source')
tree.branch.new_thread('bottom')
tree.branch.new_thread('top')
- tree.branch.nick = 'bottom'
+ tree.branch._set_nick('bottom')
return bzrlib.plugins.loom.tree.LoomTreeDecorator(tree)
def test_down_thread(self):
tree = self.get_tree_with_loom('source')
tree.branch.new_thread('bottom')
tree.branch.new_thread('top')
- tree.branch.nick = 'top'
+ tree.branch._set_nick('top')
loom_tree = bzrlib.plugins.loom.tree.LoomTreeDecorator(tree)
loom_tree.down_thread()
self.assertEqual('bottom', tree.branch.nick)
@@ -53,7 +53,7 @@
def _add_thread(self, tree, name):
"""Create a new thread with a commit and return the commit id."""
tree.branch.new_thread(name)
- tree.branch.nick = name
+ tree.branch._set_nick(name)
return tree.commit(name)
def test_down_named_thread(self):
@@ -78,7 +78,7 @@
tree = self.get_tree_with_loom('tree')
tree.branch.new_thread('bottom')
tree.branch.new_thread('top')
- tree.branch.nick = 'bottom'
+ tree.branch._set_nick('bottom')
bottom_rev1 = tree.commit('bottom_commit')
tree_loom_tree = bzrlib.plugins.loom.tree.LoomTreeDecorator(tree)
tree_loom_tree.up_thread()
@@ -89,10 +89,10 @@
"""up-thread into a thread that already has this thread is a no-op."""
tree = self.get_tree_with_loom('tree')
tree.branch.new_thread('bottom')
- tree.branch.nick = 'bottom'
+ tree.branch._set_nick('bottom')
bottom_rev1 = tree.commit('bottom_commit')
tree.branch.new_thread('top', 'bottom')
- tree.branch.nick = 'top'
+ tree.branch._set_nick('top')
top_rev1 = tree.commit('top_commit', allow_pointless=True)
tree_loom_tree = bzrlib.plugins.loom.tree.LoomTreeDecorator(tree)
tree_loom_tree.down_thread()
@@ -108,10 +108,10 @@
"""up-thread from a thread with new work."""
tree = self.get_tree_with_loom('tree')
tree.branch.new_thread('bottom')
- tree.branch.nick = 'bottom'
+ tree.branch._set_nick('bottom')
bottom_rev1 = tree.commit('bottom_commit')
tree.branch.new_thread('top', 'bottom')
- tree.branch.nick = 'top'
+ tree.branch._set_nick('top')
top_rev1 = tree.commit('top_commit', allow_pointless=True)
tree_loom_tree = bzrlib.plugins.loom.tree.LoomTreeDecorator(tree)
tree_loom_tree.down_thread()
@@ -153,7 +153,7 @@
tree.branch.new_thread('bottom')
tree.branch.new_thread('middle')
tree.branch.new_thread('top')
- tree.branch.nick = 'bottom'
+ tree.branch._set_nick('bottom')
return bzrlib.plugins.loom.tree.LoomTreeDecorator(tree)
def test_up_many(self):
@@ -212,7 +212,7 @@
# ensure we have some stuff to revert
tree.branch.new_thread('foo')
tree.branch.new_thread('bar')
- tree.branch.nick = 'bar'
+ tree.branch._set_nick('bar')
tree.commit('change something', allow_pointless=True)
loom_tree = bzrlib.plugins.loom.tree.LoomTreeDecorator(tree)
loom_tree.revert_loom()
@@ -227,7 +227,7 @@
# ensure we have some stuff to revert
tree.branch.new_thread('foo')
tree.branch.new_thread('bar')
- tree.branch.nick = 'bar'
+ tree.branch._set_nick('bar')
tree.commit('change something', allow_pointless=True)
loom_tree = bzrlib.plugins.loom.tree.LoomTreeDecorator(tree)
loom_tree.revert_loom(thread='bar')
@@ -244,7 +244,7 @@
# ensure we have some stuff to revert
tree.branch.new_thread('foo')
tree.branch.new_thread('bar')
- tree.branch.nick = 'bar'
+ tree.branch._set_nick('bar')
tree.commit('change something', allow_pointless=True)
loom_tree = bzrlib.plugins.loom.tree.LoomTreeDecorator(tree)
loom_tree.revert_loom(thread='foo')
=== modified file 'tree.py'
--- a/tree.py 2010-06-16 03:37:23 +0000
+++ b/tree.py 2010-07-02 04:27:17 +0000
@@ -81,7 +81,7 @@
graph = self.tree.branch.repository.get_graph()
# special case no-change condition.
if new_thread_rev == old_thread_rev:
- self.tree.branch.nick = new_thread_name
+ self.tree.branch._set_nick(new_thread_name)
return 0
if new_thread_rev == EMPTY_REVISION:
new_thread_rev = bzrlib.revision.NULL_REVISION
@@ -125,7 +125,7 @@
# change the branch
self.tree.branch.generate_revision_history(new_thread_rev)
# update the branch nick.
- self.tree.branch.nick = new_thread_name
+ self.tree.branch._set_nick(new_thread_name)
trace.note("Moved to thread '%s'." % new_thread_name)
if (basis_tree is not None and
not result and not
@@ -183,7 +183,7 @@
index = state.thread_index(name)
new_thread_rev = threads[index][1]
assert new_thread_rev is not None
- self.tree.branch.nick = new_thread_name
+ self.tree.branch._set_nick(new_thread_name)
if new_thread_rev == old_thread_rev:
# fast path no-op changes
bzrlib.trace.note("Moved to thread '%s'." % new_thread_name)
More information about the bazaar-commits
mailing list