changeset 632:eea224fa1156

svnmeta: improve error message in get_source_rev() Letting a KeyError propagate when the supplied revision has no conversion record on file isn't terribly helpful. At least not when this KeyError merely states that the key missing is 'convert_revision'. It's much better to preemptively check for it, detect that it's missing, and then raise an exception with a descriptive message.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Thu, 08 Jul 2010 21:53:59 +0200
parents 493023041e74
children 37b2adc64fb3
files hgsubversion/svnmeta.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -424,8 +424,10 @@ class SVNMeta(object):
         """
         if ctx is None:
             ctx = self.repo[changeid]
-        extra = ctx.extra()['convert_revision']
-        branchpath, revnum = extra[40:].rsplit('@', 1)
+        extra = ctx.extra()
+        if 'convert_revision' not in extra:
+            raise KeyError('%s has no conversion record' % ctx)
+        branchpath, revnum = extra['convert_revision'][40:].rsplit('@', 1)
         branch = self.localname(self.normalize(branchpath))
         if self.layout == 'single':
             branchpath = ''