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
18
from bzrlib.branch import Branch
22
SUFFIXES = ('.THIS', '.BASE', '.OTHER')
23
def get_conflicted_stem(path):
24
for suffix in SUFFIXES:
25
if path.endswith(suffix):
26
return path[:-len(suffix)]
28
def iter_conflicts(tree):
30
for path in (s[0] for s in tree.list_files()):
31
stem = get_conflicted_stem(path)
34
if stem not in conflicted:
38
class cmd_conflicts(bzrlib.commands.Command):
39
"""List files with conflicts.
40
(conflicts are determined by the presence of .BASE .TREE, and .OTHER
44
for path in iter_conflicts(Branch.open_containing('.').working_tree()):
47
class cmd_resolve(bzrlib.commands.Command):
48
"""Mark a conflict as resolved.
50
takes_args = ['file+']
51
def run(self, file_list):
52
for file in file_list:
54
for suffix in SUFFIXES:
56
os.unlink(file+suffix)
58
if e.errno != errno.ENOENT:
62
if failures == len(SUFFIXES):
63
print "%s is not conflicted" % file
67
# monkey-patch the standard 'status' to give us conflicts, too.
68
def _show_status(branch, **kwargs):
69
old_show_status(branch, **kwargs)
70
conflicted = list(iter_conflicts(branch.working_tree()))
71
if len(conflicted) > 0:
76
old_show_status = bzrlib.status.show_status
77
bzrlib.status.show_status = _show_status