From 336972695265e07a8e935dd2f6053d30541831d4 Mon Sep 17 00:00:00 2001 From: mhagger Date: Sat, 28 Aug 2010 11:37:35 +0000 Subject: [PATCH] Verify that the default branch is not nonsense. We don't know how to deal with a default branch that is not a top-level branch, so explicitly punt on such a case. Add a test that is derived from an error report from patric@rufflar.com. git-svn-id: http://cvs2svn.tigris.org/svn/cvs2svn/trunk@5260 be7e6eca-30d4-0310-a8e5-ac0d63af7087 --- cvs2svn_lib/collect_data.py | 25 ++++- run-tests.py | 16 ++++ .../strange-default-branch-cvsrepos/file5347,v | 101 +++++++++++++++++++++ 3 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 test-data/strange-default-branch-cvsrepos/file5347,v diff --git a/cvs2svn_lib/collect_data.py b/cvs2svn_lib/collect_data.py index 93f232d9..e7fd779f 100644 --- a/cvs2svn_lib/collect_data.py +++ b/cvs2svn_lib/collect_data.py @@ -569,9 +569,28 @@ class _FileDataCollector(cvs2svn_rcsparse.Sink): # This just sets the default branch to trunk. Normally this # shouldn't occur, but it has been seen in at least one CVS # repository. Just ignore it. - pass - else: - self.default_branch = branch + return + + m = _branch_revision_re.match(branch) + if not m: + self.collect_data.record_fatal_error( + 'The default branch %s in file %r is not a valid branch number' + % (branch, self.cvs_file.filename,) + ) + return + + branch = m.group(1) + m.group(2) + if branch.count('.') != 2: + # We don't know how to deal with a non-top-level default + # branch (what does CVS do?). So if this case is detected, + # punt: + self.collect_data.record_fatal_error( + 'The default branch %s in file %r is not a top-level branch' + % (branch, self.cvs_file.filename,) + ) + return + + self.default_branch = branch def define_tag(self, name, revision): """Remember the symbol name and revision, but don't process them yet. diff --git a/run-tests.py b/run-tests.py index 08890c32..6a6d4888 100755 --- a/run-tests.py +++ b/run-tests.py @@ -3865,6 +3865,7 @@ def add_on_branch2(): ('/%(branches)s/BRANCH/file1', 'A'), )) + @Cvs2SvnTestFunction def branch_from_vendor_branch(): "branch from vendor branch" @@ -3874,6 +3875,20 @@ def branch_from_vendor_branch(): symbol_hints_file='branch-from-vendor-branch-symbol-hints.txt', ) + +@Cvs2SvnTestFunction +def strange_default_branch(): + "default branch too deep in the hierarchy" + + ensure_conversion( + 'strange-default-branch', + error_re=( + r'ERROR\: The default branch 1\.2\.4\.3\.2\.1\.2 ' + r'in file .* is not a top-level branch' + ), + ) + + ######################################################################## # Run the tests @@ -4082,6 +4097,7 @@ test_list = [ exclude_symbol_default, add_on_branch2, XFail(branch_from_vendor_branch), + strange_default_branch, ] if __name__ == '__main__': diff --git a/test-data/strange-default-branch-cvsrepos/file5347,v b/test-data/strange-default-branch-cvsrepos/file5347,v new file mode 100644 index 00000000..e38d94aa --- /dev/null +++ b/test-data/strange-default-branch-cvsrepos/file5347,v @@ -0,0 +1,101 @@ +head 1.2; +branch 1.2.4.3.2.1.2; +access; +symbols + symbol1:1.2.0.4 + symbol2:1.2.4.3.0.2 + symbol3:1.2.4.3.2.1.0.2; +locks; strict; +comment @# @; + + +1.2 +date 2003.08.18.09.31.37; author author9; state Exp; +branches + 1.2.4.1; +next 1.1; + +1.1 +date 2003.07.03.13.58.23; author author9; state Exp; +branches; +next ; + +1.2.4.1 +date 2003.09.29.07.36.35; author author8; state Exp; +branches; +next 1.2.4.2; + +1.2.4.2 +date 2003.10.01.11.47.47; author author8; state Exp; +branches; +next 1.2.4.3; + +1.2.4.3 +date 2003.10.02.10.09.19; author author8; state Exp; +branches + 1.2.4.3.2.1; +next ; + +1.2.4.3.2.1 +date 2003.11.18.17.40.18; author author9; state Exp; +branches + 1.2.4.3.2.1.2.1; +next ; + +1.2.4.3.2.1.2.1 +date 2003.12.29.13.02.08; author author9; state Exp; +branches; +next ; + + +desc +@@ + + +1.2 +log +@log 12594@ +text +@@ + + +1.2.4.1 +log +@log 12595@ +text +@@ + + +1.2.4.2 +log +@log 12596@ +text +@@ + + +1.2.4.3 +log +@log 12597@ +text +@@ + + +1.2.4.3.2.1 +log +@log 12598@ +text +@@ + + +1.2.4.3.2.1.2.1 +log +@log 12560@ +text +@@ + + +1.1 +log +@log 12506@ +text +@@ -- 2.11.4.GIT