bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5557.1.7
by John Arbash Meinel
Merge in the bzr.dev 5582 |
1 |
# Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1185.14.3
by Aaron Bentley
Copied conflict lister in |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
1185.14.3
by Aaron Bentley
Copied conflict lister in |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
1185.14.3
by Aaron Bentley
Copied conflict lister in |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1185.14.3
by Aaron Bentley
Copied conflict lister in |
16 |
|
6622.1.28
by Jelmer Vernooij
More renames; commands in output, environment variables. |
17 |
# TODO: 'brz resolve' should accept a directory name and work from that
|
1185.16.11
by Martin Pool
todo |
18 |
# point down
|
19 |
||
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
20 |
import errno |
1185.16.33
by Martin Pool
- move 'conflict' and 'resolved' from shipped plugin to regular builtins |
21 |
import os |
6543.2.1
by Martin Packman
Refactor auto_resolve tree method into auto action on conflicts |
22 |
import re |
1996.3.33
by John Arbash Meinel
make bzrlib/conflicts.py lazy |
23 |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
24 |
from .lazy_import import lazy_import |
1996.3.33
by John Arbash Meinel
make bzrlib/conflicts.py lazy |
25 |
lazy_import(globals(), """ |
1185.16.33
by Martin Pool
- move 'conflict' and 'resolved' from shipped plugin to regular builtins |
26 |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
27 |
from breezy import (
|
4597.3.24
by Vincent Ladeuil
Fix imports in bzrlib/conflicts.py. |
28 |
workingtree,
|
1996.3.33
by John Arbash Meinel
make bzrlib/conflicts.py lazy |
29 |
)
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
30 |
from breezy.i18n import gettext, ngettext
|
1996.3.33
by John Arbash Meinel
make bzrlib/conflicts.py lazy |
31 |
""") |
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
32 |
from . import ( |
6630.1.1
by Jelmer Vernooij
Remove deprecated functionality. |
33 |
cache_utf8, |
7413.8.11
by Jelmer Vernooij
Don't lazy-import errors. |
34 |
errors, |
5904.1.2
by Martin Pool
Various pyflakes import fixes. |
35 |
commands, |
4597.3.51
by Vincent Ladeuil
Implement conflicts.ResolveActionOption. |
36 |
option, |
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
37 |
osutils, |
4597.3.51
by Vincent Ladeuil
Implement conflicts.ResolveActionOption. |
38 |
registry, |
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
39 |
trace, |
4597.3.51
by Vincent Ladeuil
Implement conflicts.ResolveActionOption. |
40 |
)
|
1534.10.6
by Aaron Bentley
Conflict serialization working for WorkingTree3 |
41 |
|
42 |
||
1996.3.33
by John Arbash Meinel
make bzrlib/conflicts.py lazy |
43 |
class cmd_conflicts(commands.Command): |
5131.2.1
by Martin
Permit bzrlib to run under python -OO by explictly assigning to __doc__ for user-visible docstrings |
44 |
__doc__ = """List files with conflicts. |
1551.2.18
by Aaron Bentley
Updated docs to clarify conflict handling |
45 |
|
46 |
Merge will do its best to combine the changes in two branches, but there
|
|
47 |
are some kinds of problems only a human can fix. When it encounters those,
|
|
48 |
it will mark a conflict. A conflict means that you need to fix something,
|
|
6437.2.2
by Vincent Ladeuil
Release 2.5b5 |
49 |
before you can commit.
|
1551.2.18
by Aaron Bentley
Updated docs to clarify conflict handling |
50 |
|
1551.9.8
by Aaron Bentley
Add --text parameter to conflicts |
51 |
Conflicts normally are listed as short, human-readable messages. If --text
|
52 |
is supplied, the pathnames of files with text conflicts are listed,
|
|
53 |
instead. (This is useful for editing all files with text conflicts.)
|
|
54 |
||
6622.1.28
by Jelmer Vernooij
More renames; commands in output, environment variables. |
55 |
Use brz resolve when you have fixed a problem.
|
1185.14.3
by Aaron Bentley
Copied conflict lister in |
56 |
"""
|
2598.1.1
by Martin Pool
Add test for and documentation of option style, fix up existing options to comply |
57 |
takes_options = [ |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
58 |
'directory', |
59 |
option.Option('text', |
|
60 |
help='List paths of files with text conflicts.'), |
|
2598.1.1
by Martin Pool
Add test for and documentation of option style, fix up existing options to comply |
61 |
]
|
4927.2.1
by Ian Clatworthy
conflicts topic renamed to conflict-types and other minor help clean-ups |
62 |
_see_also = ['resolve', 'conflict-types'] |
1551.9.8
by Aaron Bentley
Add --text parameter to conflicts |
63 |
|
5171.3.13
by Martin von Gagern
Add --directory option to 7 more commands. |
64 |
def run(self, text=False, directory=u'.'): |
65 |
wt = workingtree.WorkingTree.open_containing(directory)[0] |
|
1534.10.24
by Aaron Bentley
Eliminated conflicts_to_strings, made remove_files a ConflictList member |
66 |
for conflict in wt.conflicts(): |
1551.9.8
by Aaron Bentley
Add --text parameter to conflicts |
67 |
if text: |
68 |
if conflict.typestring != 'text conflict': |
|
69 |
continue
|
|
70 |
self.outf.write(conflict.path + '\n') |
|
71 |
else: |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
72 |
self.outf.write(str(conflict) + '\n') |
1185.14.3
by Aaron Bentley
Copied conflict lister in |
73 |
|
1652.1.1
by Martin Pool
Fix 'bzr resolve' run from subdirectory |
74 |
|
4597.3.51
by Vincent Ladeuil
Implement conflicts.ResolveActionOption. |
75 |
resolve_action_registry = registry.Registry() |
76 |
||
77 |
||
78 |
resolve_action_registry.register( |
|
6543.2.1
by Martin Packman
Refactor auto_resolve tree method into auto action on conflicts |
79 |
'auto', 'auto', 'Detect whether conflict has been resolved by user.') |
80 |
resolve_action_registry.register( |
|
6259.2.8
by Martin Packman
Add full stops to various registry help strings |
81 |
'done', 'done', 'Marks the conflict as resolved.') |
4597.3.51
by Vincent Ladeuil
Implement conflicts.ResolveActionOption. |
82 |
resolve_action_registry.register( |
4597.3.67
by Vincent Ladeuil
Settle with --take-this and --take-other as action names. |
83 |
'take-this', 'take_this', |
6259.2.8
by Martin Packman
Add full stops to various registry help strings |
84 |
'Resolve the conflict preserving the version in the working tree.') |
4597.3.51
by Vincent Ladeuil
Implement conflicts.ResolveActionOption. |
85 |
resolve_action_registry.register( |
4597.3.67
by Vincent Ladeuil
Settle with --take-this and --take-other as action names. |
86 |
'take-other', 'take_other', |
6259.2.8
by Martin Packman
Add full stops to various registry help strings |
87 |
'Resolve the conflict taking the merged version into account.') |
4597.3.51
by Vincent Ladeuil
Implement conflicts.ResolveActionOption. |
88 |
resolve_action_registry.default_key = 'done' |
89 |
||
7143.15.2
by Jelmer Vernooij
Run autopep8. |
90 |
|
4597.3.51
by Vincent Ladeuil
Implement conflicts.ResolveActionOption. |
91 |
class ResolveActionOption(option.RegistryOption): |
92 |
||
93 |
def __init__(self): |
|
94 |
super(ResolveActionOption, self).__init__( |
|
95 |
'action', 'How to resolve the conflict.', |
|
96 |
value_switches=True, |
|
97 |
registry=resolve_action_registry) |
|
98 |
||
99 |
||
1996.3.33
by John Arbash Meinel
make bzrlib/conflicts.py lazy |
100 |
class cmd_resolve(commands.Command): |
5131.2.1
by Martin
Permit bzrlib to run under python -OO by explictly assigning to __doc__ for user-visible docstrings |
101 |
__doc__ = """Mark a conflict as resolved. |
1551.2.18
by Aaron Bentley
Updated docs to clarify conflict handling |
102 |
|
103 |
Merge will do its best to combine the changes in two branches, but there
|
|
104 |
are some kinds of problems only a human can fix. When it encounters those,
|
|
105 |
it will mark a conflict. A conflict means that you need to fix something,
|
|
6437.2.2
by Vincent Ladeuil
Release 2.5b5 |
106 |
before you can commit.
|
1551.2.18
by Aaron Bentley
Updated docs to clarify conflict handling |
107 |
|
6622.1.28
by Jelmer Vernooij
More renames; commands in output, environment variables. |
108 |
Once you have fixed a problem, use "brz resolve" to automatically mark
|
109 |
text conflicts as fixed, "brz resolve FILE" to mark a specific conflict as
|
|
110 |
resolved, or "brz resolve --all" to mark all conflicts as resolved.
|
|
1185.14.3
by Aaron Bentley
Copied conflict lister in |
111 |
"""
|
1185.33.24
by Martin Pool
Add alias 'resolved' |
112 |
aliases = ['resolved'] |
1185.14.3
by Aaron Bentley
Copied conflict lister in |
113 |
takes_args = ['file*'] |
2598.1.2
by Martin Pool
Also check that option help ends in a period, and fix those that don't |
114 |
takes_options = [ |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
115 |
'directory', |
116 |
option.Option('all', help='Resolve all conflicts in this tree.'), |
|
117 |
ResolveActionOption(), |
|
118 |
]
|
|
4798.7.1
by Neil Martinsen-Burrell
fix some formatting and see also usage |
119 |
_see_also = ['conflicts'] |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
120 |
|
5321.1.75
by Gordon Tyler
Reverted more command-related stuff and my own idiocy. |
121 |
def run(self, file_list=None, all=False, action=None, directory=None): |
1652.1.3
by Martin Pool
Improved bzr resolve command line handling |
122 |
if all: |
123 |
if file_list: |
|
7490.61.1
by Jelmer Vernooij
Rename BzrCommandError to CommandError. |
124 |
raise errors.CommandError(gettext("If --all is specified," |
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
125 |
" no FILE may be provided")) |
5521.1.1
by Vincent Ladeuil
Handle --directory when paths are also provided to shelve and restore. |
126 |
if directory is None: |
127 |
directory = u'.' |
|
5171.3.13
by Martin von Gagern
Add --directory option to 7 more commands. |
128 |
tree = workingtree.WorkingTree.open_containing(directory)[0] |
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
129 |
if action is None: |
130 |
action = 'done' |
|
1185.14.3
by Aaron Bentley
Copied conflict lister in |
131 |
else: |
5346.4.4
by Martin Pool
Use open_containing_paths |
132 |
tree, file_list = workingtree.WorkingTree.open_containing_paths( |
5521.1.1
by Vincent Ladeuil
Handle --directory when paths are also provided to shelve and restore. |
133 |
file_list, directory) |
6543.2.1
by Martin Packman
Refactor auto_resolve tree method into auto action on conflicts |
134 |
if action is None: |
135 |
if file_list is None: |
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
136 |
action = 'auto' |
6543.2.1
by Martin Packman
Refactor auto_resolve tree method into auto action on conflicts |
137 |
else: |
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
138 |
action = 'done' |
6543.2.1
by Martin Packman
Refactor auto_resolve tree method into auto action on conflicts |
139 |
before, after = resolve(tree, file_list, action=action) |
140 |
# GZ 2012-07-27: Should unify UI below now that auto is less magical.
|
|
141 |
if action == 'auto' and file_list is None: |
|
142 |
if after > 0: |
|
7290.25.1
by Jelmer Vernooij
merge lp:~gz/bzr/resolve_auto_refactor |
143 |
trace.note( |
144 |
ngettext('%d conflict auto-resolved.', |
|
145 |
'%d conflicts auto-resolved.', before - after), |
|
6543.2.1
by Martin Packman
Refactor auto_resolve tree method into auto action on conflicts |
146 |
before - after) |
147 |
trace.note(gettext('Remaining conflicts:')) |
|
148 |
for conflict in tree.conflicts(): |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
149 |
trace.note(str(conflict)) |
6543.2.1
by Martin Packman
Refactor auto_resolve tree method into auto action on conflicts |
150 |
return 1 |
2120.7.3
by Aaron Bentley
Update resolve command to automatically mark conflicts as resolved |
151 |
else: |
6543.2.1
by Martin Packman
Refactor auto_resolve tree method into auto action on conflicts |
152 |
trace.note(gettext('All conflicts resolved.')) |
153 |
return 0 |
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
154 |
else: |
6138.3.4
by Jonathan Riddell
add gettext() to uses of trace.note() |
155 |
trace.note(ngettext('{0} conflict resolved, {1} remaining', |
156 |
'{0} conflicts resolved, {1} remaining', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
157 |
before - after).format(before - after, after)) |
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
158 |
|
159 |
||
160 |
def resolve(tree, paths=None, ignore_misses=False, recursive=False, |
|
161 |
action='done'): |
|
3017.2.2
by Aaron Bentley
Add docstring to resolve |
162 |
"""Resolve some or all of the conflicts in a working tree. |
163 |
||
164 |
:param paths: If None, resolve all conflicts. Otherwise, select only
|
|
165 |
specified conflicts.
|
|
166 |
:param recursive: If True, then elements of paths which are directories
|
|
167 |
have all their children resolved, etc. When invoked as part of
|
|
168 |
recursive commands like revert, this should be True. For commands
|
|
169 |
or applications wishing finer-grained control, like the resolve
|
|
170 |
command, this should be False.
|
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
171 |
:param ignore_misses: If False, warnings will be printed if the supplied
|
172 |
paths do not have conflicts.
|
|
173 |
:param action: How the conflict should be resolved,
|
|
3017.2.2
by Aaron Bentley
Add docstring to resolve |
174 |
"""
|
4597.9.19
by Vincent Ladeuil
resolve now reports conflicts resolved/remaining. |
175 |
nb_conflicts_after = None |
6754.8.9
by Jelmer Vernooij
Fix more tests. |
176 |
with tree.lock_tree_write(): |
1534.10.23
by Aaron Bentley
Removed conflicts_to_stanzas and stanzas_to_conflicts |
177 |
tree_conflicts = tree.conflicts() |
4597.9.19
by Vincent Ladeuil
resolve now reports conflicts resolved/remaining. |
178 |
nb_conflicts_before = len(tree_conflicts) |
1534.10.10
by Aaron Bentley
Resolve uses the new stuff. |
179 |
if paths is None: |
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
180 |
new_conflicts = [] |
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
181 |
to_process = tree_conflicts |
1534.10.10
by Aaron Bentley
Resolve uses the new stuff. |
182 |
else: |
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
183 |
new_conflicts, to_process = tree_conflicts.select_conflicts( |
184 |
tree, paths, ignore_misses, recursive) |
|
185 |
for conflict in to_process: |
|
186 |
try: |
|
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
187 |
conflict.do(action, tree) |
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
188 |
conflict.cleanup(tree) |
189 |
except NotImplementedError: |
|
190 |
new_conflicts.append(conflict) |
|
1534.10.10
by Aaron Bentley
Resolve uses the new stuff. |
191 |
try: |
4597.9.19
by Vincent Ladeuil
resolve now reports conflicts resolved/remaining. |
192 |
nb_conflicts_after = len(new_conflicts) |
1534.10.25
by Aaron Bentley
Move select_conflicts into ConflictList |
193 |
tree.set_conflicts(new_conflicts) |
1996.3.33
by John Arbash Meinel
make bzrlib/conflicts.py lazy |
194 |
except errors.UnsupportedOperation: |
1534.10.10
by Aaron Bentley
Resolve uses the new stuff. |
195 |
pass
|
4597.9.19
by Vincent Ladeuil
resolve now reports conflicts resolved/remaining. |
196 |
if nb_conflicts_after is None: |
197 |
nb_conflicts_after = nb_conflicts_before |
|
198 |
return nb_conflicts_before, nb_conflicts_after |
|
4597.3.26
by Vincent Ladeuil
Tests passing for a minimal --interactive implementation. |
199 |
|
200 |
||
1185.35.1
by Aaron Bentley
Implemented conflicts.restore |
201 |
def restore(filename): |
4597.2.6
by Vincent Ladeuil
Cleanup doc string. |
202 |
"""Restore a conflicted file to the state it was in before merging. |
203 |
||
204 |
Only text restoration is supported at present.
|
|
1185.35.1
by Aaron Bentley
Implemented conflicts.restore |
205 |
"""
|
206 |
conflicted = False |
|
207 |
try: |
|
1996.3.33
by John Arbash Meinel
make bzrlib/conflicts.py lazy |
208 |
osutils.rename(filename + ".THIS", filename) |
1185.35.1
by Aaron Bentley
Implemented conflicts.restore |
209 |
conflicted = True |
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
210 |
except OSError as e: |
1185.35.1
by Aaron Bentley
Implemented conflicts.restore |
211 |
if e.errno != errno.ENOENT: |
212 |
raise
|
|
213 |
try: |
|
214 |
os.unlink(filename + ".BASE") |
|
215 |
conflicted = True |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
216 |
except OSError as e: |
1185.35.1
by Aaron Bentley
Implemented conflicts.restore |
217 |
if e.errno != errno.ENOENT: |
218 |
raise
|
|
219 |
try: |
|
220 |
os.unlink(filename + ".OTHER") |
|
221 |
conflicted = True |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
222 |
except OSError as e: |
1185.35.1
by Aaron Bentley
Implemented conflicts.restore |
223 |
if e.errno != errno.ENOENT: |
224 |
raise
|
|
225 |
if not conflicted: |
|
1996.3.33
by John Arbash Meinel
make bzrlib/conflicts.py lazy |
226 |
raise errors.NotConflicted(filename) |
1534.10.4
by Aaron Bentley
Implemented conflict serialization |
227 |
|
228 |
||
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
229 |
class ConflictList(object): |
1652.1.1
by Martin Pool
Fix 'bzr resolve' run from subdirectory |
230 |
"""List of conflicts. |
231 |
||
232 |
Typically obtained from WorkingTree.conflicts()
|
|
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
233 |
"""
|
234 |
||
235 |
def __init__(self, conflicts=None): |
|
236 |
object.__init__(self) |
|
237 |
if conflicts is None: |
|
238 |
self.__list = [] |
|
239 |
else: |
|
240 |
self.__list = conflicts |
|
241 |
||
1652.1.1
by Martin Pool
Fix 'bzr resolve' run from subdirectory |
242 |
def is_empty(self): |
243 |
return len(self.__list) == 0 |
|
244 |
||
1534.10.22
by Aaron Bentley
Got ConflictList implemented |
245 |
def __len__(self): |
246 |
return len(self.__list) |
|
247 |
||
248 |
def __iter__(self): |
|
249 |
return iter(self.__list) |
|
250 |
||
251 |
def __getitem__(self, key): |
|
252 |
return self.__list[key] |
|
253 |
||
254 |
def append(self, conflict): |
|
255 |
return self.__list.append(conflict) |
|
256 |
||
257 |
def __eq__(self, other_list): |
|
258 |
return list(self) == list(other_list) |
|
259 |
||
260 |
def __ne__(self, other_list): |
|
261 |
return not (self == other_list) |
|
262 |
||
263 |
def __repr__(self): |
|
264 |
return "ConflictList(%r)" % self.__list |
|
265 |
||
1534.10.24
by Aaron Bentley
Eliminated conflicts_to_strings, made remove_files a ConflictList member |
266 |
def to_strings(self): |
267 |
"""Generate strings for the provided conflicts""" |
|
268 |
for conflict in self: |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
269 |
yield str(conflict) |
1534.10.24
by Aaron Bentley
Eliminated conflicts_to_strings, made remove_files a ConflictList member |
270 |
|
271 |
def remove_files(self, tree): |
|
1534.10.25
by Aaron Bentley
Move select_conflicts into ConflictList |
272 |
"""Remove the THIS, BASE and OTHER files for listed conflicts""" |
1534.10.24
by Aaron Bentley
Eliminated conflicts_to_strings, made remove_files a ConflictList member |
273 |
for conflict in self: |
274 |
if not conflict.has_files: |
|
275 |
continue
|
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
276 |
conflict.cleanup(tree) |
1534.10.21
by Aaron Bentley
Moved and renamed conflict functions |
277 |
|
1551.15.58
by Aaron Bentley
Status honours selected paths for conflicts (#127606) |
278 |
def select_conflicts(self, tree, paths, ignore_misses=False, |
279 |
recurse=False): |
|
1534.10.25
by Aaron Bentley
Move select_conflicts into ConflictList |
280 |
"""Select the conflicts associated with paths in a tree. |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
281 |
|
1551.7.10
by Aaron Bentley
Remerge doesn't clear unrelated conflicts |
282 |
:return: a pair of ConflictLists: (not_selected, selected)
|
1534.10.25
by Aaron Bentley
Move select_conflicts into ConflictList |
283 |
"""
|
284 |
path_set = set(paths) |
|
285 |
selected_paths = set() |
|
286 |
new_conflicts = ConflictList() |
|
287 |
selected_conflicts = ConflictList() |
|
288 |
||
289 |
for conflict in self: |
|
290 |
selected = False |
|
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
291 |
if conflict.path in path_set: |
292 |
selected = True |
|
293 |
selected_paths.add(conflict.path) |
|
294 |
if recurse: |
|
295 |
if osutils.is_inside_any(path_set, conflict.path): |
|
1534.10.25
by Aaron Bentley
Move select_conflicts into ConflictList |
296 |
selected = True |
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
297 |
selected_paths.add(conflict.path) |
1551.15.58
by Aaron Bentley
Status honours selected paths for conflicts (#127606) |
298 |
|
1534.10.25
by Aaron Bentley
Move select_conflicts into ConflictList |
299 |
if selected: |
300 |
selected_conflicts.append(conflict) |
|
301 |
else: |
|
302 |
new_conflicts.append(conflict) |
|
303 |
if ignore_misses is not True: |
|
304 |
for path in [p for p in paths if p not in selected_paths]: |
|
305 |
if not os.path.exists(tree.abspath(path)): |
|
6619.3.3
by Jelmer Vernooij
Apply 2to3 print fix. |
306 |
print("%s does not exist" % path) |
1534.10.25
by Aaron Bentley
Move select_conflicts into ConflictList |
307 |
else: |
6619.3.3
by Jelmer Vernooij
Apply 2to3 print fix. |
308 |
print("%s is not conflicted" % path) |
1534.10.25
by Aaron Bentley
Move select_conflicts into ConflictList |
309 |
return new_conflicts, selected_conflicts |
310 |
||
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
311 |
|
1534.10.18
by Aaron Bentley
Defined all new Conflict types |
312 |
class Conflict(object): |
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
313 |
"""Base class for conflicts.""" |
314 |
||
315 |
typestring = None |
|
316 |
||
317 |
def __init__(self, path): |
|
1534.10.18
by Aaron Bentley
Defined all new Conflict types |
318 |
self.path = path |
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
319 |
|
5013.2.4
by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files. |
320 |
def associated_filenames(self): |
321 |
"""The names of the files generated to help resolve the conflict.""" |
|
322 |
raise NotImplementedError(self.associated_filenames) |
|
323 |
||
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
324 |
def cleanup(self, tree): |
5013.2.4
by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files. |
325 |
for fname in self.associated_filenames(): |
326 |
try: |
|
327 |
osutils.delete_any(tree.abspath(fname)) |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
328 |
except OSError as e: |
5013.2.4
by Vincent Ladeuil
``bzr add`` won't blindly add conflict related files. |
329 |
if e.errno != errno.ENOENT: |
330 |
raise
|
|
4597.3.52
by Vincent Ladeuil
Replace --interactive by --action. |
331 |
|
7490.129.3
by Jelmer Vernooij
Split out bzr-specific Conflicts code. |
332 |
def do(self, action, tree): |
333 |
"""Apply the specified action to the conflict. |
|
334 |
||
335 |
:param action: The method name to call.
|
|
336 |
||
337 |
:param tree: The tree passed as a parameter to the method.
|
|
338 |
"""
|
|
339 |
raise NotImplementedError(self.do) |
|
7490.129.9
by Jelmer Vernooij
Fix tests. |
340 |
|
341 |
def describe(self): |
|
7490.133.16
by Jelmer Vernooij
Merge refactor of conflict code. |
342 |
"""Return a string description of this conflict.""" |
7490.129.9
by Jelmer Vernooij
Fix tests. |
343 |
raise NotImplementedError(self.describe) |