Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate

Commit fbd7bd8d36535c9ff93e5b2f4850b6c2727b9062

Persist changed metadata in git

When only the metadata of an entry got changed, gdatastore only
updated the Xapian index but neglected git. This caused the change not
to persist across an index rebuild and not to propagate across
gdatastore instances.

We now store the updated metadata in a new commit with the same ref
name and having the previous ref as parent. This should be enough for
the index rebuild case. It will also propagate nicely through git,
though we don't have code in place yet to notice updated entries
(rather than completely new ones).
  
542542 old_metadata = self._index.retrieve(object_id)['metadata']
543543 metadata['creation_time'] = old_metadata['creation_time']
544544
545 self._update_metadata_in_git(object_id, metadata)
545546 self._index.store(object_id, metadata)
546547 self._invoke_callbacks('change_metadata', object_id, metadata)
547548
815815 return self._git_call('write-tree', index_path=index_path).strip()
816816 finally:
817817 shutil.rmtree(index_dir)
818
819 def _update_metadata_in_git(self, object_id, metadata):
820 commit_message = self._format_commit_message(metadata)
821 tree_hash = self._get_tree_hash(object_id)
822 ref = _format_ref(*object_id)
823 commit_hash = self._git_call('commit-tree', ['-p', ref, tree_hash],
824 input=commit_message).strip()
825 self._git_call('update-ref', [ref, commit_hash])
826
827 def _get_tree_hash(self, object_id):
828 args = ['commit', _format_ref(*object_id)]
829 # First line of output contains tree hash
830 return self._git_call('cat-file', args).split('\n', 1)[0].split(' ')[1]
818831
819832 def _get_object_ids_from_git(self):
820833 args = ['--sort=committerdate', '--format=%(refname)',