# HG changeset patch # User Nikita Slyusarev # Date 2019-02-07 15:57:54 # Node ID 2c13e91ede6e646aa667be722b02375368df9187 # Parent 328ca3b9e545b049e76444045b582da9746ac476 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. diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -1324,8 +1324,8 @@ class svn_sink(converter_sink, commandli 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')) diff --git a/tests/test-convert-svn-sink.t b/tests/test-convert-svn-sink.t --- a/tests/test-convert-svn-sink.t +++ b/tests/test-convert-svn-sink.t @@ -466,3 +466,46 @@ Tags are not supported, but must not bre 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