At http://people.samba.org/bzr/jelmer/bzr-svn/0.5
------------------------------------------------------------ revno: 2307 revision-id: [email protected] parent: [email protected] committer: Jelmer Vernooij <[email protected]> branch nick: 0.5 timestamp: Thu 2009-01-15 01:57:29 +0100 message: Add function for checking inventory delta. modified: fetch.py fetch.py-20060625004942-x2lfaib8ra707a8p-1 === modified file 'fetch.py' --- a/fetch.py 2008-12-16 01:26:33 +0000 +++ b/fetch.py 2009-01-15 00:57:29 +0000 @@ -43,6 +43,27 @@ FETCH_COMMIT_WRITE_SIZE = 500 + +def check_inventory_delta(delta): + """Check the internal consistency of an inventory delta. + + :param delta: An inventory delta + """ + old_paths = set() + new_paths = set() + file_ids = set() + for (old_path, new_path, file_id, ie) in delta: + if old_path is not None and old_path in old_paths: + raise AssertionError("new path %s exists more than once" % old_path) + if new_path is not None and new_path in new_paths: + raise AssertionError("old path %s exists more than once" % new_path) + if file_id in file_ids: + raise AssertionError("file id %s exists more than once" % file_id) + old_paths.add(old_path) + new_paths.add(new_path) + file_ids.add(file_id) + + def md5_strings(strings): """Return the MD5sum of the concatenation of strings. @@ -508,6 +529,8 @@ [r for r in rev.parent_ids if self.target.has_revision(r)]) else: self.inventory = self.old_inventory + if "check" in debug.debug_flags: + check_inventory_delta(self._inv_delta) self.inventory.apply_delta(self._inv_delta) self.inventory.revision_id = rev.revision_id -- bazaar-commits mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/bazaar-commits
