[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mercurial-devel
Subject:    [PATCH 4 of 4] splicemap: improve error handling when source is subversion (issue2084)
From:       Ben Goswami <bengoswami () fb ! com>
Date:       2013-04-30 20:13:20
Message-ID: b577d8dc6eeae6ce7889.1367352800 () devrs155 ! prn1 ! facebook ! com
[Download RAW message or body]

# HG changeset patch
# User Ben Goswami <bengoswami@fb.com>
# Date 1366938060 25200
#      Thu Apr 25 18:01:00 2013 -0700
# Node ID b577d8dc6eeae6ce7889a452e7798e2e5aa551f4
# Parent  3dae607e8a02b4e82667b3b5660bd76459051c12
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:<uuid><path>@<number>
format.

the test case has been enhanced to check this format.

diff --git a/hgext/convert/common.py b/hgext/convert/common.py
--- a/hgext/convert/common.py
+++ b/hgext/convert/common.py
@@ -65,10 +65,9 @@
 
     def checkhexformat(self, revstr):
         """ fails if revstr is not a 40 byte hex. mercurial and git both uses
-            such format for their rivision numbering
+            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 --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -399,5 +399,5 @@
         return bookmarks.listbookmarks(self.repo)
 
     def checkrevformat(self, revstr):
-        """ Mercurial, rivision string is a 40 byte hex """
+        """ Mercurial, revision string is a 40 byte hex """
         self.checkhexformat(revstr)
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -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 --git a/tests/test-convert-svn-source.t b/tests/test-convert-svn-source.t
--- a/tests/test-convert-svn-source.t
+++ b/tests/test-convert-svn-source.t
@@ -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 <<EOF
+  > $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
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@selenic.com
http://selenic.com/mailman/listinfo/mercurial-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic