summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-01-05 17:03:34 +0000
committerLars Wirzenius <liw@liw.fi>2013-01-05 17:03:34 +0000
commit206fb1529bf3bef9c51e9c47dd5b3fa053c485ba (patch)
tree9fbb1fde561ceb8ca396e98dcd8f3804e0ee87a3
parent989eb64fc8be4261f5b1ceaec6b91e97395fa336 (diff)
parent9bf89651bf665a59d0817fe2c5f4d821803264e7 (diff)
downloadlarch-206fb1529bf3bef9c51e9c47dd5b3fa053c485ba.tar.gz
Show node ids in error messages in hex
This makes it easier to find them on disk, since the filenames are already in hex.
-rw-r--r--NEWS2
-rw-r--r--larch/nodestore.py12
2 files changed, 8 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index a760a39..ec217b1 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ Version UNRELEASED
* Fsck now check for missing nodes, and optionally fixes them by
deleting references to them.
+* Node numbers are now reported in hexadecimal, to make it easier to find
+ on disk. Patch by Damien Couroussé.
Version 1.20121216
------------------
diff --git a/larch/nodestore.py b/larch/nodestore.py
index fb0abe0..929450a 100644
--- a/larch/nodestore.py
+++ b/larch/nodestore.py
@@ -27,8 +27,8 @@ class NodeMissing(larch.Error):
else:
error_msg = (': %s: %s: %s' %
(error.errno, error.strerror, error.filename))
- self.msg = ('Node %d cannot be found in the node store %s%s' %
- (node_id, node_store, error_msg))
+ self.msg = ('Node %s cannot be found in the node store %s%s' %
+ (hex(node_id), node_store, error_msg))
class NodeTooBig(larch.Error):
@@ -36,8 +36,8 @@ class NodeTooBig(larch.Error):
'''User tried to put a node that was too big into the store.'''
def __init__(self, node, node_size):
- self.msg = ('%s %d is too big (%d bytes)' %
- (node.__class__.__name__, node.id, node_size))
+ self.msg = ('%s %s is too big (%d bytes)' %
+ (node.__class__.__name__, hex(node.id), node_size))
class NodeExists(larch.Error):
@@ -45,7 +45,7 @@ class NodeExists(larch.Error):
'''User tried to put a node that already exists in the store.'''
def __init__(self, node_id):
- self.msg = 'Node %d is already in the store' % node_id
+ self.msg = 'Node %s is already in the store' % hex(node_id)
class NodeCannotBeModified(larch.Error):
@@ -53,7 +53,7 @@ class NodeCannotBeModified(larch.Error):
'''User called start_modification on node that cannot be modified.'''
def __init__(self, node_id):
- self.msg = 'Node %d cannot be modified' % node_id
+ self.msg = 'Node %s cannot be modified' % hex(node_id)
class NodeStore(object): # pragma: no cover