Rev 98: Merge compatibility fixes with bzr 1.6. in file:///data/jelmer/bzr-rebase/trunk/
Jelmer Vernooij
jelmer at samba.org
Tue Jul 22 21:57:39 BST 2008
At file:///data/jelmer/bzr-rebase/trunk/
------------------------------------------------------------
revno: 98
revision-id: jelmer at samba.org-20080722205738-v3y5kp2d8s5bo9ct
parent: jelmer at samba.org-20080701022232-8loxbt0ppfxfy19o
parent: robertc at robertcollins.net-20080718171813-wvgbhtgf1rwngtmn
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2008-07-22 22:57:38 +0200
message:
Merge compatibility fixes with bzr 1.6.
modified:
__init__.py __init__.py-20070626215909-fi0s39bkwxn4gcto-1
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
------------------------------------------------------------
revno: 96.2.3
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
------------------------------------------------------------
revno: 96.2.2
revision-id: robertc at robertcollins.net-20080718114356-lx2ymkdra6ie6a3s
parent: robertc at robertcollins.net-20080626081523-jq42aq5zx2hx5daj
parent: jelmer at samba.org-20080701022232-8loxbt0ppfxfy19o
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dev
timestamp: Fri 2008-07-18 21:43:56 +1000
message:
Merge trunk.
modified:
__init__.py __init__.py-20070626215909-fi0s39bkwxn4gcto-1
------------------------------------------------------------
revno: 96.2.1
revision-id: robertc at robertcollins.net-20080626081523-jq42aq5zx2hx5daj
parent: jelmer at samba.org-20080623020428-ra3snuwqos2quw92
committer: Robert Collins <robertc at robertcollins.net>
branch nick: dev
timestamp: Thu 2008-06-26 18:15:23 +1000
message:
Code cleanup - 80 column wrap, no trailing spaces.
modified:
__init__.py __init__.py-20070626215909-fi0s39bkwxn4gcto-1
=== modified file '__init__.py'
--- a/__init__.py 2008-06-20 18:56:34 +0000
+++ b/__init__.py 2008-07-18 11:43:56 +0000
@@ -117,19 +117,20 @@
type=str)]
@display_command
- def run(self, upstream_location=None, onto=None, revision=None,
- merge_type=None, verbose=False, dry_run=False,
+ def run(self, upstream_location=None, onto=None, revision=None,
+ merge_type=None, verbose=False, dry_run=False,
always_rebase_merges=False, pending_merges=False):
from bzrlib.branch import Branch
from bzrlib.revisionspec import RevisionSpec
from bzrlib.workingtree import WorkingTree
- from rebase import (generate_simple_plan, rebase, rebase_plan_exists,
- read_rebase_plan, remove_rebase_plan,
+ from rebase import (generate_simple_plan, rebase, rebase_plan_exists,
+ read_rebase_plan, remove_rebase_plan,
workingtree_replay, write_rebase_plan,
regenerate_default_revid,
rebase_todo)
if revision is not None and pending_merges:
- raise BzrCommandError("--revision and --pending-merges are mutually exclusive")
+ raise BzrCommandError(
+ "--revision and --pending-merges are mutually exclusive")
wt = WorkingTree.open_containing(".")[0]
wt.lock_write()
@@ -147,7 +148,9 @@
try:
# Abort if there already is a plan file
if rebase_plan_exists(wt):
- raise BzrCommandError("A rebase operation was interrupted. Continue using 'bzr rebase-continue' or abort using 'bzr rebase-abort'")
+ raise BzrCommandError("A rebase operation was interrupted. "
+ "Continue using 'bzr rebase-continue' or abort using 'bzr "
+ "rebase-abort'")
start_revid = None
stop_revid = None
@@ -169,7 +172,8 @@
if len(wt_parents) in (0, 1):
raise BzrCommandError("No pending merges present.")
elif len(wt_parents) > 2:
- raise BzrCommandError("Rebasing more than one pending merge not supported")
+ raise BzrCommandError(
+ "Rebasing more than one pending merge not supported")
stop_revid = wt_parents[1]
assert stop_revid is not None, "stop revid invalid"
@@ -184,31 +188,36 @@
wt.branch.repository.fetch(upstream_repository, onto)
if stop_revid is not None:
- revhistory = list(wt.branch.repository.iter_reverse_revision_history(stop_revid))
+ revhistory = list(
+ wt.branch.repository.iter_reverse_revision_history(
+ stop_revid))
revhistory.reverse()
else:
revhistory = wt.branch.revision_history()
if start_revid is None:
- common_revid = find_last_common_revid(revhistory,
+ common_revid = find_last_common_revid(revhistory,
upstream.revision_history())
if common_revid == upstream.last_revision():
self.outf.write("No revisions to rebase.\n")
return
if common_revid == revhistory[-1]:
- self.outf.write("Base branch is descendant of current branch. Use 'bzr pull'.\n")
+ self.outf.write("Base branch is descendant of current "
+ "branch. Use 'bzr pull'.\n")
return
try:
start_revid = revhistory[revhistory.index(common_revid)+1]
except NoSuchRevision:
- raise BzrCommandError("No common revision, please specify --revision")
+ raise BzrCommandError(
+ "No common revision, please specify --revision")
# Create plan
replace_map = generate_simple_plan(
revhistory, start_revid, stop_revid, onto,
wt.branch.repository.get_ancestry(onto),
wt.branch.repository.get_graph(),
- lambda revid: regenerate_default_revid(wt.branch.repository, revid),
+ lambda revid: regenerate_default_revid(wt.branch.repository,
+ revid),
not always_rebase_merges
)
@@ -229,10 +238,12 @@
# Start executing plan
try:
- rebase(wt.branch.repository, replace_map,
+ rebase(wt.branch.repository, replace_map,
workingtree_replay(wt, merge_type=merge_type))
except ConflictsInTree:
- raise BzrCommandError("A conflict occurred replaying a commit. Resolve the conflict and run 'bzr rebase-continue' or run 'bzr rebase-abort'.")
+ raise BzrCommandError("A conflict occurred replaying a "
+ "commit. Resolve the conflict and run "
+ "'bzr rebase-continue' or run 'bzr rebase-abort'.")
# Remove plan file
remove_rebase_plan(wt)
finally:
@@ -270,8 +281,8 @@
@display_command
def run(self, merge_type=None):
- from rebase import (commit_rebase, rebase, rebase_plan_exists,
- read_rebase_plan, read_active_rebase_revid,
+ from rebase import (commit_rebase, rebase, rebase_plan_exists,
+ read_rebase_plan, read_active_rebase_revid,
remove_rebase_plan, workingtree_replay)
from bzrlib.workingtree import WorkingTree
wt = WorkingTree.open_containing('.')[0]
@@ -293,10 +304,12 @@
commit_rebase(wt, oldrev, replace_map[oldrevid][0])
try:
# Start executing plan from current Branch.last_revision()
- rebase(wt.branch.repository, replace_map,
+ rebase(wt.branch.repository, replace_map,
workingtree_replay(wt, merge_type=merge_type))
except ConflictsInTree:
- raise BzrCommandError("A conflict occurred replaying a commit. Resolve the conflict and run 'bzr rebase-continue' or run 'bzr rebase-abort'.")
+ raise BzrCommandError("A conflict occurred replaying a commit."
+ " Resolve the conflict and run 'bzr rebase-continue' or "
+ "run 'bzr rebase-abort'.")
# Remove plan file
remove_rebase_plan(wt)
finally:
@@ -310,7 +323,7 @@
"""
def run(self):
- from rebase import (rebase_todo, read_rebase_plan,
+ from rebase import (rebase_todo, read_rebase_plan,
read_active_rebase_revid)
from bzrlib.workingtree import WorkingTree
wt = WorkingTree.open_containing('.')[0]
@@ -371,15 +384,15 @@
pb.update("replaying commits", todo.index(revid), len(todo))
wt.branch.repository.fetch(from_branch.repository, revid)
newrevid = regenerate_default_revid(wt.branch.repository, revid)
- replay_delta_workingtree(wt, revid, newrevid,
- [wt.last_revision()],
+ replay_delta_workingtree(wt, revid, newrevid,
+ [wt.last_revision()],
merge_type=merge_type)
finally:
pb.finished()
wt.unlock()
-for cmd in [cmd_replay, cmd_rebase, cmd_rebase_abort, cmd_rebase_continue,
+for cmd in [cmd_replay, cmd_rebase, cmd_rebase_abort, cmd_rebase_continue,
cmd_rebase_todo]:
register_command(cmd)
=== 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