1
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
1
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
995
995
self._new_contents.iteritems()]
996
996
entries.sort(reverse=True)
997
997
for path, trans_id, kind in entries:
998
if kind == "directory":
1003
os.rmdir(self._limbodir)
1000
delete_any(self._limbodir)
1004
1001
except OSError:
1005
1002
# We don't especially care *why* the dir is immortal.
1006
1003
raise ImmortalLimbo(self._limbodir)
1008
1005
if self._deletiondir is not None:
1009
os.rmdir(self._deletiondir)
1006
delete_any(self._deletiondir)
1010
1007
except OSError:
1011
1008
raise errors.ImmortalPendingDeletion(self._deletiondir)
1748
1745
if self._transform.final_file_id(trans_id) is None:
1749
1746
yield self._final_paths._determine_path(trans_id)
1751
def _make_inv_entries(self, ordered_entries, specific_file_ids):
1748
def _make_inv_entries(self, ordered_entries, specific_file_ids=None):
1752
1749
for trans_id, parent_file_id in ordered_entries:
1753
1750
file_id = self._transform.final_file_id(trans_id)
1754
1751
if file_id is None:
1791
1788
specific_file_ids):
1792
1789
yield unicode(self._final_paths.get_path(trans_id)), entry
1794
def list_files(self, include_root=False):
1795
"""See Tree.list_files."""
1791
def _iter_entries_for_dir(self, dir_path):
1792
"""Return path, entry for items in a directory without recursing down."""
1793
dir_file_id = self.path2id(dir_path)
1795
for file_id in self.iter_children(dir_file_id):
1796
trans_id = self._transform.trans_id_file_id(file_id)
1797
ordered_ids.append((trans_id, file_id))
1798
for entry, trans_id in self._make_inv_entries(ordered_ids):
1799
yield unicode(self._final_paths.get_path(trans_id)), entry
1801
def list_files(self, include_root=False, from_dir=None, recursive=True):
1802
"""See WorkingTree.list_files."""
1796
1803
# XXX This should behave like WorkingTree.list_files, but is really
1797
1804
# more like RevisionTree.list_files.
1798
for path, entry in self.iter_entries_by_dir():
1799
if entry.name == '' and not include_root:
1801
yield path, 'V', entry.kind, entry.file_id, entry
1808
prefix = from_dir + '/'
1809
entries = self.iter_entries_by_dir()
1810
for path, entry in entries:
1811
if entry.name == '' and not include_root:
1814
if not path.startswith(prefix):
1816
path = path[len(prefix):]
1817
yield path, 'V', entry.kind, entry.file_id, entry
1819
if from_dir is None and include_root is True:
1820
root_entry = inventory.make_entry('directory', '',
1821
ROOT_PARENT, self.get_root_id())
1822
yield '', 'V', 'directory', root_entry.file_id, root_entry
1823
entries = self._iter_entries_for_dir(from_dir or '')
1824
for path, entry in entries:
1825
yield path, 'V', entry.kind, entry.file_id, entry
1803
1827
def kind(self, file_id):
1804
1828
trans_id = self._transform.trans_id_file_id(file_id)
1938
1962
return old_annotation
1939
1963
if not changed_content:
1940
1964
return old_annotation
1965
# TODO: This is doing something similar to what WT.annotate_iter is
1966
# doing, however it fails slightly because it doesn't know what
1967
# the *other* revision_id is, so it doesn't know how to give the
1968
# other as the origin for some lines, they all get
1969
# 'default_revision'
1970
# It would be nice to be able to use the new Annotator based
1971
# approach, as well.
1941
1972
return annotate.reannotate([old_annotation],
1942
1973
self.get_file(file_id).readlines(),
1943
1974
default_revision)