# HG changeset patch # User Ben Goswami # Date 1366938060 25200 # Node ID 83973dc1bfe96c2718f31c3f09a7cd614593dcdf # Parent 478a04605ce1ba55a5a9db7aaa1f77a69f158270 splicemap: improve error handling when source is subversion (issue2084) Implemented error handling on splicemap file when source is subversion (This checks are similar to when source is hg or git). The revision string is expected to be of svn:@ format. the test case has been enhanced to check this format. diff -r 478a04605ce1 -r 83973dc1bfe9 hgext/convert/common.py --- a/hgext/convert/common.py Thu Apr 25 16:02:58 2013 -0700 +++ b/hgext/convert/common.py Thu Apr 25 18:01:00 2013 -0700 @@ -67,8 +67,7 @@ """ fails if revstr is not a 40 byte hex. mercurial and git both uses such format for their revision numbering """ - matchobj = re.match(r'[0-9a-fA-F]{40,40}$', revstr) - if matchobj is None: + if not re.match(r'[0-9a-fA-F]{40,40}$', revstr): raise util.Abort(_('splicemap entry %s is not a valid revision' ' identifier') % revstr) diff -r 478a04605ce1 -r 83973dc1bfe9 hgext/convert/subversion.py --- a/hgext/convert/subversion.py Thu Apr 25 16:02:58 2013 -0700 +++ b/hgext/convert/subversion.py Thu Apr 25 18:01:00 2013 -0700 @@ -452,6 +452,14 @@ del self.commits[rev] return commit + def checkrevformat(self, revstr): + """ fails if revision format does not match the correct format""" + if not re.match(r'svn:[0-9a-f]{8,8}-[0-9a-f]{4,4}-' + '[0-9a-f]{4,4}-[0-9a-f]{4,4}-[0-9a-f]' + '{12,12}(.*)\@[0-9]+$',revstr): + raise util.Abort(_('splicemap entry %s is not a valid revision' + ' identifier') % revstr) + def gettags(self): tags = {} if self.tags is None: diff -r 478a04605ce1 -r 83973dc1bfe9 tests/test-convert-svn-source.t --- a/tests/test-convert-svn-source.t Thu Apr 25 16:02:58 2013 -0700 +++ b/tests/test-convert-svn-source.t Thu Apr 25 18:01:00 2013 -0700 @@ -16,6 +16,8 @@ #else $ SVNREPOURL=file://`python -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` #endif + $ INVALIDREVISIONID=svn:x2147622-4a9f-4db4-a8d3-13562ff547b2/proj%20B/mytrunk@1 + $ VALIDREVISIONID=svn:a2147622-4a9f-4db4-a8d3-13562ff547b2/proj%20B/mytrunk/mytrunk@1 Now test that it works with trunk/tags layout, but no branches yet. @@ -168,6 +170,15 @@ | o 0 second letter files: letter2.txt +test invalid splicemap1 + + $ cat > splicemap < $INVALIDREVISIONID $VALIDREVISIONID + > EOF + $ hg convert --splicemap splicemap "$SVNREPOURL/proj%20B/mytrunk" smap + initializing destination smap repository + abort: splicemap entry svn:x2147622-4a9f-4db4-a8d3-13562ff547b2/proj%20B/mytrunk@1 is not a valid revision identifier + [255] Test stop revision $ hg convert --rev 1 "$SVNREPOURL/proj%20B/mytrunk" stoprev