Rev 3: Use subdir to figure out what working tree to open in http://bzr.arbash-meinel.com/plugins/merge_into
John Arbash Meinel
john at arbash-meinel.com
Thu Feb 1 23:20:57 GMT 2007
At http://bzr.arbash-meinel.com/plugins/merge_into
------------------------------------------------------------
revno: 3
revision-id: john at arbash-meinel.com-20070201232050-v1z4iq6f6zk6p5yp
parent: john at arbash-meinel.com-20070201223334-muoke3e8j6w2urlv
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: merge_into
timestamp: Thu 2007-02-01 17:20:50 -0600
message:
Use subdir to figure out what working tree to open
modified:
merge_into.py merge_into.py-20070131214328-dide73mgytkt6kk2-1
test_bb_merge_into.py test_bb_merge_into.p-20070131214328-dide73mgytkt6kk2-2
-------------- next part --------------
=== modified file 'merge_into.py'
--- a/merge_into.py 2007-02-01 22:29:20 +0000
+++ b/merge_into.py 2007-02-01 23:20:50 +0000
@@ -148,9 +148,10 @@
def __getattr__(self, name):
return getattr(self._merge_type, name)
+
def merge_into_helper(location, subdir):
"""Handle the command line functionality, etc."""
- wt, relpath = workingtree.WorkingTree.open_containing('.')
+ wt, relpath = workingtree.WorkingTree.open_containing(subdir)
branch_to_merge = branch.Branch.open(location)
revision_to_merge = branch_to_merge.last_revision()
@@ -159,7 +160,7 @@
merger = MergeIntoMerger(this_tree=wt,
other_tree=target_tree,
other_branch=branch_to_merge,
- target_subdir=subdir,
+ target_subdir=relpath,
)
conflicts = merger.do_merge()
merger.set_pending()
=== modified file 'test_bb_merge_into.py'
--- a/test_bb_merge_into.py 2007-02-01 22:33:34 +0000
+++ b/test_bb_merge_into.py 2007-02-01 23:20:50 +0000
@@ -139,3 +139,33 @@
self.assertEqual(exp_files, files)
finally:
project_wt.unlock()
+
+ def test_merge_into_inside_subdir(self):
+ """You shouldn't need to be at the root for it to work correctly."""
+ project_wt, lib_wt = self.setup_two_branches()
+ self.run_bzr('merge-into', '../../lib1', 'lib1',
+ working_dir='project/dir')
+
+ # This shouldn't be necessary, but it seems required to get the
+ # inventory reloaded
+ project_wt.read_working_inventory()
+ project_wt.lock_read()
+ try:
+ # The lib-1 revision should be merged into this one
+ self.assertEqual(['project-1', 'lib-1'],
+ project_wt.get_parent_ids())
+ files = [(path, status, kind, file_id)
+ for path, status, kind, file_id, ie
+ in project_wt.list_files(include_root=True)]
+ exp_files = [('', 'V', 'directory', 'project-root-id'),
+ ('README', 'V', 'file', 'readme-id'),
+ ('dir', 'V', 'directory', 'dir-id'),
+ ('dir/file.c', 'V', 'file', 'file.c-id'),
+ ('dir/lib1', 'V', 'directory', 'lib1-root-id'),
+ ('dir/lib1/Makefile', 'V', 'file', 'makefile-lib-id'),
+ ('dir/lib1/README', 'V', 'file', 'readme-lib-id'),
+ ('dir/lib1/foo.c', 'V', 'file', 'foo.c-lib-id'),
+ ]
+ self.assertEqual(exp_files, files)
+ finally:
+ project_wt.unlock()
More information about the bazaar-commits
mailing list