convert: handle empty intial commits while converting to svn
Svn commit generation code skips empty commits, returning the parent.
Skipping the root commit must return None instead.
Added test to check skipping of empty commits.
--- a/hgext/convert/subversion.py Mon Jan 21 17:37:33 2019 +0000
+++ b/hgext/convert/subversion.py Thu Feb 07 18:57:54 2019 +0300
@@ -1324,8 +1324,8 @@
try:
rev = self.commit_re.search(output).group(1)
except AttributeError:
- if parents and not files:
- return parents[0]
+ if not files:
+ return parents[0] if parents else None
self.ui.warn(_('unexpected svn output:\n'))
self.ui.warn(output)
raise error.Abort(_('unable to cope with svn output'))
--- a/tests/test-convert-svn-sink.t Mon Jan 21 17:37:33 2019 +0000
+++ b/tests/test-convert-svn-sink.t Thu Feb 07 18:57:54 2019 +0300
@@ -466,3 +466,46 @@
msg: Add file a
A /a
$ rm -rf a a-hg a-hg-wc
+
+Skipping empty commits
+
+ $ hg init a
+
+ $ hg --cwd a --config ui.allowemptycommit=True ci -d '1 0' -m 'Initial empty commit'
+
+ $ echo a > a/a
+ $ hg --cwd a ci -d '0 0' -A -m 'Some change'
+ adding a
+ $ hg --cwd a --config ui.allowemptycommit=True ci -d '2 0' -m 'Empty commit 1'
+ $ hg --cwd a --config ui.allowemptycommit=True ci -d '3 0' -m 'Empty commit 2'
+ $ echo b > a/b
+ $ hg --cwd a ci -d '0 0' -A -m 'Another change'
+ adding b
+
+ $ hg convert -d svn a
+ assuming destination a-hg
+ initializing svn repository 'a-hg'
+ initializing svn working copy 'a-hg-wc'
+ scanning source...
+ sorting...
+ converting...
+ 4 Initial empty commit
+ 3 Some change
+ 2 Empty commit 1
+ 1 Empty commit 2
+ 0 Another change
+
+ $ svnupanddisplay a-hg-wc 0
+ 2 1 test a
+ 2 2 test .
+ 2 2 test b
+ revision: 2
+ author: test
+ msg: Another change
+ A /b
+ revision: 1
+ author: test
+ msg: Some change
+ A /a
+
+ $ rm -rf a a-hg a-hg-wc