# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1278618839 -7200 # Node ID eea224fa1156a26c23f08cf8b10739d9b5e98ddf # Parent 493023041e7435c29ed2e2969a13aeb2b733a9bd 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. diff --git a/hgsubversion/svnmeta.py b/hgsubversion/svnmeta.py --- 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 = ''