14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
from __future__ import absolute_import
17
19
from .lazy_import import lazy_import
18
20
lazy_import(globals(), """
885
887
raise NotImplementedError(self.iter_revisions)
889
def get_deltas_for_revisions(self, revisions, specific_fileids=None):
890
"""Produce a generator of revision deltas.
892
Note that the input is a sequence of REVISIONS, not revision_ids.
893
Trees will be held in memory until the generator exits.
894
Each delta is relative to the revision's lefthand predecessor.
896
:param specific_fileids: if not None, the result is filtered
897
so that only those file-ids, their parents and their
898
children are included.
900
raise NotImplementedError(self.get_deltas_for_revisions)
887
902
def get_revision_delta(self, revision_id):
888
903
"""Return the delta for one revision.
893
908
with self.lock_read():
894
909
r = self.get_revision(revision_id)
895
return list(self.get_revision_deltas([r]))[0]
897
def get_revision_deltas(self, revisions, specific_files=None):
898
"""Produce a generator of revision deltas.
900
Note that the input is a sequence of REVISIONS, not revision ids.
901
Trees will be held in memory until the generator exits.
902
Each delta is relative to the revision's lefthand predecessor.
904
specific_files should exist in the first revision.
906
:param specific_files: if not None, the result is filtered
907
so that only those files, their parents and their
908
children are included.
910
from .tree import InterTree
911
# Get the revision-ids of interest
912
required_trees = set()
913
for revision in revisions:
914
required_trees.add(revision.revision_id)
915
required_trees.update(revision.parent_ids[:1])
918
t.get_revision_id(): t
919
for t in self.revision_trees(required_trees)}
921
# Calculate the deltas
922
for revision in revisions:
923
if not revision.parent_ids:
924
old_tree = self.revision_tree(_mod_revision.NULL_REVISION)
926
old_tree = trees[revision.parent_ids[0]]
927
intertree = InterTree.get(old_tree, trees[revision.revision_id])
928
yield intertree.compare(specific_files=specific_files)
929
if specific_files is not None:
931
p for p in intertree.find_source_paths(
932
specific_files).values()
910
return list(self.get_deltas_for_revisions([r]))[0]
935
912
def store_revision_signature(self, gpg_strategy, plaintext, revision_id):
936
913
raise NotImplementedError(self.store_revision_signature)
1530
1507
self.target.set_make_working_trees(
1531
1508
self.source.make_working_trees())
1532
except (NotImplementedError, errors.RepositoryUpgradeRequired):
1509
except NotImplementedError:
1534
1511
self.target.fetch(self.source, revision_id=revision_id)