Rev 6291: (jelmer) Move patches exceptions to bzrlib.errors. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Nov 24 17:25:42 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6291 [merge]
revision-id: pqm at pqm.ubuntu.com-20111124172541-3y61o9wf6onqh84q
parent: pqm at pqm.ubuntu.com-20111124170047-qe7trqwbvwkroky6
parent: jelmer at samba.org-20111124154318-trbu4wnbmve2xt88
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2011-11-24 17:25:41 +0000
message:
(jelmer) Move patches exceptions to bzrlib.errors. (Jelmer Vernooij)
modified:
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/patches.py patches.py-20050727183609-378c1cc5972ce908
bzrlib/shelf_ui.py shelver.py-20081005210102-33worgzwrtdw0yrm-1
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2011-11-11 12:08:56 +0000
+++ b/bzrlib/errors.py 2011-11-24 15:43:18 +0000
@@ -24,13 +24,6 @@
trace,
)
from bzrlib.i18n import gettext
-from bzrlib.patches import (
- MalformedHunkHeader,
- MalformedLine,
- MalformedPatchHeader,
- PatchConflict,
- PatchSyntax,
- )
# TODO: is there any value in providing the .args field used by standard
@@ -3368,3 +3361,54 @@
self.from_kind = from_kind
self.to_kind = to_kind
self.format = format
+
+
+class PatchSyntax(BzrError):
+ """Base class for patch syntax errors."""
+
+
+class BinaryFiles(BzrError):
+
+ _fmt = 'Binary files section encountered.'
+
+ def __init__(self, orig_name, mod_name):
+ self.orig_name = orig_name
+ self.mod_name = mod_name
+
+
+class MalformedPatchHeader(PatchSyntax):
+
+ _fmt = "Malformed patch header. %(desc)s\n%(line)r"
+
+ def __init__(self, desc, line):
+ self.desc = desc
+ self.line = line
+
+
+class MalformedHunkHeader(PatchSyntax):
+
+ _fmt = "Malformed hunk header. %(desc)s\n%(line)r"
+
+ def __init__(self, desc, line):
+ self.desc = desc
+ self.line = line
+
+
+class MalformedLine(PatchSyntax):
+
+ _fmt = "Malformed line. %(desc)s\n%(line)r"
+
+ def __init__(self, desc, line):
+ self.desc = desc
+ self.line = line
+
+
+class PatchConflict(BzrError):
+
+ _fmt = ('Text contents mismatch at line %(line_no)d. Original has '
+ '"%(orig_line)s", but patch says it should be "%(patch_line)s"')
+
+ def __init__(self, line_no, orig_line, patch_line):
+ self.line_no = line_no
+ self.orig_line = orig_line.rstrip('\n')
+ self.patch_line = patch_line.rstrip('\n')
=== modified file 'bzrlib/patches.py'
--- a/bzrlib/patches.py 2010-02-25 06:17:27 +0000
+++ b/bzrlib/patches.py 2011-11-24 15:43:18 +0000
@@ -14,58 +14,21 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+from bzrlib.errors import (
+ BinaryFiles,
+ MalformedHunkHeader,
+ MalformedLine,
+ MalformedPatchHeader,
+ PatchConflict,
+ PatchSyntax,
+ )
+
import re
binary_files_re = 'Binary files (.*) and (.*) differ\n'
-
-class BinaryFiles(Exception):
-
- def __init__(self, orig_name, mod_name):
- self.orig_name = orig_name
- self.mod_name = mod_name
- Exception.__init__(self, 'Binary files section encountered.')
-
-
-class PatchSyntax(Exception):
- def __init__(self, msg):
- Exception.__init__(self, msg)
-
-
-class MalformedPatchHeader(PatchSyntax):
- def __init__(self, desc, line):
- self.desc = desc
- self.line = line
- msg = "Malformed patch header. %s\n%r" % (self.desc, self.line)
- PatchSyntax.__init__(self, msg)
-
-
-class MalformedHunkHeader(PatchSyntax):
- def __init__(self, desc, line):
- self.desc = desc
- self.line = line
- msg = "Malformed hunk header. %s\n%r" % (self.desc, self.line)
- PatchSyntax.__init__(self, msg)
-
-
-class MalformedLine(PatchSyntax):
- def __init__(self, desc, line):
- self.desc = desc
- self.line = line
- msg = "Malformed line. %s\n%s" % (self.desc, self.line)
- PatchSyntax.__init__(self, msg)
-
-
-class PatchConflict(Exception):
- def __init__(self, line_no, orig_line, patch_line):
- orig = orig_line.rstrip('\n')
- patch = str(patch_line).rstrip('\n')
- msg = 'Text contents mismatch at line %d. Original has "%s",'\
- ' but patch says it should be "%s"' % (line_no, orig, patch)
- Exception.__init__(self, msg)
-
-
def get_patch_names(iter_lines):
try:
line = iter_lines.next()
=== modified file 'bzrlib/shelf_ui.py'
--- a/bzrlib/shelf_ui.py 2011-10-05 18:40:53 +0000
+++ b/bzrlib/shelf_ui.py 2011-11-24 15:43:18 +0000
@@ -16,7 +16,6 @@
from cStringIO import StringIO
-import os
import shutil
import sys
import tempfile
More information about the bazaar-commits
mailing list