Merge branch 'master' of stigma.nowoczesnapolska.org.pl:platforma
[redakcja.git] / lib / wlrepo / mercurial_backend / document.py
index 3bd26a6..9a2c2aa 100755 (executable)
@@ -103,7 +103,7 @@ class MercurialDocument(wlrepo.Document):
             self.invoke_and_commit(take_action, \
                 lambda d: ("$AUTO$ File checkout.", user) )
 
             self.invoke_and_commit(take_action, \
                 lambda d: ("$AUTO$ File checkout.", user) )
 
-        return self._library.document_for_rev(fullid)
+        return self._library.document_for_revision(fullid)
 
     def up_to_date(self):
         if self.ismain():
 
     def up_to_date(self):
         if self.ismain():
@@ -168,13 +168,13 @@ class MercurialDocument(wlrepo.Document):
 
     def would_share(self):
         if self.ismain():
 
     def would_share(self):
         if self.ismain():
-            return False
+            return False, "Main version is always shared"
 
         shared = self.shared()
 
         # we just did this - move on
         if self.parentof(shared):
 
         shared = self.shared()
 
         # we just did this - move on
         if self.parentof(shared):
-            return False
+            return False, "Document has been recetly shared - no changes"
 
         #     *
         #    /|
 
         #     *
         #    /|
@@ -191,13 +191,17 @@ class MercurialDocument(wlrepo.Document):
         #   | |
         # We want to prevent stuff like this.
         if self.parent().parentof(shared):
         #   | |
         # We want to prevent stuff like this.
         if self.parent().parentof(shared):
-            return False
+            return False, "Preventing zig-zag"
+
+        return True, "OK"
+
 
     def share(self, message):
         lock = self.library.lock()
         try:
 
     def share(self, message):
         lock = self.library.lock()
         try:
+            result, info = self.would_share()
 
 
-            if not self.would_share():
+            if not result:
                 return self.shared()          
       
             # The good situation
                 return self.shared()          
       
             # The good situation
@@ -209,6 +213,8 @@ class MercurialDocument(wlrepo.Document):
             #       / |
             # main *  *
             #      |  |
             #       / |
             # main *  *
             #      |  |
+            shared = self.shared()
+
             if shared.ancestorof(self):               
                 success = shared._revision.merge_with(self._revision, user=self.owner, message=message)
 
             if shared.ancestorof(self):               
                 success = shared._revision.merge_with(self._revision, user=self.owner, message=message)