[PATCH 3 of 4] splicemap: improve error handling when source is git (issue2084)

Ben Goswami bengoswami at fb.com
Tue Apr 30 15:13:19 CDT 2013


# HG changeset patch
# User Ben Goswami <bengoswami at fb.com>
# Date 1366930978 25200
#      Thu Apr 25 16:02:58 2013 -0700
# Node ID 3dae607e8a02b4e82667b3b5660bd76459051c12
# Parent  9bf28065bccfbd1574b9ca62d8b7859bda8bc4d9
splicemap: improve error handling when source is git (issue2084)

Implemented similar error handling that is done for hg in an earlier revision.
These are:
   a. add checking for splicemap file format
   b. add checking for each revision string formats

diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -296,3 +296,8 @@
                 pass
 
         return bookmarks
+
+    def checkrevformat(self, revstr):
+        """ git revision string is a 40 byte hex """
+        self.checkhexformat(revstr)
+
diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t
--- a/tests/test-convert-git.t
+++ b/tests/test-convert-git.t
@@ -13,6 +13,10 @@
   $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
   $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
   $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
+  $ INVALIDID1=afd12345af
+  $ INVALIDID2=28173x36ddd1e67bf7098d541130558ef5534a86
+  $ VALIDID1=39b3d83f9a69a9ba4ebb111461071a0af0027357
+  $ VALIDID2=8dd6476bd09d9c7776355dc454dafe38efaec5da
   $ count=10
   $ commit()
   > {
@@ -298,6 +302,36 @@
   $ commit -a -m 'addsubmodule' >/dev/null 2>/dev/null
   $ cd ..
 
+test invalid splicemap1
+
+  $ cat > splicemap <<EOF
+  > $VALIDID1
+  > EOF
+  $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap1-hg
+  initializing destination git-repo2-splicemap1-hg repository
+  abort: syntax error in splicemap(1): child parent1[,parent2] expected
+  [255]
+
+test invalid splicemap2
+
+  $ cat > splicemap <<EOF
+  > $VALIDID1 $VALIDID2, $VALIDID2, $VALIDID2
+  > EOF
+  $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap2-hg
+  initializing destination git-repo2-splicemap2-hg repository
+  abort: syntax error in splicemap(1): child parent1[,parent2] expected
+  [255]
+
+test invalid splicemap3
+
+  $ cat > splicemap <<EOF
+  > $INVALIDID1 $INVALIDID2
+  > EOF
+  $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap3-hg
+  initializing destination git-repo2-splicemap3-hg repository
+  abort: splicemap entry afd12345af is not a valid revision identifier
+  [255]
+
 convert sub modules
   $ hg convert git-repo6 git-repo6-hg
   initializing destination git-repo6-hg repository


More information about the Mercurial-devel mailing list