summaryrefslogtreecommitdiff
path: root/revision_store.py
diff options
context:
space:
mode:
authorJohn Arbash Meinel <john@arbash-meinel.com>2009-12-09 14:14:46 -0600
committerJohn Arbash Meinel <john@arbash-meinel.com>2009-12-09 14:14:46 -0600
commit5ff6d451b0f69149b4fba0e98abdfbc8c584fa79 (patch)
treeba6c84955d5ce0ee424722df0696506c3de444c5 /revision_store.py
parent768639fa20a03ad421e2a7c0098de6fd3391b484 (diff)
downloadbzr-fastimport-5ff6d451b0f69149b4fba0e98abdfbc8c584fa79.tar.gz
Add a bunch of direct tests for the _TreeShim interface.
Diffstat (limited to 'revision_store.py')
-rw-r--r--revision_store.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/revision_store.py b/revision_store.py
index 0488b0e..be98bb7 100644
--- a/revision_store.py
+++ b/revision_store.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2008 Canonical Ltd
+# Copyright (C) 2008, 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
@@ -40,10 +40,16 @@ class _TreeShim(object):
if file_id in self._new_info_by_id:
new_path = self._new_info_by_id[file_id][0]
if new_path is None:
- raise errors.NoSuchId()
+ raise errors.NoSuchId(self, file_id)
+ return new_path
return self._basis_inv.id2path(file_id)
def path2id(self, path):
+ # CommitBuilder currently only requires access to the root id. We don't
+ # build a map of renamed files, etc. One possibility if we ever *do*
+ # need more than just root, is to defer to basis_inv.path2id() and then
+ # check if the file_id is in our _new_info_by_id dict. And in that
+ # case, return _new_info_by_id[file_id][0]
if path != '':
raise NotImplementedError(_TreeShim.path2id)
# TODO: Handle root renames?
@@ -72,7 +78,6 @@ class _TreeShim(object):
def get_reference_revision(self, file_id, path=None):
raise NotImplementedError(_TreeShim.get_reference_revision)
-
def _delta_to_iter_changes(self):
"""Convert the inv_delta into an iter_changes repr."""
# iter_changes is:
@@ -87,6 +92,9 @@ class _TreeShim(object):
# )
basis_inv = self._basis_inv
for old_path, new_path, file_id, ie in self._inv_delta:
+ # Perf: Would this be faster if we did 'if file_id in basis_inv'?
+ # Since the *very* common case is that the file already exists, it
+ # probably is better to optimize for that
try:
old_ie = basis_inv[file_id]
except errors.NoSuchId:
@@ -126,6 +134,7 @@ class _TreeShim(object):
content_modified = (ie.text_sha1 != old_ie.text_sha1
or ie.text_size != old_ie.text_size)
# TODO: ie.kind != old_ie.kind
+ # TODO: symlinks changing targets, content_modified?
change = (file_id,
(old_path, new_path),
content_modified,