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.
  
190190 """
191191 - add a new version with the given ids
192192 - 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)
194193 - if parent_id = '', there must be no existing entry with the same tree_id and no parent_id
195194 """
196195 if not tree_id:
498498 raise ValueError('No parent_id given but tree_id already '
499499 '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
505501 if not tree_id:
506502 tree_id = self._gen_uuid()
507503
588588 if not parent_id:
589589 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
594597 def _format_commit_message(self, metadata):
595598 return pprint.pformat(to_native(metadata))