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
20
SUFFIXES = ('.TREE', '.BASE', '.OTHER')
21
def get_conflicted_stem(path):
22
for suffix in SUFFIXES:
23
if path.endswith(suffix):
24
return path[:-len(suffix)]
26
def iter_conflicts(tree):
28
for path in (s[0] for s in tree.list_files()):
29
stem = get_conflicted_stem(path)
32
if stem not in conflicted:
36
class cmd_conflicts(bzrlib.commands.Command):
37
"""List files with conflicts.
38
(conflicts are determined by the presence of .BASE .TREE, and .OTHER
42
for path in iter_conflicts(Branch('.').working_tree()):
45
# monkey-patch the standard 'status' to give us conflicts, too.
46
def _show_status(branch, **kwargs):
47
old_show_status(branch, **kwargs)
48
conflicted = list(iter_conflicts(branch.working_tree()))
49
if len(conflicted) > 0:
54
old_show_status = bzrlib.status.show_status
55
bzrlib.status.show_status = _show_status