diff -Nru bzr-fastimport-0.10.0+bzr317/branch_updater.py bzr-fastimport-0.10.0+bzr324/branch_updater.py --- bzr-fastimport-0.10.0+bzr317/branch_updater.py 2011-02-01 10:04:51.000000000 +0000 +++ bzr-fastimport-0.10.0+bzr324/branch_updater.py 2011-07-20 14:33:45.000000000 +0000 @@ -19,7 +19,7 @@ from operator import itemgetter from bzrlib import bzrdir, errors, osutils, transport -from bzrlib.trace import error, note +from bzrlib.trace import show_error, note from bzrlib.plugins.fastimport.helpers import ( best_format_for_objects_in_a_repository, @@ -119,7 +119,7 @@ branch_tips.append((br,tip)) continue except errors.BzrError, ex: - error("ERROR: failed to create branch %s: %s", + show_error("ERROR: failed to create branch %s: %s", location, ex) lost_head = self.cache_mgr.lookup_committish(tip) lost_info = (name, lost_head) @@ -152,8 +152,12 @@ """ from fastimport.helpers import single_plural last_rev_id = self.cache_mgr.lookup_committish(last_mark) - revs = list(self.repo.iter_reverse_revision_history(last_rev_id)) - revno = len(revs) + self.repo.lock_read() + try: + graph = self.repo.get_graph() + revno = graph.find_distance_to_null(last_rev_id, []) + finally: + self.repo.unlock() existing_revno, existing_last_rev_id = br.last_revision_info() changed = False if revno != existing_revno or last_rev_id != existing_last_rev_id: diff -Nru bzr-fastimport-0.10.0+bzr317/bzr_commit_handler.py bzr-fastimport-0.10.0+bzr324/bzr_commit_handler.py --- bzr-fastimport-0.10.0+bzr317/bzr_commit_handler.py 2011-02-02 10:34:22.000000000 +0000 +++ bzr-fastimport-0.10.0+bzr324/bzr_commit_handler.py 2011-07-20 14:31:09.000000000 +0000 @@ -44,14 +44,13 @@ _serializer_handles_escaping = hasattr(serializer.Serializer, 'squashes_xml_invalid_characters') -def copy_inventory(inv): - # This currently breaks revision-id matching - #if hasattr(inv, "_get_mutable_inventory"): - # # TODO: Make this a public API on inventory - # return inv._get_mutable_inventory() - # TODO: Shallow copy - deep inventory copying is expensive - return inv.copy() +def copy_inventory(inv): + entries = inv.iter_entries_by_dir() + inv = inventory.Inventory(None, inv.revision_id) + for path, inv_entry in entries: + inv.add(inv_entry.copy()) + return inv class GenericCommitHandler(processor.CommitHandler): @@ -363,7 +362,7 @@ % (kind, path)) return # Record it - if file_id in inv: + if inv.has_id(file_id): old_ie = inv[file_id] if old_ie.kind == 'directory': self.record_delete(path, old_ie) @@ -405,7 +404,7 @@ # It's possible that a file or symlink with that file-id # already exists. If it does, we need to delete it. - if dir_file_id in inv: + if inv.has_id(dir_file_id): self.record_delete(dirname, ie) self.record_new(dirname, ie) return basename, ie.file_id @@ -510,8 +509,11 @@ self.data_for_commit[file_id] = ''.join(lines) def _delete_all_items(self, inv): - for name, root_item in inv.root.children.iteritems(): - inv.remove_recursive_id(root_item.file_id) + if len(inv) == 0: + return + for path, ie in inv.iter_entries_by_dir(): + if path != "": + self.record_delete(path, ie) def _warn_unless_in_merges(self, fileid, path): if len(self.parents) <= 1: @@ -906,10 +908,4 @@ def deleteall_handler(self, filecmd): self.debug("deleting all files (and also all directories)") - # I'm not 100% sure this will work in the delta case. - # But clearing out the basis inventory so that everything - # is added sounds ok in theory ... - # We grab a copy as the basis is likely to be cached and - # we don't want to destroy the cached version - self.basis_inventory = copy_inventory(self.basis_inventory) self._delete_all_items(self.basis_inventory) diff -Nru bzr-fastimport-0.10.0+bzr317/cmds.py bzr-fastimport-0.10.0+bzr324/cmds.py --- bzr-fastimport-0.10.0+bzr317/cmds.py 2011-04-28 12:26:11.000000000 +0000 +++ bzr-fastimport-0.10.0+bzr324/cmds.py 2011-06-17 12:09:55.000000000 +0000 @@ -41,7 +41,7 @@ def _get_source_stream(source): - if source == '-': + if source == '-' or source is None: import sys from fastimport import helpers stream = helpers.binary_stream(sys.stdin) diff -Nru bzr-fastimport-0.10.0+bzr317/debian/changelog bzr-fastimport-0.10.0+bzr324/debian/changelog --- bzr-fastimport-0.10.0+bzr317/debian/changelog 2011-05-14 21:34:40.000000000 +0000 +++ bzr-fastimport-0.10.0+bzr324/debian/changelog 2011-07-23 21:49:54.000000000 +0000 @@ -1,8 +1,14 @@ -bzr-fastimport (0.10.0+bzr317-3~bazaar1~karmic1) karmic; urgency=low +bzr-fastimport (0.10.0+bzr324-1~bazaar1~karmic1) karmic; urgency=low * Rebuild in PPA. - -- Max Bowsher Sat, 14 May 2011 22:34:40 +0100 + -- Max Bowsher <_@maxb.eu> Sat, 23 Jul 2011 22:49:54 +0100 + +bzr-fastimport (0.10.0+bzr324-1) unstable; urgency=low + + * New upstream snapshot. + + -- Jelmer Vernooij Wed, 20 Jul 2011 16:34:20 +0200 bzr-fastimport (0.10.0+bzr317-3) unstable; urgency=low diff -Nru bzr-fastimport-0.10.0+bzr317/debian/patches/debian-changes-0.10.0+bzr317-3 bzr-fastimport-0.10.0+bzr324/debian/patches/debian-changes-0.10.0+bzr317-3 --- bzr-fastimport-0.10.0+bzr317/debian/patches/debian-changes-0.10.0+bzr317-3 2011-05-06 00:59:06.000000000 +0000 +++ bzr-fastimport-0.10.0+bzr324/debian/patches/debian-changes-0.10.0+bzr317-3 1970-01-01 00:00:00.000000000 +0000 @@ -1,1225 +0,0 @@ -Description: Upstream changes introduced in version 0.10.0+bzr317-3 - This patch has been created by dpkg-source during the package build. - Here's the last changelog entry, hopefully it gives details on why - those changes were made: - . - bzr-fastimport (0.10.0+bzr317-3) unstable; urgency=low - . - * Re-arrange | condition in build deps to make sbuild happy. - * Bump standards version to 3.9.2 (no changes). - . - The person named in the Author field signed this changelog entry. -Author: Jelmer Vernooij - ---- -The information above should follow the Patch Tagging Guidelines, please -checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here -are templates for supplementary fields that you might want to add: - -Origin: , -Bug: -Bug-Debian: http://bugs.debian.org/ -Bug-Ubuntu: https://launchpad.net/bugs/ -Forwarded: -Reviewed-By: -Last-Update: - ---- /dev/null -+++ bzr-fastimport-0.10.0+bzr317/tests/test_filter_processor.py -@@ -0,0 +1,877 @@ -+# Copyright (C) 2009 Canonical Ltd -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ -+"""Test FilterProcessor""" -+ -+from cStringIO import StringIO -+ -+from bzrlib import tests -+ -+from bzrlib.plugins.fastimport import ( -+ parser, -+ ) -+from bzrlib.plugins.fastimport.processors.filter_processor import ( -+ FilterProcessor, -+ ) -+ -+ -+# A sample input stream containing all (top level) import commands -+_SAMPLE_ALL = \ -+"""blob -+mark :1 -+data 4 -+foo -+commit refs/heads/master -+mark :2 -+committer Joe 1234567890 +1000 -+data 14 -+Initial import -+M 644 :1 COPYING -+checkpoint -+progress first import done -+reset refs/remote/origin/master -+from :2 -+tag v0.1 -+from :2 -+tagger Joe 1234567890 +1000 -+data 12 -+release v0.1 -+""" -+ -+ -+# A sample input stream creating the following tree: -+# -+# NEWS -+# doc/README.txt -+# doc/index.txt -+_SAMPLE_WITH_DIR = \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 doc/README.txt -+blob -+mark :2 -+data 17 -+Life -+is -+good ... -+commit refs/heads/master -+mark :101 -+committer a 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :2 NEWS -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :101 -+M 644 :3 doc/README.txt -+M 644 :4 doc/index.txt -+""" -+ -+ -+class TestCaseWithFiltering(tests.TestCase): -+ -+ def assertFiltering(self, input, params, expected): -+ outf = StringIO() -+ proc = FilterProcessor(None, params=params) -+ proc.outf = outf -+ s = StringIO(input) -+ p = parser.ImportParser(s) -+ proc.process(p.iter_commands) -+ out = outf.getvalue() -+ self.assertEqualDiff(expected, out) -+ -+ -+class TestNoFiltering(TestCaseWithFiltering): -+ -+ def test_params_not_given(self): -+ self.assertFiltering(_SAMPLE_ALL, None, _SAMPLE_ALL) -+ -+ def test_params_are_none(self): -+ params = {'include_paths': None, 'exclude_paths': None} -+ self.assertFiltering(_SAMPLE_ALL, params, _SAMPLE_ALL) -+ -+ -+class TestIncludePaths(TestCaseWithFiltering): -+ -+ def test_file_in_root(self): -+ # Things to note: -+ # * only referenced blobs are retained -+ # * from clause is dropped from the first command -+ params = {'include_paths': ['NEWS']} -+ self.assertFiltering(_SAMPLE_WITH_DIR, params, \ -+"""blob -+mark :2 -+data 17 -+Life -+is -+good ... -+commit refs/heads/master -+mark :101 -+committer a 1234798653 +0000 -+data 8 -+test -+ing -+M 644 :2 NEWS -+""") -+ -+ def test_file_in_subdir(self): -+ # Additional things to note: -+ # * new root: path is now index.txt, not doc/index.txt -+ # * other files changed in matching commits are excluded -+ params = {'include_paths': ['doc/index.txt']} -+ self.assertFiltering(_SAMPLE_WITH_DIR, params, \ -+"""blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+M 644 :4 index.txt -+""") -+ -+ def test_file_with_changes(self): -+ # Additional things to note: -+ # * from updated to reference parents in the output -+ params = {'include_paths': ['doc/README.txt']} -+ self.assertFiltering(_SAMPLE_WITH_DIR, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 README.txt -+""") -+ -+ def test_subdir(self): -+ params = {'include_paths': ['doc/']} -+ self.assertFiltering(_SAMPLE_WITH_DIR, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 README.txt -+M 644 :4 index.txt -+""") -+ -+ def test_multiple_files_in_subdir(self): -+ # The new root should be the subdrectory -+ params = {'include_paths': ['doc/README.txt', 'doc/index.txt']} -+ self.assertFiltering(_SAMPLE_WITH_DIR, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 README.txt -+M 644 :4 index.txt -+""") -+ -+ -+class TestExcludePaths(TestCaseWithFiltering): -+ -+ def test_file_in_root(self): -+ params = {'exclude_paths': ['NEWS']} -+ self.assertFiltering(_SAMPLE_WITH_DIR, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 doc/README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 doc/README.txt -+M 644 :4 doc/index.txt -+""") -+ -+ def test_file_in_subdir(self): -+ params = {'exclude_paths': ['doc/README.txt']} -+ self.assertFiltering(_SAMPLE_WITH_DIR, params, \ -+"""blob -+mark :2 -+data 17 -+Life -+is -+good ... -+commit refs/heads/master -+mark :101 -+committer a 1234798653 +0000 -+data 8 -+test -+ing -+M 644 :2 NEWS -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :101 -+M 644 :4 doc/index.txt -+""") -+ -+ def test_subdir(self): -+ params = {'exclude_paths': ['doc/']} -+ self.assertFiltering(_SAMPLE_WITH_DIR, params, \ -+"""blob -+mark :2 -+data 17 -+Life -+is -+good ... -+commit refs/heads/master -+mark :101 -+committer a 1234798653 +0000 -+data 8 -+test -+ing -+M 644 :2 NEWS -+""") -+ -+ def test_multple_files(self): -+ params = {'exclude_paths': ['doc/index.txt', 'NEWS']} -+ self.assertFiltering(_SAMPLE_WITH_DIR, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 doc/README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 doc/README.txt -+""") -+ -+ -+class TestIncludeAndExcludePaths(TestCaseWithFiltering): -+ -+ def test_included_dir_and_excluded_file(self): -+ params = {'include_paths': ['doc/'], 'exclude_paths': ['doc/index.txt']} -+ self.assertFiltering(_SAMPLE_WITH_DIR, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 README.txt -+""") -+ -+ -+# A sample input stream creating the following tree: -+# -+# NEWS -+# doc/README.txt -+# doc/index.txt -+# -+# It then renames doc/README.txt => doc/README -+_SAMPLE_WITH_RENAME_INSIDE = _SAMPLE_WITH_DIR + \ -+"""commit refs/heads/master -+mark :103 -+committer d 1234798653 +0000 -+data 10 -+move intro -+from :102 -+R doc/README.txt doc/README -+""" -+ -+# A sample input stream creating the following tree: -+# -+# NEWS -+# doc/README.txt -+# doc/index.txt -+# -+# It then renames doc/README.txt => README -+_SAMPLE_WITH_RENAME_TO_OUTSIDE = _SAMPLE_WITH_DIR + \ -+"""commit refs/heads/master -+mark :103 -+committer d 1234798653 +0000 -+data 10 -+move intro -+from :102 -+R doc/README.txt README -+""" -+ -+# A sample input stream creating the following tree: -+# -+# NEWS -+# doc/README.txt -+# doc/index.txt -+# -+# It then renames NEWS => doc/NEWS -+_SAMPLE_WITH_RENAME_TO_INSIDE = _SAMPLE_WITH_DIR + \ -+"""commit refs/heads/master -+mark :103 -+committer d 1234798653 +0000 -+data 10 -+move intro -+from :102 -+R NEWS doc/NEWS -+""" -+ -+class TestIncludePathsWithRenames(TestCaseWithFiltering): -+ -+ def test_rename_all_inside(self): -+ # These rename commands ought to be kept but adjusted for the new root -+ params = {'include_paths': ['doc/']} -+ self.assertFiltering(_SAMPLE_WITH_RENAME_INSIDE, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 README.txt -+M 644 :4 index.txt -+commit refs/heads/master -+mark :103 -+committer d 1234798653 +0000 -+data 10 -+move intro -+from :102 -+R README.txt README -+""") -+ -+ def test_rename_to_outside(self): -+ # These rename commands become deletes -+ params = {'include_paths': ['doc/']} -+ self.assertFiltering(_SAMPLE_WITH_RENAME_TO_OUTSIDE, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 README.txt -+M 644 :4 index.txt -+commit refs/heads/master -+mark :103 -+committer d 1234798653 +0000 -+data 10 -+move intro -+from :102 -+D README.txt -+""") -+ -+ def test_rename_to_inside(self): -+ # This ought to create a new file but doesn't yet -+ params = {'include_paths': ['doc/']} -+ self.assertFiltering(_SAMPLE_WITH_RENAME_TO_INSIDE, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 README.txt -+M 644 :4 index.txt -+""") -+ -+ -+# A sample input stream creating the following tree: -+# -+# NEWS -+# doc/README.txt -+# doc/index.txt -+# -+# It then copies doc/README.txt => doc/README -+_SAMPLE_WITH_COPY_INSIDE = _SAMPLE_WITH_DIR + \ -+"""commit refs/heads/master -+mark :103 -+committer d 1234798653 +0000 -+data 10 -+move intro -+from :102 -+C doc/README.txt doc/README -+""" -+ -+# A sample input stream creating the following tree: -+# -+# NEWS -+# doc/README.txt -+# doc/index.txt -+# -+# It then copies doc/README.txt => README -+_SAMPLE_WITH_COPY_TO_OUTSIDE = _SAMPLE_WITH_DIR + \ -+"""commit refs/heads/master -+mark :103 -+committer d 1234798653 +0000 -+data 10 -+move intro -+from :102 -+C doc/README.txt README -+""" -+ -+# A sample input stream creating the following tree: -+# -+# NEWS -+# doc/README.txt -+# doc/index.txt -+# -+# It then copies NEWS => doc/NEWS -+_SAMPLE_WITH_COPY_TO_INSIDE = _SAMPLE_WITH_DIR + \ -+"""commit refs/heads/master -+mark :103 -+committer d 1234798653 +0000 -+data 10 -+move intro -+from :102 -+C NEWS doc/NEWS -+""" -+ -+ -+class TestIncludePathsWithCopies(TestCaseWithFiltering): -+ -+ def test_copy_all_inside(self): -+ # These copy commands ought to be kept but adjusted for the new root -+ params = {'include_paths': ['doc/']} -+ self.assertFiltering(_SAMPLE_WITH_COPY_INSIDE, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 README.txt -+M 644 :4 index.txt -+commit refs/heads/master -+mark :103 -+committer d 1234798653 +0000 -+data 10 -+move intro -+from :102 -+C README.txt README -+""") -+ -+ def test_copy_to_outside(self): -+ # This can be ignored -+ params = {'include_paths': ['doc/']} -+ self.assertFiltering(_SAMPLE_WITH_COPY_TO_OUTSIDE, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 README.txt -+M 644 :4 index.txt -+""") -+ -+ def test_copy_to_inside(self): -+ # This ought to create a new file but doesn't yet -+ params = {'include_paths': ['doc/']} -+ self.assertFiltering(_SAMPLE_WITH_COPY_TO_INSIDE, params, \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 README.txt -+M 644 :4 index.txt -+""") -+ -+ -+# A sample input stream with deleteall's creating the following tree: -+# -+# NEWS -+# doc/README.txt -+# doc/index.txt -+_SAMPLE_WITH_DELETEALL = \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+deleteall -+M 644 :1 doc/README.txt -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+deleteall -+M 644 :3 doc/README.txt -+M 644 :4 doc/index.txt -+""" -+ -+ -+class TestIncludePathsWithDeleteAll(TestCaseWithFiltering): -+ -+ def test_deleteall(self): -+ params = {'include_paths': ['doc/index.txt']} -+ self.assertFiltering(_SAMPLE_WITH_DELETEALL, params, \ -+"""blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+deleteall -+M 644 :4 index.txt -+""") -+ -+ -+_SAMPLE_WITH_TAGS = _SAMPLE_WITH_DIR + \ -+"""tag v0.1 -+from :100 -+tagger d 1234798653 +0000 -+data 12 -+release v0.1 -+tag v0.2 -+from :102 -+tagger d 1234798653 +0000 -+data 12 -+release v0.2 -+""" -+ -+class TestIncludePathsWithTags(TestCaseWithFiltering): -+ -+ def test_tag_retention(self): -+ # If a tag references a commit with a parent we kept, -+ # keep the tag but adjust 'from' accordingly. -+ # Otherwise, delete the tag command. -+ params = {'include_paths': ['NEWS']} -+ self.assertFiltering(_SAMPLE_WITH_TAGS, params, \ -+"""blob -+mark :2 -+data 17 -+Life -+is -+good ... -+commit refs/heads/master -+mark :101 -+committer a 1234798653 +0000 -+data 8 -+test -+ing -+M 644 :2 NEWS -+tag v0.2 -+from :101 -+tagger d 1234798653 +0000 -+data 12 -+release v0.2 -+""") -+ -+ -+_SAMPLE_WITH_RESETS = _SAMPLE_WITH_DIR + \ -+"""reset refs/heads/foo -+reset refs/heads/bar -+from :102 -+""" -+ -+class TestIncludePathsWithResets(TestCaseWithFiltering): -+ -+ def test_reset_retention(self): -+ # Resets init'ing a branch (without a from) are passed through. -+ # If a reset references a commit with a parent we kept, -+ # keep the reset but adjust 'from' accordingly. -+ params = {'include_paths': ['NEWS']} -+ self.assertFiltering(_SAMPLE_WITH_RESETS, params, \ -+"""blob -+mark :2 -+data 17 -+Life -+is -+good ... -+commit refs/heads/master -+mark :101 -+committer a 1234798653 +0000 -+data 8 -+test -+ing -+M 644 :2 NEWS -+reset refs/heads/foo -+reset refs/heads/bar -+from :101 -+""") ---- /dev/null -+++ bzr-fastimport-0.10.0+bzr317/tests/test_head_tracking.py -@@ -0,0 +1,257 @@ -+# Copyright (C) 2009 Canonical Ltd -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ -+"""Test tracking of heads""" -+ -+from cStringIO import StringIO -+ -+from bzrlib import tests -+ -+from bzrlib.plugins.fastimport import ( -+ commands, -+ parser, -+ ) -+from bzrlib.plugins.fastimport.cache_manager import CacheManager -+ -+ -+# A sample input stream that only adds files to a branch -+_SAMPLE_MAINLINE = \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 doc/README.txt -+blob -+mark :2 -+data 17 -+Life -+is -+good ... -+commit refs/heads/master -+mark :101 -+committer a 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :2 NEWS -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :101 -+M 644 :3 doc/README.txt -+M 644 :4 doc/index.txt -+""" -+ -+# A sample input stream that adds files to two branches -+_SAMPLE_TWO_HEADS = \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 doc/README.txt -+blob -+mark :2 -+data 17 -+Life -+is -+good ... -+commit refs/heads/mybranch -+mark :101 -+committer a 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :2 NEWS -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 doc/README.txt -+M 644 :4 doc/index.txt -+""" -+ -+# A sample input stream that adds files to two branches -+_SAMPLE_TWO_BRANCHES_MERGED = \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 doc/README.txt -+blob -+mark :2 -+data 17 -+Life -+is -+good ... -+commit refs/heads/mybranch -+mark :101 -+committer a 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :2 NEWS -+blob -+mark :3 -+data 19 -+Welcome! -+my friend -+blob -+mark :4 -+data 11 -+== Docs == -+commit refs/heads/master -+mark :102 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+M 644 :3 doc/README.txt -+M 644 :4 doc/index.txt -+commit refs/heads/master -+mark :103 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :102 -+merge :101 -+D doc/index.txt -+""" -+ -+# A sample input stream that contains a reset -+_SAMPLE_RESET = \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 doc/README.txt -+reset refs/remotes/origin/master -+from :100 -+""" -+ -+# A sample input stream that contains a reset and more commits -+_SAMPLE_RESET_WITH_MORE_COMMITS = \ -+"""blob -+mark :1 -+data 9 -+Welcome! -+commit refs/heads/master -+mark :100 -+committer a 1234798653 +0000 -+data 4 -+test -+M 644 :1 doc/README.txt -+reset refs/remotes/origin/master -+from :100 -+commit refs/remotes/origin/master -+mark :101 -+committer d 1234798653 +0000 -+data 8 -+test -+ing -+from :100 -+D doc/README.txt -+""" -+ -+class TestHeadTracking(tests.TestCase): -+ -+ def assertHeads(self, input, expected): -+ s = StringIO(input) -+ p = parser.ImportParser(s) -+ cm = CacheManager() -+ for cmd in p.iter_commands(): -+ if isinstance(cmd, commands.CommitCommand): -+ cm.track_heads(cmd) -+ # eat the file commands -+ list(cmd.file_iter()) -+ elif isinstance(cmd, commands.ResetCommand): -+ if cmd.from_ is not None: -+ cm.track_heads_for_ref(cmd.ref, cmd.from_) -+ self.assertEqual(cm.heads, expected) -+ -+ def test_mainline(self): -+ self.assertHeads(_SAMPLE_MAINLINE, { -+ ':102': set(['refs/heads/master']), -+ }) -+ -+ def test_two_heads(self): -+ self.assertHeads(_SAMPLE_TWO_HEADS, { -+ ':101': set(['refs/heads/mybranch']), -+ ':102': set(['refs/heads/master']), -+ }) -+ -+ def test_two_branches_merged(self): -+ self.assertHeads(_SAMPLE_TWO_BRANCHES_MERGED, { -+ ':103': set(['refs/heads/master']), -+ }) -+ -+ def test_reset(self): -+ self.assertHeads(_SAMPLE_RESET, { -+ ':100': set(['refs/heads/master', 'refs/remotes/origin/master']), -+ }) -+ -+ def test_reset_with_more_commits(self): -+ self.assertHeads(_SAMPLE_RESET_WITH_MORE_COMMITS, { -+ ':101': set(['refs/remotes/origin/master']), -+ }) ---- /dev/null -+++ bzr-fastimport-0.10.0+bzr317/tests/test_helpers.py -@@ -0,0 +1,56 @@ -+# Copyright (C) 2009 Canonical Ltd -+# -+# This program is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 2 of the License, or -+# (at your option) any later version. -+# -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ -+"""Test the helper functions.""" -+ -+from bzrlib import tests -+ -+from bzrlib.plugins.fastimport import ( -+ helpers, -+ ) -+ -+ -+class TestCommonDirectory(tests.TestCase): -+ -+ def test_no_paths(self): -+ c = helpers.common_directory(None) -+ self.assertEqual(c, None) -+ c = helpers.common_directory([]) -+ self.assertEqual(c, None) -+ -+ def test_one_path(self): -+ c = helpers.common_directory(['foo']) -+ self.assertEqual(c, '') -+ c = helpers.common_directory(['foo/']) -+ self.assertEqual(c, 'foo/') -+ c = helpers.common_directory(['foo/bar']) -+ self.assertEqual(c, 'foo/') -+ -+ def test_two_paths(self): -+ c = helpers.common_directory(['foo', 'bar']) -+ self.assertEqual(c, '') -+ c = helpers.common_directory(['foo/', 'bar']) -+ self.assertEqual(c, '') -+ c = helpers.common_directory(['foo/', 'foo/bar']) -+ self.assertEqual(c, 'foo/') -+ c = helpers.common_directory(['foo/bar/x', 'foo/bar/y']) -+ self.assertEqual(c, 'foo/bar/') -+ c = helpers.common_directory(['foo/bar/aa_x', 'foo/bar/aa_y']) -+ self.assertEqual(c, 'foo/bar/') -+ -+ def test_lots_of_paths(self): -+ c = helpers.common_directory(['foo/bar/x', 'foo/bar/y', 'foo/bar/z']) -+ self.assertEqual(c, 'foo/bar/') diff -Nru bzr-fastimport-0.10.0+bzr317/debian/patches/series bzr-fastimport-0.10.0+bzr324/debian/patches/series --- bzr-fastimport-0.10.0+bzr317/debian/patches/series 2011-05-06 00:58:03.000000000 +0000 +++ bzr-fastimport-0.10.0+bzr324/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -debian-changes-0.10.0+bzr317-3 diff -Nru bzr-fastimport-0.10.0+bzr317/NEWS bzr-fastimport-0.10.0+bzr324/NEWS --- bzr-fastimport-0.10.0+bzr317/NEWS 2011-04-28 12:37:24.000000000 +0000 +++ bzr-fastimport-0.10.0+bzr324/NEWS 2011-06-17 12:09:55.000000000 +0000 @@ -13,6 +13,12 @@ * Setup.py no longer relies on bzrlib. (Jelmer Vernooij, #735201) +* Avoid Inventory.copy, which has disappeared in newer versions of Bazaar. + (Jelmer Vernooij, #485788) + +* Allow "bzr fast-import-filter" to be used without first argument. + (Jelmer Vernooij, #792935) + 0.10 08-Mar-2011 Changes diff -Nru bzr-fastimport-0.10.0+bzr317/revision_store.py bzr-fastimport-0.10.0+bzr324/revision_store.py --- bzr-fastimport-0.10.0+bzr317/revision_store.py 2010-12-11 20:23:22.000000000 +0000 +++ bzr-fastimport-0.10.0+bzr324/revision_store.py 2011-07-20 14:31:09.000000000 +0000 @@ -271,7 +271,7 @@ parent_candidate_entries.keys()) heads = [] for inv in self._rev_parent_invs: - if ie.file_id in inv: + if inv.has_id(ie.file_id): old_rev = inv[ie.file_id].revision if old_rev in head_set: rev_id = inv[ie.file_id].revision diff -Nru bzr-fastimport-0.10.0+bzr317/tests/test_commands.py bzr-fastimport-0.10.0+bzr324/tests/test_commands.py --- bzr-fastimport-0.10.0+bzr317/tests/test_commands.py 2011-04-28 12:26:11.000000000 +0000 +++ bzr-fastimport-0.10.0+bzr324/tests/test_commands.py 2011-06-17 12:09:55.000000000 +0000 @@ -135,3 +135,16 @@ self.build_tree_contents([('file.fi', simple_fast_import_stream)]) data = self.run_bzr("fast-import file.fi br")[0] self.assertEquals(1, tree.branch.revno()) + + +class TestFastImportFilter(ExternalBase): + + def test_empty(self): + self.build_tree_contents([('empty.fi', "")]) + self.make_branch_and_tree("br") + self.assertEquals("", self.run_bzr("fast-import-filter -")[0]) + + def test_default_stdin(self): + self.build_tree_contents([('empty.fi', "")]) + self.make_branch_and_tree("br") + self.assertEquals("", self.run_bzr("fast-import-filter")[0])