X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/352b8591bd1c7163835a6fa1db34d3e2861c1071..4a1d358fcc56a21796d35c8486e0ae6043220fd7:/lib/wlrepo/__init__.py diff --git a/lib/wlrepo/__init__.py b/lib/wlrepo/__init__.py index cbc0c2c6..f8c07c68 100644 --- a/lib/wlrepo/__init__.py +++ b/lib/wlrepo/__init__.py @@ -18,7 +18,7 @@ class Library(object): """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 @@ -51,7 +51,7 @@ class Document(object): Should be called on the user version of document. If not, it doesn nothing.""" def data(self, entry): - """Returns the specified entry as a file-like object.""" + """Returns the specified entry as a unicode data.""" pass @property @@ -73,6 +73,9 @@ class Document(object): def parentof(self, other): return self._revision.parentof(other._revision) + 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,10 +108,31 @@ class LibraryException(Exception): Exception.__init__(self, msg) self.cause = cause +class UpdateException(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=[]): + LibraryException.__init__(self, \ + u"Entry '%s' at revision %r not found. %s" % (entry, rev, \ + (u"Posible values:\n" + u',\n'.join(guesses)) if len(guesses) else u'') ) + +class DocumentAlreadyExists(LibraryException): pass # import backends to local namespace -from mercurial_backend.library import MercurialLibrary \ No newline at end of file + +def open_library(path, proto, *args, **kwargs): + if proto == 'hg': + import wlrepo.mercurial_backend.library + return wlrepo.mercurial_backend.library.MercurialLibrary(path, *args, **kwargs) + + raise NotImplemented() \ No newline at end of file