~divmod-dev/divmod.org/build-nevow-without-importing-2699

« back to all changes in this revision

Viewing changes to Combinator/combinator/branchmgr.py

  • Committer: exarkun
  • Date: 2009-02-03 17:15:32 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:17177
Revert 17176 - test suite regression

Two Combinator tests fail with this changeset:

{{{
===============================================================================
[ERROR]: combinator.test.test_branchmgr.BranchManagerChangeBranchTests.test_mergeTrunk

Traceback (most recent call last):
  File "/var/lib/buildbot/divmod-bigdogvm1/q-linux/build/Divmod/Combinator/combinator/test/test_branchmgr.py", line 534, in test_mergeTrunk
    self.assertEqual(err.args, ())
exceptions.AttributeError: InvalidBranch instance has no attribute args
===============================================================================
[ERROR]: combinator.test.test_branchmgr.FakeBranchManagerChangeBranchTests.test_mergeTrunk

Traceback (most recent call last):
  File "/var/lib/buildbot/divmod-bigdogvm1/q-linux/build/Divmod/Combinator/combinator/test/test_branchmgr.py", line 534, in test_mergeTrunk
    self.assertEqual(err.args, ())
exceptions.AttributeError: InvalidBranch instance has no attribute args
===============================================================================
}}}

Reopens #2791

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    """
37
37
    An attempt was made to use a branch in a way which is not allowed for that
38
38
    branch.
39
 
 
40
 
    @type branch: C{str}
41
 
    @param branch: The name of the invalid branch
42
39
    """
43
 
    def __init__(self, branch):
44
 
        self.branch = branch
45
40
 
46
41
 
47
42
class MissingCreationRevision(ValueError):
387
382
                    ).read().strip()
388
383
 
389
384
 
390
 
    def newProjectBranch(self, projectName, branchName, fromBranchName='trunk'):
 
385
    def newProjectBranch(self, projectName, branchName):
391
386
        """
392
387
        Create a new branch of trunk of the given project.
393
388
 
398
393
        @type branchName: C{str}
399
394
        @param branchName: The new branch's name.
400
395
        """
401
 
        trunkURI = self.projectBranchURI(projectName, fromBranchName)
 
396
        trunkURI = self.projectBranchURI(projectName, 'trunk')
402
397
        branchURI = self.projectBranchURI(projectName, branchName)
403
 
        # optimize away this url exists test for the common case, where
404
 
        # fromBranchName = 'trunk'
405
 
        if fromBranchName != 'trunk' and not subversionURLExists(trunkURI):
406
 
            raise NonExistentBranch(fromBranchName)
407
398
        if subversionURLExists(branchURI):
408
399
            raise DuplicateBranch(branchName)
409
400
        runcmd('svn', 'cp', trunkURI, branchURI, '-m',
411
402
        self.changeProjectBranch(projectName, branchName, revert=False)
412
403
 
413
404
 
414
 
    def mergeProjectBranch(self, projectName, targetBranch='trunk', force=False):
 
405
    def mergeProjectBranch(self, projectName, force=False):
415
406
        originalWorkingDirectory = os.getcwd()
416
407
        try:
417
408
            try:
418
409
                currentBranch = self.currentBranchFor(projectName)
419
410
            except IOError:
420
411
                raise MissingTrunkLocation(projectName)
421
 
            if currentBranch == targetBranch:
422
 
                raise InvalidBranch(currentBranch)
 
412
            if currentBranch == "trunk":
 
413
                raise InvalidBranch()
423
414
            branchDir = self.projectBranchDir(projectName, currentBranch)
424
415
            os.chdir(branchDir)
425
416
            rev = None
429
420
                    rev = node.getAttribute("revision")
430
421
            if rev is None:
431
422
                raise MissingCreationRevision("No revision found")
432
 
            trunkDir = self.projectBranchDir(projectName, branchPath=targetBranch)
 
423
            trunkDir = self.projectBranchDir(projectName)
433
424
            os.chdir(trunkDir)
434
425
            if not force:
435
426
                statusf = runcmd('svn', 'status', '--quiet')
440
431
            runcmd('svn', 'merge',
441
432
                   branchDir + "/@" + rev,
442
433
                   branchDir + "/@HEAD")
443
 
            self.changeProjectBranch(projectName, targetBranch)
 
434
            self.changeProjectBranch(projectName, 'trunk')
444
435
        finally:
445
436
            os.chdir(originalWorkingDirectory)
446
437
 
647
638
        raise SystemExit(
648
639
            "Can't unbranch while trunk working copy contains modifications.")
649
640
    except InvalidBranch, e:
650
 
        raise SystemExit("Cannot merge %s." % e.branch)
 
641
        raise SystemExit("Cannot merge trunk.")
651
642
 
652
643
 
653
644
 
701
692
    Merge the active branch of a project into the trunk working copy of that
702
693
    project.  This is the main function for the C{unbranch} command.
703
694
 
704
 
    @param args: A list of two required elements and a third optional element:
 
695
    @param args: A list of two elements:
705
696
      1. The name of the unbranch executable.
706
697
      2. The name of the project for which to merge a branch.
707
 
      3. The name of the branch to which the merge should be delivered.
708
 
         (default 'trunk')
709
698
    """
710
699
    force = False
711
700
    if "--force" in args:
712
701
        force = True
713
702
        args.remove("--force")
714
 
    if len(args) in (2, 3):
715
 
        if len(args) == 2:
716
 
            targetBranch = 'trunk'
717
 
        else:
718
 
            targetBranch = args[2]
 
703
    if len(args) == 2:
719
704
        return _combinatorMain(theBranchManager.mergeProjectBranch,
720
 
                               args[1], targetBranch, force)
721
 
    _combinatorUsage(args[0], "[--force] <project> [<target branch name>]")
 
705
                               args[1], force)
 
706
    _combinatorUsage(args[0], "[--force] <project>")
722
707
 
723
708
 
724
709
 
727
712
    Create a new branch for a project and make it active.  This is the main
728
713
    function for the C{mkbranch} command.
729
714
 
730
 
    @param args: A list of three required elements and a fourth optional element:
 
715
    @param args: A list of three elements:
731
716
      1. The name of the mkbranch executable.
732
717
      2. The name of the project for which to create a new branch.
733
718
      3. The name to give to the newly created branch.
734
 
      4. The name of the branch from which to sprout the new branch.
735
 
         (default 'trunk')
736
719
    """
737
 
    if len(args) in (3, 4):
 
720
    if len(args) == 3:
738
721
        return _combinatorMain(theBranchManager.newProjectBranch, *args[1:])
739
 
    _combinatorUsage(args[0], "<project> <branch name> [<source branch name>]")
 
722
    _combinatorUsage(args[0], "<project> <branch name>")
740
723
 
741
724
 
742
725
theBranchManager = BranchManager()