/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_4.py

  • Committer: Robert Collins
  • Date: 2007-03-02 01:06:12 UTC
  • mto: (2255.11.3 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: robertc@robertcollins.net-20070302010612-v4zb59puoc5b0ai5
Teach _iter_changes to gather unversioned path details upon request.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1437
1437
 
1438
1438
    def _iter_changes(self, include_unchanged=False,
1439
1439
                      specific_files=None, pb=None, extra_trees=[],
1440
 
                      require_versioned=True):
 
1440
                      require_versioned=True, want_unversioned=False):
1441
1441
        """Return the changes from source to target.
1442
1442
 
1443
1443
        :return: An iterator that yields tuples. See InterTree._iter_changes
1453
1453
        :param require_versioned: If True, all files in specific_files must be
1454
1454
            versioned in one of source, target, extra_trees or
1455
1455
            PathsNotVersionedError is raised.
 
1456
        :param want_unversioned: Should unversioned files be returned in the
 
1457
            output. An unversioned file is defined as one with (False, False)
 
1458
            for the versioned pair.
1456
1459
        """
1457
1460
        utf8_decode = cache_utf8._utf8_decode
1458
1461
        _minikind_to_kind = dirstate.DirState._minikind_to_kind
1793
1796
            if not root_entries and not root_dir_info:
1794
1797
                # this specified path is not present at all, skip it.
1795
1798
                continue
 
1799
            path_handled = False
1796
1800
            for entry in root_entries:
1797
1801
                for result in _process_entry(entry, root_dir_info):
1798
1802
                    # this check should probably be outside the loop: one
1799
1803
                    # 'iterate two trees' api, and then _iter_changes filters
1800
1804
                    # unchanged pairs. - RBC 20070226
 
1805
                    path_handled = True
1801
1806
                    if (include_unchanged
1802
1807
                        or result[2]                    # content change
1803
1808
                        or result[3][0] != result[3][1] # versioned status
1809
1814
                        result = (result[0],
1810
1815
                                  utf8_decode(result[1])[0]) + result[2:]
1811
1816
                        yield result
 
1817
            if want_unversioned and not path_handled:
 
1818
                new_executable = bool(
 
1819
                    stat.S_ISREG(root_dir_info[3].st_mode)
 
1820
                    and stat.S_IEXEC & root_dir_info[3].st_mode)
 
1821
                yield (None, current_root, True, (False, False), (None, None),
 
1822
                    (None, splitpath(current_root)[-1]),
 
1823
                    (None, root_dir_info[2]), (None, new_executable))
1812
1824
            dir_iterator = osutils._walkdirs_utf8(root_abspath, prefix=current_root)
1813
1825
            initial_key = (current_root, '', '')
1814
1826
            block_index, _ = state._find_block_index_from_key(initial_key)
1906
1918
                else:
1907
1919
                    current_path_info = None
1908
1920
                advance_path = True
 
1921
                path_handled = False
1909
1922
                while (current_entry is not None or
1910
1923
                    current_path_info is not None):
1911
1924
                    if current_entry is None:
1912
 
                        # no more entries: yield current_pathinfo as an
1913
 
                        # unversioned file: its not the same as a path in any
1914
 
                        # tree in the dirstate.
1915
 
                        new_executable = bool(
1916
 
                            stat.S_ISREG(current_path_info[3].st_mode)
1917
 
                            and stat.S_IEXEC & current_path_info[3].st_mode)
1918
 
                        pass # unversioned file support not added to the
1919
 
                        # _iter_changes api yet - breaks status amongst other
1920
 
                        # things.
1921
 
#                        yield (None, current_path_info[0], True,
1922
 
#                               (False, False),
1923
 
#                               (None, None),
1924
 
#                               (None, current_path_info[1]),
1925
 
#                               (None, current_path_info[2]),
1926
 
#                               (None, new_executable))
 
1925
                        # the check for path_handled when the path is adnvaced
 
1926
                        # will yield this path if needed.
 
1927
                        pass
1927
1928
                    elif current_path_info is None:
1928
1929
                        # no path is fine: the per entry code will handle it.
1929
1930
                        for result in _process_entry(current_entry, current_path_info):
1955
1956
                                # this check should probably be outside the loop: one
1956
1957
                                # 'iterate two trees' api, and then _iter_changes filters
1957
1958
                                # unchanged pairs. - RBC 20070226
 
1959
                                path_handled = True
1958
1960
                                if (include_unchanged
1959
1961
                                    or result[2]                    # content change
1960
1962
                                    or result[3][0] != result[3][1] # versioned status
1972
1974
                            # this check should probably be outside the loop: one
1973
1975
                            # 'iterate two trees' api, and then _iter_changes filters
1974
1976
                            # unchanged pairs. - RBC 20070226
 
1977
                            path_handled = True
1975
1978
                            if (include_unchanged
1976
1979
                                or result[2]                    # content change
1977
1980
                                or result[3][0] != result[3][1] # versioned status
1992
1995
                    else:
1993
1996
                        advance_entry = True # reset the advance flaga
1994
1997
                    if advance_path and current_path_info is not None:
 
1998
                        if want_unversioned and not path_handled:
 
1999
                            new_executable = bool(
 
2000
                                stat.S_ISREG(current_path_info[3].st_mode)
 
2001
                                and stat.S_IEXEC & current_path_info[3].st_mode)
 
2002
                            if want_unversioned:
 
2003
                                yield (None, current_path_info[0], True,
 
2004
                                       (False, False),
 
2005
                                       (None, None),
 
2006
                                       (None, current_path_info[1]),
 
2007
                                       (None, current_path_info[2]),
 
2008
                                       (None, new_executable))
1995
2009
                        path_index += 1
1996
2010
                        if path_index < len(current_dir_info[1]):
1997
2011
                            current_path_info = current_dir_info[1][path_index]
1998
2012
                        else:
1999
2013
                            current_path_info = None
 
2014
                        path_handled = False
2000
2015
                    else:
2001
2016
                        advance_path = True # reset the advance flagg.
2002
2017
                if current_block is not None: