Merge lp:~jelmer/brz/mv-bug into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/mv-bug
Merge into: lp:brz
Diff against target: 75 lines (+46/-4)
2 files modified
breezy/bzr/workingtree.py (+7/-4)
breezy/tests/blackbox/test_mv.py (+39/-0)
To merge this branch: bzr merge lp:~jelmer/brz/mv-bug
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+359342@code.launchpad.net

Commit message

Fix move when file was in different location, rather than removed.

Description of the change

Fix move when file was in different location, rather than removed.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks!

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/bzr/workingtree.py'
2--- breezy/bzr/workingtree.py 2018-11-22 03:51:03 +0000
3+++ breezy/bzr/workingtree.py 2018-11-23 19:58:12 +0000
4@@ -1257,10 +1257,13 @@
5 raise errors.BzrRenameFailedError(
6 from_rel, to_rel,
7 errors.NotVersionedError(path=from_rel))
8- # put entry back in the inventory so we can rename it
9- from_entry = basis_tree.root_inventory.get_entry(
10- from_id).copy()
11- from_inv.add(from_entry)
12+ try:
13+ from_entry = from_inv.get_entry(from_id)
14+ except errors.NoSuchId:
15+ # put entry back in the inventory so we can rename it
16+ from_entry = basis_tree.root_inventory.get_entry(
17+ from_id).copy()
18+ from_inv.add(from_entry)
19 else:
20 from_inv, from_inv_id = self._unpack_file_id(from_id)
21 from_entry = from_inv.get_entry(from_inv_id)
22
23=== modified file 'breezy/tests/blackbox/test_mv.py'
24--- breezy/tests/blackbox/test_mv.py 2018-11-11 04:08:32 +0000
25+++ breezy/tests/blackbox/test_mv.py 2018-11-23 19:58:12 +0000
26@@ -26,6 +26,7 @@
27
28 from breezy.tests import (
29 TestCaseWithTransport,
30+ script,
31 )
32 from breezy.tests.features import (
33 CaseInsensitiveFilesystemFeature,
34@@ -529,3 +530,41 @@
35 os.remove(u"\xA7")
36 out, err = self.run_bzr_error(["Could not rename", "not exist"],
37 ["mv", u"\xA7", "b"])
38+
39+ def test_dupe_move(self):
40+ self.script_runner = script.ScriptRunner()
41+ self.script_runner.run_script(self, '''
42+ $ brz init brz-bug
43+ Created a standalone tree (format: 2a)
44+ $ cd brz-bug
45+ $ mkdir dir
46+ $ brz add
47+ adding dir
48+ $ echo text >> dir/test.txt
49+ $ brz add
50+ adding dir/test.txt
51+ $ brz ci -m "Add files"
52+ 2>Committing to: .../brz-bug/
53+ 2>added dir
54+ 2>added dir/test.txt
55+ 2>Committed revision 1.
56+ $ mv dir dir2
57+ $ mv dir2/test.txt dir2/test2.txt
58+ $ brz st
59+ removed:
60+ dir/
61+ dir/test.txt
62+ unknown:
63+ dir2/
64+ $ brz mv dir dir2
65+ dir => dir2
66+ $ brz st
67+ removed:
68+ dir/test.txt
69+ renamed:
70+ dir/ => dir2/
71+ unknown:
72+ dir2/test2.txt
73+ $ brz mv dir/test.txt dir2/test2.txt
74+ dir/test.txt => dir2/test2.txt
75+ ''')

Subscribers

People subscribed via source and target branches