From a06616521f431096f3bcd71971e74b6e0a4ca372 Mon Sep 17 00:00:00 2001 From: mhagger Date: Thu, 14 Apr 2011 03:50:12 +0000 Subject: [PATCH] If the declared vendor branch is not present, emit a warning and ignore it. git-svn-id: http://cvs2svn.tigris.org/svn/cvs2svn/trunk@5344 be7e6eca-30d4-0310-a8e5-ac0d63af7087 --- CHANGES | 1 + cvs2svn_lib/collect_data.py | 11 ++++++++++- run-tests.py | 14 ++++++++++++++ test-data/missing-vendor-branch-cvsrepos/file,v | 24 ++++++++++++++++++++++++ www/features.html | 3 +++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 test-data/missing-vendor-branch-cvsrepos/file,v diff --git a/CHANGES b/CHANGES index e75b517b..6b085512 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,7 @@ Version ?.?.? (not yet released) * Add a ConditionalPropertySetter. * Allow CVS repository paths to be excluded from the conversion. * Normalize EOLs in CVS log messages to LF. + * Ignore vendor branch declarations that refer to non-existent branches. Bugs fixed: * Issue #31: cvs2svn does not convert empty directories. diff --git a/cvs2svn_lib/collect_data.py b/cvs2svn_lib/collect_data.py index e30cfa13..6b17217d 100644 --- a/cvs2svn_lib/collect_data.py +++ b/cvs2svn_lib/collect_data.py @@ -937,7 +937,16 @@ class _FileDataCollector(cvs2svn_rcsparse.Sink): try: if self.default_branch: - vendor_cvs_branch_id = self.sdc.branches_data[self.default_branch].id + try: + vendor_cvs_branch_id = self.sdc.branches_data[self.default_branch].id + except KeyError: + logger.warn( + '%s: In %s:\n' + ' vendor branch %r is not present in file and will be ignored.' + % (warning_prefix, self.cvs_file.rcs_path, self.default_branch,) + ) + self.default_branch = None + return vendor_lod_items = self._cvs_file_items.get_lod_items( self._cvs_file_items[vendor_cvs_branch_id] ) diff --git a/run-tests.py b/run-tests.py index 0bbf3470..e6817ef6 100755 --- a/run-tests.py +++ b/run-tests.py @@ -3961,6 +3961,19 @@ def log_message_eols(): )) +@Cvs2SvnTestFunction +def missing_vendor_branch(): + "default branch not present in RCS file" + + conv = ensure_conversion( + 'missing-vendor-branch', + ) + if not conv.output_found( + r'.*vendor branch \'1\.1\.1\' is not present in file and will be ignored' + ): + raise Failure() + + ######################################################################## # Run the tests @@ -4173,6 +4186,7 @@ test_list = [ strange_default_branch, move_parent, log_message_eols, + missing_vendor_branch, ] if __name__ == '__main__': diff --git a/test-data/missing-vendor-branch-cvsrepos/file,v b/test-data/missing-vendor-branch-cvsrepos/file,v new file mode 100644 index 00000000..1f9c4600 --- /dev/null +++ b/test-data/missing-vendor-branch-cvsrepos/file,v @@ -0,0 +1,24 @@ +head 1.1; +branch 1.1.1; +access; +symbols; +locks; strict; +comment @# @; + + +1.1 +date 2006.09.06.19.14.41; author author3; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@Initial revision +@ +text +@@ diff --git a/www/features.html b/www/features.html index 0baf93d5..89eeb38d 100644 --- a/www/features.html +++ b/www/features.html @@ -224,6 +224,9 @@ customization by writing Python code.

  • Log messages with variant end-of-line styles.
  • +
  • Vendor branch declarations that refer to non-existent + branches.
  • + -- 2.11.4.GIT