~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: John Arbash Meinel
  • Date: 2007-03-06 15:12:18 UTC
  • mfrom: (2319 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2321.
  • Revision ID: john@arbash-meinel.com-20070306151218-b8ucoudmtdy5ls0m
[merge] bzr.dev 2319
(broken) Conflicts generate unicode file ids, will fix in next commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
import stat
48
48
from time import time
49
49
import warnings
 
50
import re
50
51
 
51
52
import bzrlib
52
53
from bzrlib import (
1941
1942
                             file_id=self.path2id(conflicted)))
1942
1943
        return conflicts
1943
1944
 
 
1945
    @needs_tree_write_lock
 
1946
    def auto_resolve(self):
 
1947
        """Automatically resolve text conflicts according to contents.
 
1948
 
 
1949
        Only text conflicts are auto_resolvable. Files with no conflict markers
 
1950
        are considered 'resolved', because bzr always puts conflict markers
 
1951
        into files that have text conflicts.  The corresponding .THIS .BASE and
 
1952
        .OTHER files are deleted, as per 'resolve'.
 
1953
        :return: a tuple of ConflictLists: (un_resolved, resolved).
 
1954
        """
 
1955
        un_resolved = _mod_conflicts.ConflictList()
 
1956
        resolved = _mod_conflicts.ConflictList()
 
1957
        conflict_re = re.compile('^(<{7}|={7}|>{7})')
 
1958
        for conflict in self.conflicts():
 
1959
            if (conflict.typestring != 'text conflict' or
 
1960
                self.kind(conflict.file_id) != 'file'):
 
1961
                un_resolved.append(conflict)
 
1962
                continue
 
1963
            my_file = open(self.id2abspath(conflict.file_id), 'rb')
 
1964
            try:
 
1965
                for line in my_file:
 
1966
                    if conflict_re.search(line):
 
1967
                        un_resolved.append(conflict)
 
1968
                        break
 
1969
                else:
 
1970
                    resolved.append(conflict)
 
1971
            finally:
 
1972
                my_file.close()
 
1973
        resolved.remove_files(self)
 
1974
        self.set_conflicts(un_resolved)
 
1975
        return un_resolved, resolved
 
1976
 
1944
1977
 
1945
1978
class WorkingTree2(WorkingTree):
1946
1979
    """This is the Format 2 working tree.