~brook/bzr-cvsps-import/fix-402690-788914-788915

« back to all changes in this revision

Viewing changes to cvsps/importer.py

  • Committer: brook
  • Date: 2011-05-27 01:43:05 UTC
  • Revision ID: brook-20110527014305-fkqs2qhqmerif9ze
Fixes: 402690,788915,788914
Also adds a message when a cvs commit failed if the message could not be handled by bzr instead of crashing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
467
467
 
468
468
            builder.finish_inventory()
469
469
            message = self._escape_commit_message(message)
470
 
            new_revision_id = builder.commit(message)
 
470
            try:
 
471
                new_revision_id = builder.commit(message)
 
472
            except ValueError:
 
473
                lost_message = 'Lost CVS commit message during bzr conversion'
 
474
                new_revision_id = builder.commit(lost_message)
 
475
                trace.warning('WARNING The following cvs commit message was lost during the bzr import:')
 
476
                trace.warning('==============================')
 
477
                trace.warning(message)
 
478
                trace.warning('==============================')
 
479
                trace.warning('Using "{0}" instead and continuing'.format(lost_message))
471
480
        except:
472
481
            builder.abort()
473
482
            raise
484
493
        message, escape_count = self._message_escape_re.subn(
485
494
                lambda match: match.group(0).encode('unicode_escape'),
486
495
                message)
 
496
        message=message.replace('\r\n','\n').replace('\r','\n')
487
497
        return message
488
498
 
489
499
 
1183
1193
        """Open the bzr repository, creating it if needed."""
1184
1194
        self.setup_directories()
1185
1195
        bzr_repo_transport = transport.get_transport(self._repo_path)
 
1196
        is_branch = True
1186
1197
        try:
1187
1198
            a_bzrdir = bzrdir.BzrDir.open_from_transport(bzr_repo_transport)
1188
1199
        except errors.NotBranchError:
 
1200
            is_branch = False
1189
1201
            return self._create_bzr_repo(bzr_repo_transport)
1190
 
        if self._tag_style == 'tag' and (
 
1202
        if self._tag_style == 'tag' and not is_branch and (
1191
1203
                not a_bzrdir.find_branch_format().supports_tags()):
1192
1204
            newFormat = bzrdir.format_registry.get_default()
1193
1205
            converter = a_bzrdir._format.get_converter(newFormat)
1227
1239
            pb.update('Parsing cvsps dump file.')
1228
1240
        try:
1229
1241
            parser = Parser(cvsps_dump_file, encoding=self._encoding)
1230
 
            patchsets = parser.parse(pb=pb)
 
1242
            patchsets = parser.parse()
1231
1243
        finally:
1232
1244
            cvsps_dump_file.close()
1233
1245
        return patchsets
1274
1286
        """Start converting the repository."""
1275
1287
        pb = ui.ui_factory.nested_progress_bar()
1276
1288
        try:
1277
 
            repo = self.open_or_create_bzr_repo(pb=pb)
 
1289
            repo = self.open_or_create_bzr_repo()
1278
1290
        finally:
1279
1291
            pb.finished()
1280
1292
        # Maintain a repository wide lock for the whole transaction