X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/a13dbb38931d9248376d92016d1c457d5a4adbde..e196067aabac55fa0064558e0b8554f7be3419bb:/lib/wlrepo/mercurial_backend/library.py diff --git a/lib/wlrepo/mercurial_backend/library.py b/lib/wlrepo/mercurial_backend/library.py index 7a33bf38..042fda29 100644 --- a/lib/wlrepo/mercurial_backend/library.py +++ b/lib/wlrepo/mercurial_backend/library.py @@ -10,8 +10,8 @@ from mercurial import ui as hgui from mercurial import error import wlrepo -from wlrepo.mercurial_backend.document import MercurialDocument from wlrepo.mercurial_backend import MercurialRevision +from wlrepo.mercurial_backend.document import MercurialDocument class MergeStatus(object): def __init__(self, mstatus): @@ -75,13 +75,14 @@ class MercurialLibrary(wlrepo.Library): @property def ospath(self): - return self._ospath + return self._ospath.decode('utf-8') def document_for_rev(self, revision): if revision is None: raise ValueError("Revision can't be None.") if not isinstance(revision, MercurialRevision): + revision = self._sanitize_string(unicode(revision)) rev = self.get_revision(revision) else: rev = revision @@ -97,25 +98,25 @@ class MercurialLibrary(wlrepo.Library): def get_revision(self, revid): revid = self._sanitize_string(revid) - - ctx = self._changectx(revid) + + try: + ctx = self._changectx(revid) + except mercurial.error.RepoError, e: + raise wlrepo.RevisionNotFound(revid) if ctx is None: - raise RevisionNotFound(revid) + raise wlrepo.RevisionNotFound(revid) if self._revcache.has_key(ctx): return self._revcache[ctx] return MercurialRevision(self, ctx) - def fulldocid(self, docid, user=None): - docid = self._sanitize_string(docid) - user = self._sanitize_string(user) - - fulldocid = '' + def fulldocid(self, docid, user=None): + fulldocid = u'' if user is not None: - fulldocid += '$user:' + user - fulldocid += '$doc:' + docid + fulldocid += u'$user:' + user + fulldocid += u'$doc:' + docid return fulldocid @@ -123,20 +124,20 @@ class MercurialLibrary(wlrepo.Library): try: self._hgrepo[revid] return True - except error.RepoError: + except mercurial.error.RepoError: return False def document_create(self, docid): - docid = self._sanitize_string(docid) + # check if it already exists fullid = self.fulldocid(docid) if self.has_revision(fullid): - raise wlrepo.DocumentAlreadyExists("Document %s already exists!" % docid); + raise wlrepo.DocumentAlreadyExists(u"Document %s already exists!" % docid); # doesn't exist - self._create_branch(fullid) + self._create_branch(self._sanitize_string(fullid)) return self.document_for_rev(fullid) #