From bc6564ec6e788e07f105003db9da73413ffffa50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Rekucki?= Date: Tue, 29 Sep 2009 17:07:16 +0200 Subject: [PATCH] Fixed update logging. --- apps/api/handlers/library_handlers.py | 4 +++- lib/wlrepo/mercurial_backend/__init__.py | 4 +++- lib/wlrepo/mercurial_backend/document.py | 13 +++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/api/handlers/library_handlers.py b/apps/api/handlers/library_handlers.py index f0ce1863..b2ff94b4 100644 --- a/apps/api/handlers/library_handlers.py +++ b/apps/api/handlers/library_handlers.py @@ -507,7 +507,9 @@ class MergeHandler(BaseHandler): success, changed = udoc.share(form.cleaned_data['message']) if not success: - return response.EntityConflict().django_response({}) + return response.EntityConflict().django_response({ + 'reason': 'merge-failure', + }) if not changed: return response.SuccessNoContent().django_response() diff --git a/lib/wlrepo/mercurial_backend/__init__.py b/lib/wlrepo/mercurial_backend/__init__.py index 20a39e5d..f0d3d076 100644 --- a/lib/wlrepo/mercurial_backend/__init__.py +++ b/lib/wlrepo/mercurial_backend/__init__.py @@ -73,7 +73,9 @@ class MercurialRevision(wlrepo.Revision): return (a.branch() == self._changectx.branch()) def has_children(self): - return bool( self._library._hgrepo.changelog.children(self.hgrev()) ) + children = self._library._hgrepo.changelog.children(self.hgrev()) + print "C:", children, bool(children) + return bool(children) def merge_with(self, other, user, message): lock = self._library.lock(True) diff --git a/lib/wlrepo/mercurial_backend/document.py b/lib/wlrepo/mercurial_backend/document.py index 3f94097a..fcfd14c4 100644 --- a/lib/wlrepo/mercurial_backend/document.py +++ b/lib/wlrepo/mercurial_backend/document.py @@ -98,15 +98,20 @@ class MercurialDocument(wlrepo.Document): return (True, False) if self._revision.has_children(): + print 'Update failed: has children.' # can't update non-latest revision return (False, False) sv = self.shared() - - if not sv.ancestorof(self) and not self.parentof(sv): - return self._revision.merge_with(sv._revision, user=user) - return (False, False) + if self.parentof(sv): + return (True, False) + + if sv.ancestorof(self): + return (True, False) + + + return self._revision.merge_with(sv._revision, user=user) finally: lock.release() -- 2.20.1