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

Commit 0301a9cb26c58124a44202b1adc50aa6a9f086d1

Allow restoring orphan versions

In order to support removing intermediate versions (on explicit user action or
as part of automatic space reduction) we should not require the parent version
to exist when restoring versions from backup.

At least the Restore activity needs to be careful to never restore the child
before the parent, otherwise we'd loose information in git (the parent
commit id) that would have been recoverable. The previous check in restore()
would have caught that, but also prevents restoring from backups which are
missing intermediate versions (because they have been deleted).

Alternatives:
* Let gdatastore (and thus Backup) store "fake" intermediate
  versions on delete.
  • Diff rendering mode:
  • inline
  • side by side

gdatastore/datastore.py

190 """190 """
191 - add a new version with the given ids191 - add a new version with the given ids
192 - there must be no existing entry with the same (tree_id, version_id)192 - there must be no existing entry with the same (tree_id, version_id)
193 - if parent_id != '' there must be an existing entry (tree_id, parent_id)
194 - if parent_id = '', there must be no existing entry with the same tree_id and no parent_id193 - if parent_id = '', there must be no existing entry with the same tree_id and no parent_id
195 """194 """
196 if not tree_id:195 if not tree_id:
498 raise ValueError('No parent_id given but tree_id already '498 raise ValueError('No parent_id given but tree_id already '
499 'exists')499 'exists')
500500
501 elif parent_id:
502 if not self._index.contains((tree_id, parent_id)):
503 raise ValueError('Given parent does not exist')
504
505 if not tree_id:501 if not tree_id:
506 tree_id = self._gen_uuid()502 tree_id = self._gen_uuid()
507503
588 if not parent_id:588 if not parent_id:
589 return None589 return None
590590
591 return self._git_call('rev-parse',
592 [_format_ref(tree_id, parent_id)]).strip()
591 try:
592 return self._git_call('rev-parse',
593 [_format_ref(tree_id, parent_id)]).strip()
594 except GitError:
595 return None
593596
594 def _format_commit_message(self, metadata):597 def _format_commit_message(self, metadata):
595 return pprint.pformat(to_native(metadata))598 return pprint.pformat(to_native(metadata))