fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed the print view.
[redakcja.git]
/
lib
/
wlrepo
/
mercurial_backend
/
library.py
diff --git
a/lib/wlrepo/mercurial_backend/library.py
b/lib/wlrepo/mercurial_backend/library.py
old mode 100644
(file)
new mode 100755
(executable)
index
ebb38d8
..
5e9b06e
--- a/
lib/wlrepo/mercurial_backend/library.py
+++ b/
lib/wlrepo/mercurial_backend/library.py
@@
-1,5
+1,8
@@
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-
+import logging
+log = logging.getLogger('ral.mercurial')
+
__author__= "Łukasz Rekucki"
__date__ = "$2009-09-25 09:33:02$"
__doc__ = "Module documentation."
__author__= "Łukasz Rekucki"
__date__ = "$2009-09-25 09:33:02$"
__doc__ = "Module documentation."
@@
-10,7
+13,7
@@
from mercurial import ui as hgui
from mercurial import error
import wlrepo
from mercurial import error
import wlrepo
-from wlrepo.mercurial_backend import MercurialRevision
+from wlrepo.mercurial_backend
.revision
import MercurialRevision
from wlrepo.mercurial_backend.document import MercurialDocument
class MergeStatus(object):
from wlrepo.mercurial_backend.document import MercurialDocument
class MergeStatus(object):
@@
-77,7
+80,7
@@
class MercurialLibrary(wlrepo.Library):
def ospath(self):
return self._ospath.decode('utf-8')
def ospath(self):
return self._ospath.decode('utf-8')
- def document_for_rev(self, revision):
+ def document_for_rev
ision
(self, revision):
if revision is None:
raise ValueError("Revision can't be None.")
if revision is None:
raise ValueError("Revision can't be None.")
@@
-92,19
+95,25
@@
class MercurialLibrary(wlrepo.Library):
# every revision is a document
return self._doccache[str(rev)]
# every revision is a document
return self._doccache[str(rev)]
- def document(self, docid, user=None):
- return self.document_for_rev(self.fulldocid(docid, user))
+ def document(self, docid, user=None, rev=u'latest'):
+ rev = self._sanitize_string(rev)
+
+ if rev != u'latest':
+ doc = self.document_for_revision(rev)
- def get_revision(self, revid):
- revid = self._sanitize_string(revid).decode('utf-8')
+ if doc.id != docid or (doc.owner != user):
+ raise wlrepo.RevisionMismatch(self.fulldocid(docid, user)+u'@'+unicode(rev))
+
+ return doc
+ else:
+ return self.document_for_revision(self.fulldocid(docid, user))
- print "Looking up rev %r (%s)" %(revid, type(revid))
+ def get_revision(self, revid):
+ revid = self._sanitize_string(revid)
- try:
- # THIS IS THE MOST BRAIN-DEAD API I EVER SEEN
- # WHY DO ALL THE OTHER METHODS SIMPLY
- # FAIL WHEN GIVEN UNICODE, WHEN THIS WORKS ONLY!! WITH IT
+ log.info("Looking up rev %r (%s)" %(revid, type(revid)) )
+ try:
ctx = self._changectx( revid )
except mercurial.error.RepoError, e:
raise wlrepo.RevisionNotFound(revid)
ctx = self._changectx( revid )
except mercurial.error.RepoError, e:
raise wlrepo.RevisionNotFound(revid)
@@
-112,9
+121,12
@@
class MercurialLibrary(wlrepo.Library):
if ctx is None:
raise wlrepo.RevisionNotFound(revid)
if ctx is None:
raise wlrepo.RevisionNotFound(revid)
+ return self._revision(ctx)
+
+ def _revision(self, ctx):
if self._revcache.has_key(ctx):
return self._revcache[ctx]
if self._revcache.has_key(ctx):
return self._revcache[ctx]
-
+
return MercurialRevision(self, ctx)
def fulldocid(self, docid, user=None):
return MercurialRevision(self, ctx)
def fulldocid(self, docid, user=None):
@@
-125,14
+137,15
@@
class MercurialLibrary(wlrepo.Library):
return fulldocid
def has_revision(self, revid):
return fulldocid
def has_revision(self, revid):
+ revid = self._sanitize_string(revid)
+
try:
self._hgrepo[revid]
return True
except mercurial.error.RepoError:
return False
try:
self._hgrepo[revid]
return True
except mercurial.error.RepoError:
return False
- def document_create(self, docid):
-
+ def document_create(self, docid):
# check if it already exists
fullid = self.fulldocid(docid)
# check if it already exists
fullid = self.fulldocid(docid)
@@
-142,7
+155,7
@@
class MercurialLibrary(wlrepo.Library):
# doesn't exist
self._create_branch(self._sanitize_string(fullid))
# doesn't exist
self._create_branch(self._sanitize_string(fullid))
- return self.document_for_rev(fullid)
+ return self.document_for_rev
ision
(fullid)
#
# Private methods
#
# Private methods
@@
-224,7
+237,7
@@
class MercurialLibrary(wlrepo.Library):
name = self._sanitize_string(name)
return self._hgrepo.branchtags()[name]
name = self._sanitize_string(name)
return self._hgrepo.branchtags()[name]
- def _create_branch(self, name, parent=None, before_commit=None):
+ def _create_branch(self, name, parent=None, before_commit=None
, message=None
):
name = self._sanitize_string(name)
if self._has_branch(name): return # just exit
name = self._sanitize_string(name)
if self._has_branch(name): return # just exit
@@
-235,11
+248,16
@@
class MercurialLibrary(wlrepo.Library):
parentrev = parent.hgrev()
self._checkout(parentrev)
parentrev = parent.hgrev()
self._checkout(parentrev)
- self._
hgrepo.dirstate.setbranch
(name)
+ self._
set_branchname
(name)
if before_commit: before_commit(self)
if before_commit: before_commit(self)
- self._commit("$ADMN$ Initial commit for branch '%s'." % name, user='$library')
+ message = message or "$ADMN$ Initial commit for branch '%s'." % name
+ self._commit(message, user='$library')
+
+ def _set_branchname(self, name):
+ name = self._sanitize_string(name)
+ self._hgrepo.dirstate.setbranch(name)
def _switch_to_branch(self, branchname):
current = self._hgrepo[None].branch()
def _switch_to_branch(self, branchname):
current = self._hgrepo[None].branch()