/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Robert Collins
  • Date: 2007-03-07 01:14:11 UTC
  • mfrom: (2321 +trunk)
  • mto: (2321.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: robertc@robertcollins.net-20070307011411-0cmmc8atx67v3nv7
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
import stat
51
51
from time import time
52
52
import warnings
 
53
import re
53
54
 
54
55
import bzrlib
55
56
from bzrlib import (
870
871
        except StopIteration:
871
872
            raise errors.MergeModifiedFormatError()
872
873
        for s in RioReader(hashfile):
873
 
            file_id = s.get("file_id")
 
874
            # RioReader reads in Unicode, so convert file_ids back to utf8
 
875
            file_id = osutils.safe_file_id(s.get("file_id"), warn=False)
874
876
            if file_id not in self.inventory:
875
877
                continue
876
878
            text_hash = s.get("hash")
2251
2253
                if dir[2] == _directory:
2252
2254
                    pending.append(dir)
2253
2255
 
 
2256
    @needs_tree_write_lock
 
2257
    def auto_resolve(self):
 
2258
        """Automatically resolve text conflicts according to contents.
 
2259
 
 
2260
        Only text conflicts are auto_resolvable. Files with no conflict markers
 
2261
        are considered 'resolved', because bzr always puts conflict markers
 
2262
        into files that have text conflicts.  The corresponding .THIS .BASE and
 
2263
        .OTHER files are deleted, as per 'resolve'.
 
2264
        :return: a tuple of ConflictLists: (un_resolved, resolved).
 
2265
        """
 
2266
        un_resolved = _mod_conflicts.ConflictList()
 
2267
        resolved = _mod_conflicts.ConflictList()
 
2268
        conflict_re = re.compile('^(<{7}|={7}|>{7})')
 
2269
        for conflict in self.conflicts():
 
2270
            if (conflict.typestring != 'text conflict' or
 
2271
                self.kind(conflict.file_id) != 'file'):
 
2272
                un_resolved.append(conflict)
 
2273
                continue
 
2274
            my_file = open(self.id2abspath(conflict.file_id), 'rb')
 
2275
            try:
 
2276
                for line in my_file:
 
2277
                    if conflict_re.search(line):
 
2278
                        un_resolved.append(conflict)
 
2279
                        break
 
2280
                else:
 
2281
                    resolved.append(conflict)
 
2282
            finally:
 
2283
                my_file.close()
 
2284
        resolved.remove_files(self)
 
2285
        self.set_conflicts(un_resolved)
 
2286
        return un_resolved, resolved
 
2287
 
2254
2288
 
2255
2289
class WorkingTree2(WorkingTree):
2256
2290
    """This is the Format 2 working tree.