1
# Copyright (C) 2005 by Aaron Bentley
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.
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.
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
# TODO: Move this into builtins
19
# TODO: 'bzr resolve' should accept a directory name and work from that
22
# TODO: bzr revert should resolve; even when reverting the whole tree
23
# or particular directories
26
from bzrlib.branch import Branch
27
from bzrlib.errors import BzrCommandError
28
from bzrlib.commands import register_command
29
from bzrlib.workingtree import CONFLICT_SUFFIXES
33
class cmd_conflicts(bzrlib.commands.Command):
34
"""List files with conflicts.
35
(conflicts are determined by the presence of .BASE .TREE, and .OTHER
39
for path in Branch.open_containing('.').working_tree().iter_conflicts():
42
register_command(cmd_conflicts)
44
class cmd_resolve(bzrlib.commands.Command):
45
"""Mark a conflict as resolved.
47
takes_args = ['file*']
48
takes_options = ['all']
49
def run(self, file_list=None, all=False):
52
raise BzrCommandError(
53
"command 'resolve' needs one or more FILE, or --all")
54
tree = Branch.open_containing('.').working_tree()
55
file_list = list(tree.abspath(f) for f in tree.iter_conflicts())
58
raise BzrCommandError(
59
"If --all is specified, no FILE may be provided")
60
for filename in file_list:
62
for suffix in CONFLICT_SUFFIXES:
64
os.unlink(filename+suffix)
66
if e.errno != errno.ENOENT:
70
if failures == len(CONFLICT_SUFFIXES):
71
if not os.path.exists(filename):
72
print "%s does not exist" % filename
74
print "%s is not conflicted" % filename
76
register_command(cmd_resolve)