Raise proper exception when lightweight checkout is out of date during commit.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 22 Oct 2007 18:42:08 +0000 (20:42 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 22 Oct 2007 18:42:08 +0000 (20:42 +0200)
NEWS
tests/test_workingtree.py
workingtree.py

diff --git a/NEWS b/NEWS
index 9c178fcfcb4540e438ee684654a91120c037d20b..4a8702c91a580301c26d8acdbe8aa4ea17c8823f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,8 @@ bzr-svn 0.4.4 UNRELEASED
 
    * Don't print traceback when raising errors about bzr versions.
 
+   * Show proper exception when lightweight checkout is out of date.
+
   DOCUMENTATION
 
    * Add simple FAQ file. (#144388)
index 79c0218952fdca19f04af2e00ffee42abba5a1d4..44219c236b9714d762940af9e7dd236a41a7c90e 100644 (file)
@@ -17,7 +17,7 @@
 """Working tree tests."""
 
 from bzrlib.bzrdir import BzrDir
-from bzrlib.errors import NoSuchFile
+from bzrlib.errors import NoSuchFile, OutOfDateTree
 from bzrlib.inventory import Inventory
 from bzrlib.tests import KnownFailure
 from bzrlib.trace import mutter
@@ -625,3 +625,16 @@ class TestWorkingTree(TestCaseWithSubversionRepository):
         tree.commit("message")
         self.assertEqual(None, tree.branch.nick)
 
+    def test_out_of_date(self):
+        repos_url = self.make_client('a', 'dc')
+        self.build_tree({'dc/some strange file': 'data'})
+        self.client_add("dc/some strange file")
+        self.client_commit("dc", "msg")
+        self.client_update("dc")
+        self.make_checkout(repos_url, 'de')
+        self.build_tree({'dc/some strange file': 'data-x'})
+        self.client_commit("dc", "msg")
+        self.client_update("dc")
+        tree = self.open_checkout("de")
+        self.build_tree({'de/some strange file': 'data-y'})
+        self.assertRaises(OutOfDateTree, lambda: tree.commit("bar"))
index b8fc64a7d97d8797380eddecb2e93e9cbe99cc9d..6b7a43fc68c03c8c0aa2050ae3b9fa05f5884a90 100644 (file)
@@ -20,7 +20,8 @@ from bzrlib import urlutils
 from bzrlib.branch import PullResult
 from bzrlib.bzrdir import BzrDirFormat, BzrDir
 from bzrlib.errors import (InvalidRevisionId, NotBranchError, NoSuchFile,
-                           NoRepositoryPresent, BzrError, UninitializableFormat)
+                           NoRepositoryPresent, BzrError, UninitializableFormat,
+                           OutOfDateTree)
 from bzrlib.inventory import Inventory, InventoryFile, InventoryLink
 from bzrlib.lockable_files import TransportLock, LockableFiles
 from bzrlib.lockdir import LockDir
@@ -449,8 +450,13 @@ class SvnWorkingTree(WorkingTree):
             svn.wc.adm_close(wc)
 
         try:
-            commit_info = svn.client.commit3(specific_files, True, False, 
-                                         self.client_ctx)
+            try:
+                commit_info = svn.client.commit3(specific_files, True, False, 
+                                                 self.client_ctx)
+            except SubversionException, (_, num):
+                if num == svn.core.SVN_ERR_FS_TXN_OUT_OF_DATE:
+                    raise OutOfDateTree(self)
+                raise
         except:
             # Reset properties so the next subversion commit won't 
             # accidently set these properties.