~rom1-chal/bzr-builder/merge-all-what-can-be

« back to all changes in this revision

Viewing changes to cmds.py

  • Committer: Romain Chalumeau
  • Date: 2010-09-20 13:02:20 UTC
  • Revision ID: rchalumeau@echo.fr-20100920130220-4hxn3575fi5llfka
* Report ing in a different module
* report argument added to RecipeBranch
* ReST formatted report

Show diffs side-by-side

added added

removed removed

Lines of Context:
330
330
            Option('merge-what-can-be', 
331
331
                    help="Allows not to stop at the first detected conflicts in a branch. "
332
332
                        "It stores the result in a report, revert the conflicts and merges the next one."),
 
333
            Option('html-report', 
 
334
                    help="Save as html page the generated report in working dir."),
333
335
                    ]
334
336
 
335
337
    def _get_prepared_branch_from_recipe(self, recipe_file,
361
363
            return 0, base_branch
362
364
        return None, base_branch
363
365
 
364
 
    def generate_build_report(self, base_branch, recipe_file):
365
 
        self.report = '''
366
 
------------
367
 
Build report
368
 
------------
369
 
 
370
 
Build report for branch %s from recipe %s
371
 
 
372
 
''' % (base_branch.url, recipe_file)
373
 
        for branch_report in GLOBAL_REPORT.itervalues():
374
 
            self.report += '\n * %s' % str(branch_report)
375
 
            for file, developers in branch_report.conflicts : 
376
 
                self.report += "\t%s - (modifications from %s)\n" % (file, ', '.join(developers))
377
 
 
378
366
    def run(self, recipe_file, working_directory, manifest=None,
379
 
            if_changed_from=None, merge_what_can_be=False):
 
367
            if_changed_from=None, merge_what_can_be=False, html_report=False):
380
368
        result, base_branch = self._get_prepared_branch_from_recipe(recipe_file,
381
369
            if_changed_from=if_changed_from, merge_what_can_be=merge_what_can_be)
382
370
        if result is not None:
383
371
            return result
384
372
        manifest_path = manifest or os.path.join(working_directory,
385
373
                        "bzr-builder.manifest")
 
374
        
 
375
                        
 
376
        self.report = GlobalReport(base_branch, recipe_file)
 
377
        
386
378
        try:
387
379
            build_tree(base_branch, working_directory, ignore_on_failure=merge_what_can_be)
388
 
        except (ConflictsFromMerge, UnresolvedConflicts), e:
389
 
            raise
390
 
        finally:
391
 
            self.generate_build_report(base_branch, recipe_file)
 
380
        except ConflictsFromMerge, e:
392
381
            trace.note(self.report)
 
382
            print e
 
383
            raise
 
384
        # The unresolvedConflicts exception has to stop the build execution. No report is to be 
 
385
        except UnresolvedConflicts, e:
 
386
            raise
 
387
        finally:
 
388
            trace.note(self.report)    
 
389
        
393
390
        write_manifest_to_path(manifest_path, base_branch)
394
391
 
395
 
 
396
392
class cmd_dailydeb(cmd_build):
397
393
    """Build a deb based on a 'recipe'.
398
394