Rev 3227: Port across errors for shallow branch support. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

Robert Collins robertc at robertcollins.net
Wed Feb 20 00:23:22 GMT 2008


At http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

------------------------------------------------------------
revno: 3227
revision-id:robertc at robertcollins.net-20080220002317-5bdinlaczri004x2
parent: robertc at robertcollins.net-20080219041134-03amd7siou1c8ugw
committer: Robert Collins <robertc at robertcollins.net>
branch nick: errors
timestamp: Wed 2008-02-20 11:23:17 +1100
message:
  Port across errors for shallow branch support.
modified:
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2008-02-12 02:13:43 +0000
+++ b/bzrlib/errors.py	2008-02-20 00:23:17 +0000
@@ -185,6 +185,13 @@
     _fmt = "The tree builder is already building a tree."
 
 
+class BranchError(BzrError):
+    """Base class for concrete 'errors about a branch'."""
+
+    def __init__(self, branch):
+        BzrError.__init__(self, branch=branch)
+
+
 class BzrCheckError(InternalBzrError):
     
     _fmt = "Internal check failed: %(message)s"
@@ -305,6 +312,11 @@
         BzrError.__init__(self, repository=repository, file_id=file_id)
 
 
+class NotStacked(BranchError):
+
+    _fmt = "The branch '%(branch)s' is not stacked."
+
+
 class InventoryModified(InternalBzrError):
 
     _fmt = ("The current inventory for the tree %(tree)r has been modified,"
@@ -561,6 +573,28 @@
         PathError.__init__(self, url, extra=extra)
 
 
+class UnstackableBranchFormat(BzrError):
+
+    _fmt = ("The branch '%(url)s'(%(format)s) is not a stackable format. "
+        "You will need to upgrade the branch to permit branch stacking.")
+
+    def __init__(self, format, url):
+        BzrError.__init__(self)
+        self.format = format
+        self.url = url
+
+
+class UnstackableRepositoryFormat(BzrError):
+
+    _fmt = ("The repository '%(url)s'(%(format)s) is not a stackable format. "
+        "You will need to upgrade the repository to permit branch stacking.")
+
+    def __init__(self, format, url):
+        BzrError.__init__(self)
+        self.format = format
+        self.url = url
+
+
 class ReadError(PathError):
     
     _fmt = """Error reading from %(path)r."""
@@ -1164,13 +1198,10 @@
         self.bases = bases
 
 
-class NoCommits(BzrError):
+class NoCommits(BranchError):
 
     _fmt = "Branch %(branch)s has no commits."
 
-    def __init__(self, branch):
-        BzrError.__init__(self, branch=branch)
-
 
 class UnlistableStore(BzrError):
 

=== modified file 'bzrlib/tests/test_errors.py'
--- a/bzrlib/tests/test_errors.py	2008-02-13 01:42:47 +0000
+++ b/bzrlib/tests/test_errors.py	2008-02-20 00:23:17 +0000
@@ -174,6 +174,11 @@
                              " tree atree.", str(error))
         self.assertIsInstance(error, errors.NoSuchRevision)
 
+    def test_not_stacked(self):
+        error = errors.NotStacked('a branch')
+        self.assertEqualDiff("The branch 'a branch' is not stacked.",
+            str(error))
+
     def test_not_write_locked(self):
         error = errors.NotWriteLocked('a thing to repr')
         self.assertEqualDiff("'a thing to repr' is not write locked but needs "
@@ -209,6 +214,24 @@
             " of bzrlib.",
             str(error))
 
+    def test_unstackable_branch_format(self):
+        format = u'foo'
+        url = "/foo"
+        error = errors.UnstackableBranchFormat(format, url)
+        self.assertEqualDiff(
+            "The branch '/foo'(foo) is not a stackable format. "
+            "You will need to upgrade the branch to permit branch stacking.",
+            str(error))
+
+    def test_unstackable_repository_format(self):
+        format = u'foo'
+        url = "/foo"
+        error = errors.UnstackableRepositoryFormat(format, url)
+        self.assertEqualDiff(
+            "The repository '/foo'(foo) is not a stackable format. "
+            "You will need to upgrade the repository to permit branch stacking.",
+            str(error))
+
     def test_up_to_date(self):
         error = errors.UpToDateFormat(bzrdir.BzrDirFormat4())
         self.assertEqualDiff("The branch format Bazaar-NG branch, "



More information about the bazaar-commits mailing list