Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/gdatastore
diff options
context:
space:
mode:
authorSascha Silbe <sascha-pgp@silbe.org>2012-01-21 18:30:53 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2012-01-21 18:30:53 (GMT)
commit0301a9cb26c58124a44202b1adc50aa6a9f086d1 (patch)
tree63882fbde6f997689625aba092ece1f26a51282a /gdatastore
parent22a4cc29fcd609acd04058a93fd304270e26c479 (diff)
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.
Diffstat (limited to 'gdatastore')
-rw-r--r--gdatastore/datastore.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/gdatastore/datastore.py b/gdatastore/datastore.py
index e85cc4f..c0d59d8 100644
--- a/gdatastore/datastore.py
+++ b/gdatastore/datastore.py
@@ -190,7 +190,6 @@ class DBusApiNativeV1(dbus.service.Object):
"""
- add a new version with the given ids
- there must be no existing entry with the same (tree_id, version_id)
- - if parent_id != '' there must be an existing entry (tree_id, parent_id)
- if parent_id = '', there must be no existing entry with the same tree_id and no parent_id
"""
if not tree_id:
@@ -499,10 +498,6 @@ class InternalApi(object):
raise ValueError('No parent_id given but tree_id already '
'exists')
- elif parent_id:
- if not self._index.contains((tree_id, parent_id)):
- raise ValueError('Given parent does not exist')
-
if not tree_id:
tree_id = self._gen_uuid()
@@ -593,8 +588,11 @@ class InternalApi(object):
if not parent_id:
return None
- return self._git_call('rev-parse',
- [_format_ref(tree_id, parent_id)]).strip()
+ try:
+ return self._git_call('rev-parse',
+ [_format_ref(tree_id, parent_id)]).strip()
+ except GitError:
+ return None
def _format_commit_message(self, metadata):
return pprint.pformat(to_native(metadata))