changeset 789:a5be5ca638de

externals: ignore externals blank or comment lines
author Patrick Mezard <pmezard@gmail.com>
date Wed, 02 Mar 2011 21:06:30 +0100
parents 836aa282f1f8
children 3173f418079c
files hgsubversion/svnexternals.py tests/fixtures/externals.sh tests/fixtures/externals.svndump tests/test_externals.py
diffstat 4 files changed, 30 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svnexternals.py
+++ b/hgsubversion/svnexternals.py
@@ -139,6 +139,9 @@ def parsedefinitions(ui, repo, svnroot, 
     defs = []
     for base in sorted(exts):
         for line in exts[base]:
+            if not line.strip() or line.lstrip().startswith('#'):
+                # Ignore comments and blank lines
+                continue
             try:
                 path, rev, source, pegrev, norevline = parsedefinition(line)
             except BadDefinition:
--- a/tests/fixtures/externals.sh
+++ b/tests/fixtures/externals.sh
@@ -37,7 +37,10 @@ svn propset -F externals svn:externals .
 svn ci -m "set externals on ."
 # Add another one
 cat > externals <<EOF
+# A comment, then an empty line, then a blank line
+
 ^/externals/project1 deps/project1
+    
 -r2 ^/externals/project2@2 deps/project2
 EOF
 svn propset -F externals svn:externals .
--- a/tests/fixtures/externals.svndump
+++ b/tests/fixtures/externals.svndump
@@ -1,6 +1,6 @@
 SVN-fs-dump-format-version: 2
 
-UUID: ac40e40a-7fbf-47e1-90a7-c1de12a5b013
+UUID: 2fcff1c7-6cef-40bf-9072-468ceec83032
 
 Revision-number: 0
 Prop-content-length: 56
@@ -9,7 +9,7 @@ Content-length: 56
 K 8
 svn:date
 V 27
-2009-05-03T14:07:14.149596Z
+2011-02-25T14:33:01.299441Z
 PROPS-END
 
 Revision-number: 1
@@ -27,7 +27,7 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:14.234026Z
+2011-02-25T14:33:01.321997Z
 PROPS-END
 
 Node-path: branches
@@ -72,7 +72,7 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:15.135488Z
+2011-02-25T14:33:02.082464Z
 PROPS-END
 
 Node-path: externals/project1
@@ -134,7 +134,7 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:16.180110Z
+2011-02-25T14:33:03.076026Z
 PROPS-END
 
 Node-path: trunk
@@ -179,19 +179,22 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:17.092210Z
+2011-02-25T14:33:04.058124Z
 PROPS-END
 
 Node-path: trunk
 Node-kind: dir
 Node-action: change
-Prop-content-length: 111
-Content-length: 111
+Prop-content-length: 169
+Content-length: 169
 
 K 13
 svn:externals
-V 76
+V 133
+# A comment, then an empty line, then a blank line
+
 ^/externals/project1 deps/project1
+    
 -r2 ^/externals/project2@2 deps/project2
 
 PROPS-END
@@ -212,7 +215,7 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:18.165337Z
+2011-02-25T14:33:05.096545Z
 PROPS-END
 
 Node-path: trunk
@@ -272,7 +275,7 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:21.092911Z
+2011-02-25T14:33:08.059874Z
 PROPS-END
 
 Node-path: branches/branch1
@@ -306,7 +309,7 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:23.097507Z
+2011-02-25T14:33:10.059295Z
 PROPS-END
 
 Node-path: branches/branch2
@@ -344,7 +347,7 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:24.086967Z
+2011-02-25T14:33:11.058317Z
 PROPS-END
 
 Node-path: trunk/subdir
@@ -366,7 +369,7 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:25.093557Z
+2011-02-25T14:33:12.058270Z
 PROPS-END
 
 Node-path: trunk/subdir2
@@ -393,7 +396,7 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:27.088306Z
+2011-02-25T14:33:14.058780Z
 PROPS-END
 
 Node-path: externals/project2
@@ -415,7 +418,7 @@ pmezard
 K 8
 svn:date
 V 27
-2009-05-03T14:07:28.065953Z
+2011-02-25T14:33:15.045928Z
 PROPS-END
 
 Node-path: trunk/a
--- a/tests/test_externals.py
+++ b/tests/test_externals.py
@@ -81,8 +81,12 @@ class TestFetchExternals(test_util.TestB
  ^/externals/project1 deps/project1
 """
         self.assertEqual(ref0, repo[0]['.hgsvnexternals'].data())
-        ref1 = """[.]
+        ref1 = """\
+[.]
+ # A comment, then an empty line, then a blank line
+ 
  ^/externals/project1 deps/project1
+     
  -r2 ^/externals/project2@2 deps/project2
 """
         self.assertEqual(ref1, repo[1]['.hgsvnexternals'].data())