Rev 99: Update rebase to 1.6b3 API changes. in http://people.ubuntu.com/~robertc/baz2.0/plugins/rebase/dev
Robert Collins
robertc at robertcollins.net
Fri Jul 18 18:18:15 BST 2008
At http://people.ubuntu.com/~robertc/baz2.0/plugins/rebase/dev
------------------------------------------------------------
revno: 99
revision-id: robertc at robertcollins.net-20080718171813-wvgbhtgf1rwngtmn
parent: robertc at robertcollins.net-20080718114356-lx2ymkdra6ie6a3s
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dev
timestamp: Sat 2008-07-19 03:18:13 +1000
message:
Update rebase to 1.6b3 API changes.
modified:
rebase.py rebase.py-20070626221123-ellanmf93nw8z9r1-1
test_blackbox.py test_blackbox.py-20070709202607-dyvt95dfu09tuv6a-1
test_maptree.py test_maptree.py-20070709163406-wv3n8o12iygpxf4l-1
test_rebase.py test_rebase.py-20070626221123-ellanmf93nw8z9r1-2
=== modified file 'rebase.py'
--- a/rebase.py 2008-06-23 02:04:00 +0000
+++ b/rebase.py 2008-07-18 17:18:13 +0000
@@ -40,7 +40,7 @@
:return: boolean
"""
try:
- return wt._control_files.get(REBASE_PLAN_FILENAME).read() != ''
+ return wt._transport.get_bytes(REBASE_PLAN_FILENAME) != ''
except NoSuchFile:
return False
@@ -51,7 +51,7 @@
:param wt: Working Tree for which to write the plan.
:return: Tuple with last revision info and replace map.
"""
- text = wt._control_files.get(REBASE_PLAN_FILENAME).read()
+ text = wt._transport.get_bytes(REBASE_PLAN_FILENAME)
if text == '':
raise NoSuchFile(REBASE_PLAN_FILENAME)
return unmarshall_rebase_plan(text)
@@ -63,8 +63,9 @@
:param wt: Working Tree for which to write the plan.
:param replace_map: Replace map (old revid -> (new revid, new parents))
"""
- wt._control_files.put_utf8(REBASE_PLAN_FILENAME,
- marshall_rebase_plan(wt.branch.last_revision_info(), replace_map))
+ content = marshall_rebase_plan(wt.branch.last_revision_info(), replace_map)
+ assert type(content) == str
+ wt._transport.put_bytes(REBASE_PLAN_FILENAME, content)
def remove_rebase_plan(wt):
@@ -72,7 +73,7 @@
:param wt: Working Tree for which to remove the plan.
"""
- wt._control_files.put_utf8(REBASE_PLAN_FILENAME, '')
+ wt._transport.put_bytes(REBASE_PLAN_FILENAME, '')
def marshall_rebase_plan(last_rev_info, replace_map):
@@ -351,8 +352,8 @@
if fix_revid is not None:
ie.revision = fix_revid(ie.revision)
if ie.revision == oldrevid:
- if repository.weave_store.get_weave_or_empty(ie.file_id,
- repository.get_transaction()).has_version(newrevid):
+ key = (ie.file_id, newrevid)
+ if repository.texts.get_parent_map([key]):
ie.revision = newrevid
else:
ie.revision = None
@@ -363,7 +364,9 @@
ie.revision = revid_renames[ie.revision]
# make sure at least one of the new parents contains
# the ie.file_id, ie.revision combination
- if len(filter(lambda inv: ie.file_id in inv and inv[ie.file_id].revision == ie.revision, parent_invs)) == 0:
+ if (len(filter(lambda inv: ie.file_id in inv and
+ inv[ie.file_id].revision == ie.revision, parent_invs))
+ == 0):
raise ReplayParentsInconsistent(ie.file_id, ie.revision)
i += 1
builder.record_entry_contents(ie, parent_invs, path, oldtree,
@@ -452,10 +455,10 @@
write_active_rebase_revid(wt, oldrevid)
merger = Merger(wt.branch, this_tree=wt)
merger.set_other_revision(oldrevid, wt.branch)
- base_revid = replay_determine_base(repository.get_graph(),
+ base_revid = replay_determine_base(repository.get_graph(),
oldrevid, oldrev.parent_ids,
newrevid, newparents)
- mutter('replaying %r as %r with base %r and new parents %r' %
+ mutter('replaying %r as %r with base %r and new parents %r' %
(oldrevid, newrevid, base_revid, newparents))
merger.set_base_revision(base_revid, wt.branch)
merger.merge_type = merge_type
@@ -486,7 +489,8 @@
"""
if revid is None:
revid = NULL_REVISION
- wt._control_files.put_utf8(REBASE_CURRENT_REVID_FILENAME, revid)
+ assert type(revid) == str
+ wt._transport.put_bytes(REBASE_CURRENT_REVID_FILENAME, revid)
def read_active_rebase_revid(wt):
@@ -496,7 +500,7 @@
:return: Id of the revision that is being rebased.
"""
try:
- text = wt._control_files.get(REBASE_CURRENT_REVID_FILENAME).read().rstrip("\n")
+ text = wt._transport.get_bytes(REBASE_CURRENT_REVID_FILENAME).rstrip("\n")
if text == NULL_REVISION:
return None
return text
=== modified file 'test_blackbox.py'
--- a/test_blackbox.py 2008-06-11 17:35:50 +0000
+++ b/test_blackbox.py 2008-07-18 17:18:13 +0000
@@ -60,18 +60,20 @@
self.run_bzr_error(['bzr: ERROR: No pending merges present.\n'], 'rebase --pending-merges')
def test_pending_merges(self):
- os.chdir('../main')
- self.make_file('hello', '42')
- self.run_bzr('add')
- self.run_bzr('commit -m that')
- os.chdir('../feature')
- self.make_file('hoi', "my data")
- self.run_bzr('add')
- self.run_bzr('commit -m this')
- self.check_output('', 'merge ../main')
- self.check_output(' M hello\nAll changes applied successfully.\n',
- 'rebase --pending-merges')
- self.check_output('3\n', 'revno')
+ os.chdir('..')
+ self.build_tree_contents([('main/hello', '42')])
+ self.run_bzr('add', working_dir='main')
+ self.run_bzr('commit -m that main')
+ self.build_tree_contents([('feature/hoi', 'my data')])
+ self.run_bzr('add', working_dir='feature')
+ self.run_bzr('commit -m this feature')
+ self.assertEqual(('', ' M hello\nAll changes applied successfully.\n'),
+ self.run_bzr('merge ../main', working_dir='feature'))
+ out, err = self.run_bzr('rebase --pending-merges', working_dir='feature')
+ self.assertEqual('', out)
+ self.assertContainsRe(err, 'modified hello')
+ self.assertEqual(('3\n', ''),
+ self.run_bzr('revno', working_dir='feature'))
def test_simple_success(self):
self.make_file('hello', '42')
=== modified file 'test_maptree.py'
--- a/test_maptree.py 2008-05-11 18:52:36 +0000
+++ b/test_maptree.py 2008-07-18 17:18:13 +0000
@@ -56,6 +56,7 @@
def test_path2id(self):
self.oldtree.lock_write()
+ self.addCleanup(self.oldtree.unlock)
builder = TreeBuilder()
builder.start_tree(self.oldtree)
builder.build(['foo'])
@@ -68,6 +69,7 @@
def test_id2path(self):
self.oldtree.lock_write()
+ self.addCleanup(self.oldtree.unlock)
builder = TreeBuilder()
builder.start_tree(self.oldtree)
builder.build(['foo'])
@@ -81,6 +83,7 @@
def test_has_id(self):
self.oldtree.lock_write()
+ self.addCleanup(self.oldtree.unlock)
builder = TreeBuilder()
builder.start_tree(self.oldtree)
builder.build(['foo'])
@@ -94,5 +97,6 @@
class MapFileIdTests(TestCase):
+
def test_empty(self):
self.assertEquals({}, map_file_ids(None, [], []))
=== modified file 'test_rebase.py'
--- a/test_rebase.py 2008-06-23 02:04:00 +0000
+++ b/test_rebase.py 2008-07-18 17:18:13 +0000
@@ -246,17 +246,17 @@
def test_rebase_plan_exists_empty(self):
wt = self.make_branch_and_tree('.')
- wt._control_files.put_utf8(REBASE_PLAN_FILENAME, "")
+ wt._transport.put_bytes(REBASE_PLAN_FILENAME, "")
self.assertFalse(rebase_plan_exists(wt))
def test_rebase_plan_exists(self):
wt = self.make_branch_and_tree('.')
- wt._control_files.put_utf8(REBASE_PLAN_FILENAME, "foo")
+ wt._transport.put_bytes(REBASE_PLAN_FILENAME, "foo")
self.assertTrue(rebase_plan_exists(wt))
def test_remove_rebase_plan(self):
wt = self.make_branch_and_tree('.')
- wt._control_files.put_utf8(REBASE_PLAN_FILENAME, "foo")
+ wt._transport.put_bytes(REBASE_PLAN_FILENAME, "foo")
remove_rebase_plan(wt)
self.assertFalse(rebase_plan_exists(wt))
@@ -275,7 +275,7 @@
self.assertEqualDiff("""# Bazaar rebase plan 1
1 bla
oldrev newrev newparent1 newparent2
-""", wt._control_files.get(REBASE_PLAN_FILENAME).read())
+""", wt._transport.get_bytes(REBASE_PLAN_FILENAME))
def test_read_rebase_plan_nonexistant(self):
wt = self.make_branch_and_tree('.')
@@ -283,12 +283,12 @@
def test_read_rebase_plan_empty(self):
wt = self.make_branch_and_tree('.')
- wt._control_files.put_utf8(REBASE_PLAN_FILENAME, "")
+ wt._transport.put_bytes(REBASE_PLAN_FILENAME, "")
self.assertRaises(NoSuchFile, read_rebase_plan, wt)
def test_read_rebase_plan(self):
wt = self.make_branch_and_tree('.')
- wt._control_files.put_utf8(REBASE_PLAN_FILENAME, """# Bazaar rebase plan 1
+ wt._transport.put_bytes(REBASE_PLAN_FILENAME, """# Bazaar rebase plan 1
1 bla
oldrev newrev newparent1 newparent2
""")
@@ -304,12 +304,12 @@
def test_read_null(self):
wt = self.make_branch_and_tree('.')
- wt._control_files.put_utf8(REBASE_CURRENT_REVID_FILENAME, NULL_REVISION)
+ wt._transport.put_bytes(REBASE_CURRENT_REVID_FILENAME, NULL_REVISION)
self.assertIs(None, read_active_rebase_revid(wt))
def test_read(self):
wt = self.make_branch_and_tree('.')
- wt._control_files.put_utf8(REBASE_CURRENT_REVID_FILENAME, "bla")
+ wt._transport.put_bytes(REBASE_CURRENT_REVID_FILENAME, "bla")
self.assertEquals("bla", read_active_rebase_revid(wt))
def test_write(self):
@@ -543,20 +543,36 @@
self.assertEquals(oldrev.timezone, newrev.timezone)
def test_multiple(self):
+ # rebase from
+ # base: []
+ # oldparent: [base]
+ # newparent: [base]
+ # oldcommit: [oldparent, ghost]
+ # create newcommit by rebasing oldcommit from oldparent to newparent,
+ # keeping the merge of ghost.
+ # Common base:
wt = self.make_branch_and_tree("old")
wt.commit("base", rev_id="base")
- self.build_tree(['old/afile'])
+ # oldparent:
+ self.build_tree_contents([('old/afile', 'base content')])
wt.add(["afile"], ids=["originalid"])
wt.commit("bla", rev_id="oldparent")
+ # oldcommit (the delta getting rebased)
+ # - change the content of afile to be 'bloe'
file("old/afile", "w").write("bloe")
wt.add_pending_merge("ghost")
wt.commit("bla", rev_id="oldcommit")
- wt = wt.bzrdir.sprout("new").open_workingtree()
- self.build_tree(['new/bfile'])
- wt.add(["bfile"], ids=["newid"])
+ # newparent (the new base for the rebased commit)
+ new_tree = wt.bzrdir.sprout("new",
+ revision_id='base').open_workingtree()
+ new_tree.branch.repository.fetch(wt.branch.repository)
+ wt = new_tree
+ self.build_tree_contents([('new/afile', 'base content')])
+ wt.add(["afile"], ids=["originalid"])
wt.commit("bla", rev_id="newparent")
+ # And do it!
wt.lock_write()
- replay_delta_workingtree(wt, "oldcommit", "newcommit",
+ replay_delta_workingtree(wt, "oldcommit", "newcommit",
("newparent", "ghost"))
wt.unlock()
oldrev = wt.branch.repository.get_revision("oldcommit")
More information about the bazaar-commits
mailing list