X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/9bec1deeed00ac693e6031c69f0778d3bb0dfbd9..c5d631fe1a261b311725696eae54a55c68d674a8:/lib/wlrepo/mercurial_backend/library.py diff --git a/lib/wlrepo/mercurial_backend/library.py b/lib/wlrepo/mercurial_backend/library.py index 648ebe90..f033fce0 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): @@ -70,18 +70,18 @@ class MercurialLibrary(wlrepo.Library): def documents(self): - return [ key[5:] for key in \ + return [ key[5:].decode('utf-8') for key in \ self._hgrepo.branchmap() if key.startswith("$doc:") ] @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): + if not isinstance(revision, MercurialRevision): rev = self.get_revision(revision) else: rev = revision @@ -111,14 +111,11 @@ class MercurialLibrary(wlrepo.Library): 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 @@ -130,16 +127,16 @@ class MercurialLibrary(wlrepo.Library): 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) #