~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/conflicts.py

  • Committer: Martin Pool
  • Date: 2008-10-20 23:58:12 UTC
  • mto: This revision was merged to the branch mainline in revision 3787.
  • Revision ID: mbp@sourcefrog.net-20081020235812-itg90mk0u4dez92z
lp-upload-release now handles names like bzr-1.8.tar.gz

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