Changeset 30


Ignore:
Timestamp:
Nov 2, 2009 5:30:43 PM (15 years ago)
Author:
retracile
Message:

Attempt to short-circuit the rebranch logic when dealing with a branch with no commits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mergebot/trunk/mergebot/RebranchActor.py

    r29 r30  
    8888                "Rebranch internal error: Unable to recreate the branch.  %s" \
    8989                    % (instructioncomment, )),
    90             (lambda x: SvnOps.checkout(self.branch_local_url(), workingcopy, x),
    91                 "Rebranch internal error: Unable to get working copy.  %s" % \
    92                     (instructioncomment, )),
    9390        )
    9491        for cmd, error_comment in commanderrors:
     
    9996                results['mergebotstate'] = 'rebranchfailed'
    10097                return results, error_comment, False
     98
     99        # Check to see if there have been no commits on the branch.  If there
     100        # have been no commits, we know we don't need to merge anything.
     101        if startrev == endrev:
     102            ticket_message = "\n".join([
     103                "Rebranched from %s for %s." % (self.version,
     104                                                self.requestor),
     105                "There were no changes to commit to the branch since there "
     106                    "were no commits on the branch.",
     107                "You will need to update your working copy.",
     108            ])
     109            results['mergebotstate'] = 'branched'
     110            return results, ticket_message, True
     111
     112        retval = SvnOps.checkout(self.branch_local_url(), workingcopy, logfile)
     113        if retval:
     114            error_comment = \
     115                "Rebranch internal error: Unable to get working copy.  " + \
     116                instructioncomment
     117            if os.path.exists(workingcopy):
     118                shutil.rmtree(workingcopy)
     119            results['mergebotstate'] = 'rebranchfailed'
     120            return results, error_comment, False
    101121
    102122        # On success, we're in the same state as if we had just branched.
Note: See TracChangeset for help on using the changeset viewer.