~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Andrew Bennetts
  • Date: 2010-01-15 05:30:30 UTC
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: andrew.bennetts@canonical.com-20100115053030-1d6qd89pnj8hmb55
Pass kinds (not pairs) to MergeHookParams.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
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
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
# TODO: Move this into builtins
18
18
 
19
 
# TODO: 'bzr resolve' should accept a directory name and work from that 
 
19
# TODO: 'bzr resolve' should accept a directory name and work from that
20
20
# point down
21
21
 
22
22
import os
53
53
    instead.  (This is useful for editing all files with text conflicts.)
54
54
 
55
55
    Use bzr resolve when you have fixed a problem.
56
 
 
57
 
    See also bzr resolve.
58
56
    """
59
57
    takes_options = [
60
58
            Option('text',
61
59
                   help='List paths of files with text conflicts.'),
62
60
        ]
 
61
    _see_also = ['resolve', 'conflict-types']
63
62
 
64
63
    def run(self, text=False):
65
64
        from bzrlib.workingtree import WorkingTree
82
81
    before you should commit.
83
82
 
84
83
    Once you have fixed a problem, use "bzr resolve" to automatically mark
85
 
    text conflicts as fixed, resolve FILE to mark a specific conflict as
 
84
    text conflicts as fixed, "bzr resolve FILE" to mark a specific conflict as
86
85
    resolved, or "bzr resolve --all" to mark all conflicts as resolved.
87
 
 
88
 
    See also bzr conflicts.
89
86
    """
90
87
    aliases = ['resolved']
91
88
    takes_args = ['file*']
92
89
    takes_options = [
93
90
            Option('all', help='Resolve all conflicts in this tree.'),
94
91
            ]
 
92
    _see_also = ['conflicts']
95
93
    def run(self, file_list=None, all=False):
96
94
        from bzrlib.workingtree import WorkingTree
97
95
        if all:
150
148
 
151
149
 
152
150
def restore(filename):
153
 
    """\
154
 
    Restore a conflicted file to the state it was in before merging.
155
 
    Only text restoration supported at present.
 
151
    """Restore a conflicted file to the state it was in before merging.
 
152
 
 
153
    Only text restoration is supported at present.
156
154
    """
157
155
    conflicted = False
158
156
    try:
228
226
        """Generator of stanzas"""
229
227
        for conflict in self:
230
228
            yield conflict.as_stanza()
231
 
            
 
229
 
232
230
    def to_strings(self):
233
231
        """Generate strings for the provided conflicts"""
234
232
        for conflict in self:
249
247
    def select_conflicts(self, tree, paths, ignore_misses=False,
250
248
                         recurse=False):
251
249
        """Select the conflicts associated with paths in a tree.
252
 
        
 
250
 
253
251
        File-ids are also used for this.
254
252
        :return: a pair of ConflictLists: (not_selected, selected)
255
253
        """
299
297
                    print "%s is not conflicted" % path
300
298
        return new_conflicts, selected_conflicts
301
299
 
302
 
 
 
300
 
303
301
class Conflict(object):
304
302
    """Base class for all types of conflict"""
305
303
 
403
401
    """
404
402
 
405
403
    rformat = "%(class)s(%(action)r, %(path)r, %(file_id)r)"
406
 
    
 
404
 
407
405
    def __init__(self, action, path, file_id=None):
408
406
        Conflict.__init__(self, path, file_id)
409
407
        self.action = action
428
426
    def __init__(self, action, path, conflict_path, file_id=None,
429
427
                 conflict_file_id=None):
430
428
        HandledConflict.__init__(self, action, path, file_id)
431
 
        self.conflict_path = conflict_path 
 
429
        self.conflict_path = conflict_path
432
430
        # warn turned off, because the factory blindly transfers the Stanza
433
431
        # values to __init__.
434
432
        self.conflict_file_id = osutils.safe_file_id(conflict_file_id,
435
433
                                                     warn=False)
436
 
        
 
434
 
437
435
    def _cmp_list(self):
438
 
        return HandledConflict._cmp_list(self) + [self.conflict_path, 
 
436
        return HandledConflict._cmp_list(self) + [self.conflict_path,
439
437
                                                  self.conflict_file_id]
440
438
 
441
439
    def as_stanza(self):
443
441
        s.add('conflict_path', self.conflict_path)
444
442
        if self.conflict_file_id is not None:
445
443
            s.add('conflict_file_id', self.conflict_file_id.decode('utf8'))
446
 
            
 
444
 
447
445
        return s
448
446
 
449
447
 
480
478
 
481
479
 
482
480
class UnversionedParent(HandledConflict):
483
 
    """An attempt to version an file whose parent directory is not versioned.
 
481
    """An attempt to version a file whose parent directory is not versioned.
484
482
    Typically, the result of a merge where one tree unversioned the directory
485
483
    and the other added a versioned file to it.
486
484
    """