X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/de93104a2513acc5a378496c6bf6ab7ed0d45d60..10fe016074c5af0f8e0464eb3191e868f108a65e:/lib/wlrepo/__init__.py diff --git a/lib/wlrepo/__init__.py b/lib/wlrepo/__init__.py old mode 100644 new mode 100755 index 430e59f9..ed0998cf --- a/lib/wlrepo/__init__.py +++ b/lib/wlrepo/__init__.py @@ -14,11 +14,11 @@ class Library(object): """List all documents in the library.""" pass - def document_for_rev(self, rev): + def document_for_revision(self, rev): """Retrieve a document in the specified revision.""" pass - def document(self, docid, user=None): + def document(self, docid, user=None, rev='latest'): """Retrieve a document from a library.""" pass @@ -73,6 +73,12 @@ class Document(object): def parentof(self, other): return self._revision.parentof(other._revision) + def parent(self): + return self._library.document_for_revision(self._revision.parent()) + + def has_parent_from(self, other): + return self._revision.has_parent_from(other._revision) + def ancestorof(self, other): return self._revision.ancestorof(other._revision) @@ -105,9 +111,19 @@ class LibraryException(Exception): Exception.__init__(self, msg) self.cause = cause +class UpdateException(LibraryException): + pass + +class OutdatedException(LibraryException): + pass + class RevisionNotFound(LibraryException): def __init__(self, rev): LibraryException.__init__(self, "Revision %r not found." % rev) + +class RevisionMismatch(LibraryException): + def __init__(self, fdi, rev): + LibraryException.__init__(self, "No revision %r for document %r." % (rev, fdi)) class EntryNotFound(LibraryException): def __init__(self, rev, entry, guesses=[]): @@ -122,7 +138,7 @@ class DocumentAlreadyExists(LibraryException): def open_library(path, proto, *args, **kwargs): if proto == 'hg': - import wlrepo.mercurial_backend - return wlrepo.mercurial_backend.MercurialLibrary(path, *args, **kwargs) + import wlrepo.mercurial_backend.library + return wlrepo.mercurial_backend.library.MercurialLibrary(path, *args, **kwargs) raise NotImplemented() \ No newline at end of file