Merge lp:~gz/bzr/resolve_dir_removal_auto_344013 into lp:bzr

Proposed by Martin Packman
Status: Needs review
Proposed branch: lp:~gz/bzr/resolve_dir_removal_auto_344013
Merge into: lp:bzr
Prerequisite: lp:~gz/bzr/resolve_auto_refactor
Diff against target: 147 lines (+69/-7)
2 files modified
bzrlib/conflicts.py (+25/-0)
bzrlib/tests/test_conflicts.py (+44/-7)
To merge this branch: bzr merge lp:~gz/bzr/resolve_dir_removal_auto_344013
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+117104@code.launchpad.net

Description of the change

Make automatic resolving treat conflicts involving deleted directories as resolved if the directory has been subsequently deleted.

There are two ways a user might do this:

* bzr rm dir
 - In which case resolve can just remove the conflict. Bug 138803 wants rm to check for an clean up conflicts, that is not implemented here.

* rm -rf dir
 - In which case I think having `bzr st` report missing files after resolve would be confusing, so the tree inventory needs updating.

When the desired outcome is that the directory should be kept, using --done is still needed.

To post a comment you must log in.

Unmerged revisions

6546. By Martin Packman

Resolve directory deletion conflicts if the dir has been removed

6545. By Martin Packman

Deprecate WorkingTree.auto_resolve

6544. By Martin Packman

Refactor auto_resolve tree method into auto action on conflicts

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/conflicts.py'
2--- bzrlib/conflicts.py 2012-07-27 17:36:19 +0000
3+++ bzrlib/conflicts.py 2012-07-27 17:36:19 +0000
4@@ -705,6 +705,19 @@
5 # Nothing has been generated here
6 return []
7
8+ def _path_unresolved(self, tree):
9+ if tree.has_id(self.file_id):
10+ return True
11+ try:
12+ path = tree.id2path(self.file_id)
13+ except errors.NoSuchId:
14+ pass
15+ else:
16+ # GZ 2012-07-27: Is there not a less heavyweight way of updating
17+ # the inventory to accept the missing files?
18+ tree.remove([path], force=True, keep_files=False)
19+ return False
20+
21
22 class HandledPathConflict(HandledConflict):
23 """A provisionally-resolved path problem involving two paths.
24@@ -804,6 +817,10 @@
25 format = 'Conflict because %(path)s is not versioned, but has versioned'\
26 ' children. %(action)s.'
27
28+ def action_auto(self, tree):
29+ if self._path_unresolved(tree):
30+ raise NotImplementedError("Unversioned parent still exists")
31+
32 # FIXME: We silently do nothing to make tests pass, but most probably the
33 # conflict shouldn't exist (the long story is that the conflict is
34 # generated with another one that can be resolved properly) -- vila 091224
35@@ -825,6 +842,10 @@
36
37 format = 'Conflict adding files to %(path)s. %(action)s.'
38
39+ def action_auto(self, tree):
40+ if self._path_unresolved(tree):
41+ raise NotImplementedError("Missing parent still exists")
42+
43 def action_take_this(self, tree):
44 tree.remove([self.path], force=True, keep_files=False)
45
46@@ -847,6 +868,10 @@
47 # FIXME: It's a bit strange that the default action is not coherent with
48 # MissingParent from the *user* pov.
49
50+ def action_auto(self, tree):
51+ if self._path_unresolved(tree):
52+ raise NotImplementedError("Deleted parent still exists")
53+
54 def action_take_this(self, tree):
55 # just acccept bzr proposal
56 pass
57
58=== modified file 'bzrlib/tests/test_conflicts.py'
59--- bzrlib/tests/test_conflicts.py 2012-02-23 23:41:51 +0000
60+++ bzrlib/tests/test_conflicts.py 2012-07-27 17:36:19 +0000
61@@ -754,10 +754,21 @@
62 2>2 conflicts encountered.
63 """
64
65+ def test_auto_gone(self):
66+ self.run_script("""
67+$ rm -rf dir
68+$ bzr resolve --auto dir
69+2>dir/file does not exist.
70+2>dir does not exist.
71+2>2 conflicts resolved, 0 remaining
72+$ bzr status --no-pending
73+$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
74+""")
75+
76 def test_take_this(self):
77 self.run_script("""
78 $ bzr rm -q dir --force
79-$ bzr resolve dir
80+$ bzr resolve --auto dir
81 2>2 conflicts resolved, 0 remaining
82 $ bzr commit -q --strict -m 'No more conflicts nor unknown files'
83 """)
84@@ -807,15 +818,26 @@
85 self.run_script("""
86 $ bzr mv -q dir/file2 file2
87 $ bzr rm -q dir --force
88-$ bzr resolve dir
89-2>2 conflicts resolved, 0 remaining
90+$ bzr resolve --auto dir
91+2>2 conflicts resolved, 0 remaining
92+$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
93+""")
94+
95+ def test_auto_gone(self):
96+ self.run_script("""
97+$ rm -rf dir
98+$ bzr resolve --auto dir
99+2>dir/file2 does not exist.
100+2>dir does not exist.
101+2>2 conflicts resolved, 0 remaining
102+$ bzr status --no-pending
103 $ bzr commit -q --strict -m 'No more conflicts nor unknown files'
104 """)
105
106 def test_kill_them_all(self):
107 self.run_script("""
108 $ bzr rm -q dir --force
109-$ bzr resolve dir
110+$ bzr resolve --auto dir
111 2>2 conflicts resolved, 0 remaining
112 $ bzr commit -q --strict -m 'No more conflicts nor unknown files'
113 """)
114@@ -871,15 +893,30 @@
115 self.run_script("""
116 $ bzr mv -q dir/file2 file2
117 $ bzr rm -q dir --force
118-$ bzr resolve dir
119-2>2 conflicts resolved, 0 remaining
120+$ bzr resolve --auto dir
121+2>2 conflicts resolved, 0 remaining
122+$ bzr commit -q --strict -m 'No more conflicts nor unknown files'
123+""")
124+
125+ def test_auto_gone(self):
126+ self.run_script("""
127+$ rm -rf dir
128+$ bzr resolve --auto dir
129+2>dir/file2 does not exist.
130+2>dir does not exist.
131+2>2 conflicts resolved, 0 remaining
132+$ bzr status --no-pending
133+removed:
134+ dir/
135+ dir/file
136+ dir/file2
137 $ bzr commit -q --strict -m 'No more conflicts nor unknown files'
138 """)
139
140 def test_kill_them_all(self):
141 self.run_script("""
142 $ bzr rm -q dir --force
143-$ bzr resolve dir
144+$ bzr resolve --auto dir
145 2>2 conflicts resolved, 0 remaining
146 $ bzr commit -q --strict -m 'No more conflicts nor unknown files'
147 """)