fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'view-refactor' of stigma:platforma into zuber-view-refactor
[redakcja.git]
/
lib
/
wlrepo
/
mercurial_backend
/
document.py
diff --git
a/lib/wlrepo/mercurial_backend/document.py
b/lib/wlrepo/mercurial_backend/document.py
index
c7f2f9f
..
51a2014
100644
(file)
--- a/
lib/wlrepo/mercurial_backend/document.py
+++ b/
lib/wlrepo/mercurial_backend/document.py
@@
-15,6
+15,14
@@
class MercurialDocument(wlrepo.Document):
def quickwrite(self, entry, data, msg, user=None):
user = user or self.owner
def quickwrite(self, entry, data, msg, user=None):
user = user or self.owner
+
+ if isinstance(data, unicode):
+ data = data.encode('utf-8')
+
+ user = self._library._sanitize_string(user)
+ msg = self._library._sanitize_string(msg)
+ entry = self._library._sanitize_string(entry)
+
if user is None:
raise ValueError("Can't determine user.")
if user is None:
raise ValueError("Can't determine user.")
@@
-24,10
+32,10
@@
class MercurialDocument(wlrepo.Document):
f.close()
l._fileadd(r(entry))
f.close()
l._fileadd(r(entry))
- return self.invoke_and_commit(write, lambda d: (msg,
us
er))
+ return self.invoke_and_commit(write, lambda d: (msg,
self.own
er))
def invoke_and_commit(self, ops,
def invoke_and_commit(self, ops,
-
before_commit, rollback=False
):
+
commit_info
):
lock = self._library.lock()
try:
self._library._checkout(self._revision.hgrev())
lock = self._library.lock()
try:
self._library._checkout(self._revision.hgrev())
@@
-36,9
+44,14
@@
class MercurialDocument(wlrepo.Document):
return self.id + '.' + entry
ops(self._library, entry_path)
return self.id + '.' + entry
ops(self._library, entry_path)
- message, user =
before_commit(self)
+ message, user =
commit_info(self)
self._library._commit(message, user)
self._library._commit(message, user)
- return self._library.document(docid=self.id, user=self.owner)
+ try:
+ return self._library.document(docid=self.id, user=user)
+ except Exception, e:
+ # rollback the last commit
+ self._library._rollback()
+ raise e
finally:
lock.release()
finally:
lock.release()
@@
-47,7
+60,7
@@
class MercurialDocument(wlrepo.Document):
# self.invoke_and_commit(message, user, lambda *a: True)
def ismain(self):
# self.invoke_and_commit(message, user, lambda *a: True)
def ismain(self):
- return self._revision.user_name
()
is None
+ return self._revision.user_name is None
def shared(self):
if self.ismain():
def shared(self):
if self.ismain():
@@
-98,7
+111,7
@@
class MercurialDocument(wlrepo.Document):
if self.ismain():
return (True, False) # always shared
if self.ismain():
return (True, False) # always shared
- user = self._revision.user_name
()
+ user = self._revision.user_name
main = self.shared()._revision
local = self._revision
main = self.shared()._revision
local = self._revision