136
136
return self._blobs.pop(id)
138
def store_file_id(self, branch_ref, path, id):
139
"""Store the path to file-id mapping for a branch."""
140
key = self._fileid_key(path, branch_ref)
141
self._file_ids[key] = id
143
def fetch_file_id(self, branch_ref, path):
144
"""Lookup the file-id for a path in a branch.
146
Raises KeyError if unsuccessful.
148
key = self._fileid_key(path, branch_ref)
149
return self._file_ids[key]
151
def _fileid_key(self, path, branch_ref):
152
return (path, branch_ref)
154
def delete_path(self, branch_ref, path):
155
"""Remove a path from caches."""
156
# We actually want to remember what file-id we gave a path,
157
# even when that file is deleted, so doing nothing is correct.
158
# It's quite possible for a path to be deleted twice where
159
# the first time is in a merge branch (but the same branch_ref)
160
# and the second time is when that branch is merged to mainline.
163
def rename_path(self, branch_ref, old_path, new_path):
164
"""Rename a path in the caches."""
165
# In this case, we need to forget the file-id we gave a path,
166
# otherwise, we'll get duplicate file-ids in the repository
167
# if a new file is created at the old path.
168
old_key = self._fileid_key(old_path, branch_ref)
169
new_key = self._fileid_key(new_path, branch_ref)
171
old_file_id = self._file_ids[old_key]
173
# The old_key has already been removed, most likely
177
self._file_ids[new_key] = old_file_id
178
del self._file_ids[old_key]
180
138
def track_heads(self, cmd):
181
139
"""Track the repository heads given a CommitCommand.