Rev 2760: (Daniel Watkins) Clean-up error messages quoting parameters when necessary in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Aug 28 14:02:30 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2760
revision-id: pqm at pqm.ubuntu.com-20070828130228-rv0k8180v9n4vj90
parent: pqm at pqm.ubuntu.com-20070828082340-2byilw23kzl3cjx4
parent: ian.clatworthy at internode.on.net-20070828121935-5gc6qayvim5d6756
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-08-28 14:02:28 +0100
message:
(Daniel Watkins) Clean-up error messages quoting parameters when necessary
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/tests/blackbox/test_annotate.py testannotate.py-20051013044000-457f44801bfa9d39
bzrlib/tests/blackbox/test_info.py test_info.py-20060215045507-bbdd2d34efab9e0a
bzrlib/tests/blackbox/test_mv.py test_mv.py-20060705114902-33tkxz0o9cdshemo-1
bzrlib/tests/blackbox/test_outside_wt.py test_outside_wt.py-20060116200058-98edd33e7db8bdde
bzrlib/tests/test_errors.py test_errors.py-20060210110251-41aba2deddf936a8
bzrlib/tests/test_trace.py testtrace.py-20051110225523-a21117fc7a07eeff
------------------------------------------------------------
revno: 2759.1.1
merged: ian.clatworthy at internode.on.net-20070828121935-5gc6qayvim5d6756
parent: pqm at pqm.ubuntu.com-20070828082340-2byilw23kzl3cjx4
parent: d.m.watkins at warwick.ac.uk-20070823180253-5kmviq3cvtw6ttxn
committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
branch nick: ianc-integration
timestamp: Tue 2007-08-28 22:19:35 +1000
message:
(Daniel Watkins) Clean-up error messages quoting parameters when necessary
------------------------------------------------------------
revno: 2745.3.3
merged: d.m.watkins at warwick.ac.uk-20070823180253-5kmviq3cvtw6ttxn
parent: d.m.watkins at warwick.ac.uk-20070823141048-hlyyibw24f34voen
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 129791
timestamp: Thu 2007-08-23 20:02:53 +0200
message:
Changed to remove need for escaping of quotes.
------------------------------------------------------------
revno: 2745.3.2
merged: d.m.watkins at warwick.ac.uk-20070823141048-hlyyibw24f34voen
parent: d.m.watkins at warwick.ac.uk-20070823141031-i1nl5auwld9g93jx
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 129791
timestamp: Thu 2007-08-23 16:10:48 +0200
message:
Updated tests to reflect new error text.
------------------------------------------------------------
revno: 2745.3.1
merged: d.m.watkins at warwick.ac.uk-20070823141031-i1nl5auwld9g93jx
parent: pqm at pqm.ubuntu.com-20070823005013-ada9x55rc31yiwou
committer: Daniel Watkins <D.M.Watkins at warwick.ac.uk>
branch nick: 129791
timestamp: Thu 2007-08-23 16:10:31 +0200
message:
Modified errors.py to quote paths just before full stops. Also added some full stops to error messages without them.
=== modified file 'NEWS'
--- a/NEWS 2007-08-28 08:23:40 +0000
+++ b/NEWS 2007-08-28 12:19:35 +0000
@@ -49,6 +49,11 @@
* ``uncommit --help`` now explains the -r option adequately. (Daniel
Watkins, #106726)
+ * Error messages are now better formatted with parameters (such as
+ filenames) quoted when necessary. This avoids confusion when directory
+ names ending in a '.' at the end of messages were confused with a
+ full stop that may or not have been there. (Daniel Watkins, #129791)
+
IMPROVEMENTS:
* ``pull`` and ``merge`` are much faster at installing bundle format 4.
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2007-08-22 22:31:12 +0000
+++ b/bzrlib/errors.py 2007-08-23 18:02:53 +0000
@@ -256,7 +256,7 @@
class NoSuchId(BzrError):
- _fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
+ _fmt = 'The file id "%(file_id)s" is not present in the tree %(tree)s.'
def __init__(self, tree, file_id):
BzrError.__init__(self)
@@ -266,8 +266,8 @@
class NoSuchIdInRepository(NoSuchId):
- _fmt = ("The file id %(file_id)r is not present in the repository"
- " %(repository)r")
+ _fmt = ('The file id "%(file_id)s" is not present in the repository'
+ ' %(repository)r')
def __init__(self, repository, file_id):
BzrError.__init__(self, repository=repository, file_id=file_id)
@@ -286,7 +286,7 @@
class NoWorkingTree(BzrError):
- _fmt = "No WorkingTree exists for %(base)s."
+ _fmt = 'No WorkingTree exists for "%(base)s".'
def __init__(self, base):
BzrError.__init__(self)
@@ -308,7 +308,7 @@
class WorkingTreeAlreadyPopulated(BzrError):
- _fmt = """Working tree already populated in %(base)s"""
+ _fmt = 'Working tree already populated in "%(base)s"'
internal_error = True
@@ -468,17 +468,17 @@
class NotADirectory(PathError):
- _fmt = "%(path)r is not a directory %(extra)s"
+ _fmt = '"%(path)s" is not a directory %(extra)s'
class NotInWorkingDirectory(PathError):
- _fmt = "%(path)r is not in the working directory %(extra)s"
+ _fmt = '"%(path)s" is not in the working directory %(extra)s'
class DirectoryNotEmpty(PathError):
- _fmt = "Directory not empty: %(path)r%(extra)s"
+ _fmt = 'Directory not empty: "%(path)s"%(extra)s'
class ReadingCompleted(BzrError):
@@ -495,22 +495,22 @@
class ResourceBusy(PathError):
- _fmt = "Device or resource busy: %(path)r%(extra)s"
+ _fmt = 'Device or resource busy: "%(path)s"%(extra)s'
class PermissionDenied(PathError):
- _fmt = "Permission denied: %(path)r%(extra)s"
+ _fmt = 'Permission denied: "%(path)s"%(extra)s'
class InvalidURL(PathError):
- _fmt = "Invalid url supplied to transport: %(path)r%(extra)s"
+ _fmt = 'Invalid url supplied to transport: "%(path)s"%(extra)s'
class InvalidURLJoin(PathError):
- _fmt = "Invalid URL join request: %(args)s%(extra)s"
+ _fmt = 'Invalid URL join request: "%(args)s"%(extra)s'
def __init__(self, msg, base, args):
PathError.__init__(self, base, msg)
@@ -542,8 +542,8 @@
class ShortReadvError(PathError):
- _fmt = ("readv() read %(actual)s bytes rather than %(length)s bytes"
- " at %(offset)s for %(path)s%(extra)s")
+ _fmt = ('readv() read %(actual)s bytes rather than %(length)s bytes'
+ ' at %(offset)s for "%(path)s"%(extra)s')
internal_error = True
@@ -556,7 +556,7 @@
class PathNotChild(PathError):
- _fmt = "Path %(path)r is not a child of path %(base)r%(extra)s"
+ _fmt = 'Path "%(path)s" is not a child of path "%(base)s"%(extra)s'
internal_error = True
@@ -572,7 +572,7 @@
class InvalidNormalization(PathError):
- _fmt = "Path %(path)r is not unicode normalized"
+ _fmt = 'Path "%(path)s" is not unicode normalized'
# TODO: This is given a URL; we try to unescape it but doing that from inside
@@ -580,7 +580,7 @@
# TODO: Probably this behavior of should be a common superclass
class NotBranchError(PathError):
- _fmt = "Not a branch: %(path)s"
+ _fmt = 'Not a branch: "%(path)s".'
def __init__(self, path):
import bzrlib.urlutils as urlutils
@@ -598,19 +598,19 @@
class AlreadyBranchError(PathError):
- _fmt = "Already a branch: %(path)s."
+ _fmt = 'Already a branch: "%(path)s".'
class BranchExistsWithoutWorkingTree(PathError):
- _fmt = "Directory contains a branch, but no working tree \
-(use bzr checkout if you wish to build a working tree): %(path)s"
+ _fmt = 'Directory contains a branch, but no working tree \
+(use bzr checkout if you wish to build a working tree): "%(path)s"'
class AtomicFileAlreadyClosed(PathError):
- _fmt = ("'%(function)s' called on an AtomicFile after it was closed:"
- " %(path)s")
+ _fmt = ('"%(function)s" called on an AtomicFile after it was closed:'
+ ' "%(path)s"')
def __init__(self, path, function):
PathError.__init__(self, path=path, extra=None)
@@ -619,8 +619,8 @@
class InaccessibleParent(PathError):
- _fmt = ("Parent not accessible given base %(base)s and"
- " relative path %(path)s")
+ _fmt = ('Parent not accessible given base "%(base)s" and'
+ ' relative path "%(path)s"')
def __init__(self, path, base):
PathError.__init__(self, path)
@@ -629,7 +629,7 @@
class NoRepositoryPresent(BzrError):
- _fmt = "No repository present: %(path)r"
+ _fmt = 'No repository present: "%(path)s"'
def __init__(self, bzrdir):
BzrError.__init__(self)
self.path = bzrdir.transport.clone('..').base
@@ -637,7 +637,7 @@
class FileInWrongBranch(BzrError):
- _fmt = "File %(path)s in not in branch %(branch_base)s."
+ _fmt = 'File "%(path)s" in not in branch %(branch_base)s.'
def __init__(self, branch, path):
BzrError.__init__(self)
@@ -687,7 +687,7 @@
class AlreadyVersionedError(BzrError):
"""Used when a path is expected not to be versioned, but it is."""
- _fmt = "%(context_info)s%(path)s is already versioned"
+ _fmt = "%(context_info)s%(path)s is already versioned."
def __init__(self, path, context_info=None):
"""Construct a new AlreadyVersionedError.
@@ -708,7 +708,7 @@
class NotVersionedError(BzrError):
"""Used when a path is expected to be versioned, but it is not."""
- _fmt = "%(context_info)s%(path)s is not versioned"
+ _fmt = "%(context_info)s%(path)s is not versioned."
def __init__(self, path, context_info=None):
"""Construct a new NotVersionedError.
@@ -767,7 +767,7 @@
class ForbiddenControlFileError(BzrError):
- _fmt = "Cannot operate on %(filename)s because it is a control file"
+ _fmt = 'Cannot operate on "%(filename)s" because it is a control file'
class LockError(BzrError):
@@ -870,7 +870,7 @@
class LockContention(LockError):
- _fmt = "Could not acquire lock %(lock)s"
+ _fmt = 'Could not acquire lock "%(lock)s"'
# TODO: show full url for lock, combining the transport and relative
# bits?
@@ -1005,7 +1005,7 @@
class NoSuchRevisionInTree(NoSuchRevision):
"""When using Tree.revision_tree, and the revision is not accessible."""
- _fmt = "The revision id %(revision_id)s is not present in the tree %(tree)s."
+ _fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
def __init__(self, tree, revision_id):
BzrError.__init__(self)
@@ -1143,8 +1143,8 @@
class BoundBranchOutOfDate(BzrError):
- _fmt = ("Bound branch %(branch)s is out of date"
- " with master branch %(master)s.")
+ _fmt = ("Bound branch %(branch)s is out of date with master branch"
+ " %(master)s.")
def __init__(self, branch, master):
BzrError.__init__(self)
@@ -1265,7 +1265,7 @@
class RevisionNotPresent(VersionedFileError):
- _fmt = "Revision {%(revision_id)s} not present in %(file_id)s."
+ _fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
def __init__(self, revision_id, file_id):
VersionedFileError.__init__(self)
@@ -1275,7 +1275,7 @@
class RevisionAlreadyPresent(VersionedFileError):
- _fmt = "Revision {%(revision_id)s} already present in %(file_id)s."
+ _fmt = 'Revision {%(revision_id)s} already present in "%(file_id)s".'
def __init__(self, revision_id, file_id):
VersionedFileError.__init__(self)
@@ -1297,7 +1297,7 @@
class KnitHeaderError(KnitError):
- _fmt = "Knit header error: %(badline)r unexpected for file %(filename)s"
+ _fmt = 'Knit header error: %(badline)r unexpected for file "%(filename)s".'
def __init__(self, badline, filename):
KnitError.__init__(self)
@@ -1527,7 +1527,7 @@
class SigningFailed(BzrError):
- _fmt = "Failed to gpg sign data with command %(command_line)r"
+ _fmt = 'Failed to gpg sign data with command "%(command_line)s"'
def __init__(self, command_line):
BzrError.__init__(self, command_line=command_line)
@@ -1607,7 +1607,7 @@
class NoBundleFound(BzrError):
- _fmt = "No bundle was found in %(filename)s"
+ _fmt = 'No bundle was found in "%(filename)s".'
def __init__(self, filename):
BzrError.__init__(self)
@@ -2176,7 +2176,7 @@
class BadSubsumeSource(BzrError):
- _fmt = """Can't subsume %(other_tree)s into %(tree)s. %(reason)s"""
+ _fmt = "Can't subsume %(other_tree)s into %(tree)s. %(reason)s"
def __init__(self, tree, other_tree, reason):
self.tree = tree
@@ -2194,7 +2194,8 @@
class BadReferenceTarget(BzrError):
- _fmt = "Can't add reference to %(other_tree)s into %(tree)s. %(reason)s"
+ _fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
+ "%(reason)s"
internal_error = True
@@ -2301,7 +2302,7 @@
class DuplicateRecordNameError(ContainerError):
- _fmt = "Container has multiple records with the same name: \"%(name)s\""
+ _fmt = "Container has multiple records with the same name: %(name)s"
def __init__(self, name):
self.name = name
=== modified file 'bzrlib/tests/blackbox/test_annotate.py'
--- a/bzrlib/tests/blackbox/test_annotate.py 2007-07-04 08:46:22 +0000
+++ b/bzrlib/tests/blackbox/test_annotate.py 2007-08-23 14:10:48 +0000
@@ -166,4 +166,4 @@
os.chdir('tree')
out, err = self.run_bzr("annotate doesnotexist", retcode=3)
self.assertEqual('', out)
- self.assertEqual("bzr: ERROR: doesnotexist is not versioned\n", err)
+ self.assertEqual("bzr: ERROR: doesnotexist is not versioned.\n", err)
=== modified file 'bzrlib/tests/blackbox/test_info.py'
--- a/bzrlib/tests/blackbox/test_info.py 2007-08-14 11:17:54 +0000
+++ b/bzrlib/tests/blackbox/test_info.py 2007-08-23 14:10:48 +0000
@@ -41,7 +41,7 @@
location = "/i/do/not/exist/"
out, err = self.run_bzr('info '+location, retcode=3)
self.assertEqual(out, '')
- self.assertEqual(err, 'bzr: ERROR: Not a branch: %s\n' % location)
+ self.assertEqual(err, 'bzr: ERROR: Not a branch: "%s".\n' % location)
def test_info_standalone(self):
transport = self.get_transport()
=== modified file 'bzrlib/tests/blackbox/test_mv.py'
--- a/bzrlib/tests/blackbox/test_mv.py 2007-06-26 20:32:49 +0000
+++ b/bzrlib/tests/blackbox/test_mv.py 2007-08-23 14:10:48 +0000
@@ -65,13 +65,13 @@
self.build_tree(['unversioned.txt'])
self.run_bzr_error(
["^bzr: ERROR: Could not rename unversioned.txt => elsewhere."
- " .*unversioned.txt is not versioned$"],
+ " .*unversioned.txt is not versioned\.$"],
'mv unversioned.txt elsewhere')
def test_mv_nonexisting(self):
self.run_bzr_error(
["^bzr: ERROR: Could not rename doesnotexist => somewhereelse."
- " .*doesnotexist is not versioned$"],
+ " .*doesnotexist is not versioned\.$"],
'mv doesnotexist somewhereelse')
def test_mv_unqualified(self):
@@ -83,12 +83,12 @@
tree.add(['test.txt'])
self.run_bzr_error(
- ["^bzr: ERROR: Could not move to sub1: sub1 is not versioned$"],
+ ["^bzr: ERROR: Could not move to sub1: sub1 is not versioned\.$"],
'mv test.txt sub1')
self.run_bzr_error(
["^bzr: ERROR: Could not move test.txt => .*hello.txt: "
- "sub1 is not versioned$"],
+ "sub1 is not versioned\.$"],
'mv test.txt sub1/hello.txt')
def test_mv_dirs(self):
@@ -177,7 +177,7 @@
os.remove('b')
osutils.rename('a', 'b')
self.run_bzr_error(
- ["^bzr: ERROR: Could not move a => b. b is already versioned$"],
+ ["^bzr: ERROR: Could not move a => b. b is already versioned\.$"],
'mv a b')
#check that nothing changed
self.failIfExists('a')
@@ -213,7 +213,7 @@
osutils.rename('a', 'sub/a')
self.run_bzr_error(
- ["^bzr: ERROR: Could not move a => a: sub is not versioned$"],
+ ["^bzr: ERROR: Could not move a => a: sub is not versioned\.$"],
'mv a sub/a')
self.failIfExists('a')
self.failUnlessExists('sub/a')
@@ -249,7 +249,7 @@
osutils.rename('a1', 'sub/a1')
self.run_bzr_error(
- ["^bzr: ERROR: Could not move to sub. sub is not versioned$"],
+ ["^bzr: ERROR: Could not move to sub. sub is not versioned\.$"],
'mv a1 a2 sub')
self.failIfExists('a1')
self.failUnlessExists('sub/a1')
=== modified file 'bzrlib/tests/blackbox/test_outside_wt.py'
--- a/bzrlib/tests/blackbox/test_outside_wt.py 2007-06-27 19:13:50 +0000
+++ b/bzrlib/tests/blackbox/test_outside_wt.py 2007-08-23 14:10:48 +0000
@@ -32,14 +32,14 @@
def test_cwd_log(self):
os.chdir(tempfile.mkdtemp())
out, err = self.run_bzr('log', retcode=3)
- self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
+ self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (getcwd(),),
err)
def test_url_log(self):
url = self.get_readonly_url() + 'subdir/'
out, err = self.run_bzr(['log', url], retcode=3)
self.assertEqual(u'bzr: ERROR: Not a branch:'
- u' %s\n' % url, err)
+ u' "%s".\n' % url, err)
def test_diff_ouside_tree(self):
os.chdir(tempfile.mkdtemp())
@@ -51,22 +51,22 @@
# -r X..Y
out, err = self.run_bzr('diff -r revno:2:branch2..revno:1', retcode=3)
self.assertEquals('', out)
- self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
+ self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (getcwd(),),
err)
# -r X
out, err = self.run_bzr('diff -r revno:2:branch2', retcode=3)
self.assertEquals('', out)
- self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
+ self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (getcwd(),),
err)
# -r X..
out, err = self.run_bzr('diff -r revno:2:branch2..', retcode=3)
self.assertEquals('', out)
- self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
+ self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (getcwd(),),
err)
# no -r at all.
out, err = self.run_bzr('diff', retcode=3)
self.assertEquals('', out)
- self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
+ self.assertEqual(u'bzr: ERROR: Not a branch: "%s/".\n' % (getcwd(),),
err)
=== modified file 'bzrlib/tests/test_errors.py'
--- a/bzrlib/tests/test_errors.py 2007-07-20 03:20:20 +0000
+++ b/bzrlib/tests/test_errors.py 2007-08-23 18:02:53 +0000
@@ -84,7 +84,7 @@
def test_knit_header_error(self):
error = errors.KnitHeaderError('line foo\n', 'path/to/file')
self.assertEqual("Knit header error: 'line foo\\n' unexpected"
- " for file path/to/file", str(error))
+ " for file \"path/to/file\".", str(error))
def test_knit_index_unknown_method(self):
error = errors.KnitIndexUnknownMethod('http://host/foo.kndx',
@@ -118,15 +118,14 @@
def test_no_such_id(self):
error = errors.NoSuchId("atree", "anid")
- self.assertEqualDiff("The file id anid is not present in the tree "
+ self.assertEqualDiff("The file id \"anid\" is not present in the tree "
"atree.",
str(error))
def test_no_such_revision_in_tree(self):
error = errors.NoSuchRevisionInTree("atree", "anid")
- self.assertEqualDiff("The revision id anid is not present in the tree "
- "atree.",
- str(error))
+ self.assertEqualDiff("The revision id {anid} is not present in the"
+ " tree atree.", str(error))
self.assertIsInstance(error, errors.NoSuchRevision)
def test_not_write_locked(self):
@@ -353,7 +352,7 @@
"""Test the formatting of DuplicateRecordNameError."""
e = errors.DuplicateRecordNameError(u"n\xe5me".encode('utf-8'))
self.assertEqual(
- "Container has multiple records with the same name: \"n\xc3\xa5me\"",
+ "Container has multiple records with the same name: n\xc3\xa5me",
str(e))
=== modified file 'bzrlib/tests/test_trace.py'
--- a/bzrlib/tests/test_trace.py 2007-08-20 03:43:40 +0000
+++ b/bzrlib/tests/test_trace.py 2007-08-23 14:10:48 +0000
@@ -83,7 +83,7 @@
pass
msg = _format_exception()
self.assertTrue(len(msg) > 0)
- self.assertEqualDiff(msg, 'bzr: ERROR: Not a branch: wibble\n')
+ self.assertEqualDiff(msg, 'bzr: ERROR: Not a branch: \"wibble\".\n')
def test_trace_unicode(self):
"""Write Unicode to trace log"""
More information about the bazaar-commits
mailing list