~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_commit.py

  • Committer: John Arbash Meinel
  • Date: 2007-04-28 15:04:17 UTC
  • mfrom: (2466 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2566.
  • Revision ID: john@arbash-meinel.com-20070428150417-trp3pi0pzd411pu4
[merge] bzr.dev 2466

Show diffs side-by-side

added added

removed removed

Lines of Context:
358
358
        # --no-strict overrides --strict
359
359
        self.run_bzr('commit', '--strict', '-m', 'add b', '--no-strict',
360
360
                     working_dir='tree')
 
361
 
 
362
    def test_fixes_bug_output(self):
 
363
        """commit --fixes=lp:23452 succeeds without output."""
 
364
        tree = self.make_branch_and_tree('tree')
 
365
        self.build_tree(['tree/hello.txt'])
 
366
        tree.add('hello.txt')
 
367
        output, err = self.run_bzr(
 
368
            'commit', '-m', 'hello', '--fixes=lp:23452', 'tree/hello.txt')
 
369
        self.assertEqual('', output)
 
370
        self.assertEqual('added hello.txt\nCommitted revision 1.\n', err)
 
371
 
 
372
    def test_no_bugs_no_properties(self):
 
373
        """If no bugs are fixed, the bugs property is not set.
 
374
 
 
375
        see https://beta.launchpad.net/bzr/+bug/109613
 
376
        """
 
377
        tree = self.make_branch_and_tree('tree')
 
378
        self.build_tree(['tree/hello.txt'])
 
379
        tree.add('hello.txt')
 
380
        self.run_bzr( 'commit', '-m', 'hello', 'tree/hello.txt')
 
381
        # Get the revision properties, ignoring the branch-nick property, which
 
382
        # we don't care about for this test.
 
383
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
384
        properties = dict(last_rev.properties)
 
385
        del properties['branch-nick']
 
386
        self.assertFalse('bugs' in properties)
 
387
 
 
388
    def test_fixes_bug_sets_property(self):
 
389
        """commit --fixes=lp:234 sets the lp:234 revprop to 'fixed'."""
 
390
        tree = self.make_branch_and_tree('tree')
 
391
        self.build_tree(['tree/hello.txt'])
 
392
        tree.add('hello.txt')
 
393
        self.run_bzr(
 
394
            'commit', '-m', 'hello', '--fixes=lp:234', 'tree/hello.txt')
 
395
 
 
396
        # Get the revision properties, ignoring the branch-nick property, which
 
397
        # we don't care about for this test.
 
398
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
399
        properties = dict(last_rev.properties)
 
400
        del properties['branch-nick']
 
401
 
 
402
        self.assertEqual({'bugs': 'https://launchpad.net/bugs/234 fixed'},
 
403
                         properties)
 
404
 
 
405
    def test_fixes_multiple_bugs_sets_properties(self):
 
406
        """--fixes can be used more than once to show that bugs are fixed."""
 
407
        tree = self.make_branch_and_tree('tree')
 
408
        self.build_tree(['tree/hello.txt'])
 
409
        tree.add('hello.txt')
 
410
        self.run_bzr(
 
411
            'commit', '-m', 'hello', '--fixes=lp:123', '--fixes=lp:235',
 
412
            'tree/hello.txt')
 
413
 
 
414
        # Get the revision properties, ignoring the branch-nick property, which
 
415
        # we don't care about for this test.
 
416
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
417
        properties = dict(last_rev.properties)
 
418
        del properties['branch-nick']
 
419
 
 
420
        self.assertEqual(
 
421
            {'bugs': 'https://launchpad.net/bugs/123 fixed\n'
 
422
                     'https://launchpad.net/bugs/235 fixed'},
 
423
            properties)
 
424
 
 
425
    def test_fixes_bug_with_alternate_trackers(self):
 
426
        """--fixes can be used on a properly configured branch to mark bug
 
427
        fixes on multiple trackers.
 
428
        """
 
429
        tree = self.make_branch_and_tree('tree')
 
430
        tree.branch.get_config().set_user_option(
 
431
            'trac_twisted_url', 'http://twistedmatrix.com/trac')
 
432
        self.build_tree(['tree/hello.txt'])
 
433
        tree.add('hello.txt')
 
434
        self.run_bzr(
 
435
            'commit', '-m', 'hello', '--fixes=lp:123',
 
436
            '--fixes=twisted:235', 'tree/')
 
437
 
 
438
        # Get the revision properties, ignoring the branch-nick property, which
 
439
        # we don't care about for this test.
 
440
        last_rev = tree.branch.repository.get_revision(tree.last_revision())
 
441
        properties = dict(last_rev.properties)
 
442
        del properties['branch-nick']
 
443
 
 
444
        self.assertEqual(
 
445
            {'bugs': 'https://launchpad.net/bugs/123 fixed\n'
 
446
                     'http://twistedmatrix.com/trac/ticket/235 fixed'},
 
447
            properties)
 
448
 
 
449
    def test_fixes_unknown_bug_prefix(self):
 
450
        tree = self.make_branch_and_tree('tree')
 
451
        self.build_tree(['tree/hello.txt'])
 
452
        tree.add('hello.txt')
 
453
        self.run_bzr_error(
 
454
            ["Unrecognized bug %s. Commit refused." % 'xxx:123'],
 
455
            'commit', '-m', 'add b', '--fixes=xxx:123',
 
456
            working_dir='tree')
 
457
 
 
458
    def test_fixes_invalid_bug_number(self):
 
459
        tree = self.make_branch_and_tree('tree')
 
460
        self.build_tree(['tree/hello.txt'])
 
461
        tree.add('hello.txt')
 
462
        self.run_bzr_error(
 
463
            ["Invalid bug identifier for %s. Commit refused." % 'lp:orange'],
 
464
            'commit', '-m', 'add b', '--fixes=lp:orange',
 
465
            working_dir='tree')
 
466
 
 
467
    def test_fixes_invalid_argument(self):
 
468
        """Raise an appropriate error when the fixes argument isn't tag:id."""
 
469
        tree = self.make_branch_and_tree('tree')
 
470
        self.build_tree(['tree/hello.txt'])
 
471
        tree.add('hello.txt')
 
472
        self.run_bzr_error(
 
473
            [r"Invalid bug orange. Must be in the form of 'tag:id'\. "
 
474
             r"Commit refused\."],
 
475
            'commit', '-m', 'add b', '--fixes=orange',
 
476
            working_dir='tree')