Changes in / [20:30]


Ignore:
Files:
7 added
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • /mergebot/branches/ticket-1/mergebot/SvnOps.py

    r20 r30  
    6969    skipped_regex = re.compile("Skipped.* '(.*)'", re.M) 
    7070    start_rev, end_rev = revision_range 
    71     pipe = os.popen("cd %s && svn merge --revision %s:%s %s . 2>>%s" % \ 
     71    pipe = os.popen("cd %s && svn merge --non-interactive --revision %s:%s %s . 2>>%s" % \ 
    7272        (workingdir, start_rev, end_rev, from_url, logfile)) 
    7373    output = pipe.readlines() 
     
    7979            filename = skipped_regex.findall(line)[0] 
    8080            status = "C" 
     81        elif line.startswith('--- Merging '): 
     82            continue # ignore this line for now 
     83        elif line.startswith('Summary of conflicts:'): 
     84            continue # ignore this line for now 
     85        elif line.startswith('  Text conflicts:'): 
     86            continue # ignore this line for now 
    8187        else: 
    8288            assert line[4] == ' ', "Unexpected output from svn merge " \ 
  • /mergebot/trunk/README.txt

    r20 r30  
    33$ svn co <url> mergebot-0.11 
    44$ cd mergebot-0.11 
    5 $ ./rpm/makerpm 
     5$ python setup.py bdist_rpm 
    66$ su -c "rpm --install dist/TracMergeBot*.noarch.rpm" 
    77# Create the mergebot work area 
  • /mergebot/trunk/mergebot/Actor.py

    r20 r30  
     1"""Base class for mergebot actors that do the various kinds of tasks 
     2""" 
    13import os 
     4from mergebot import SvnOps 
    25 
    36class Actor(object): 
     7    """Base class for mergebot actors""" 
    48    def __init__(self, work_dir, repo_url, repo_dir, ticket, component, 
    59                 version, summary, requestor): 
     
    2327 
    2428    def logfilename(self): 
     29        """Returns the absolute path of the logfile for this ticket""" 
    2530        return os.path.abspath(os.path.join(os.path.dirname(self.work_dir), 
    2631            'ticket-%s.log' % self.ticket)) 
    2732 
    2833    def public_url(self): 
     34        """Returns the public URL for this component""" 
    2935        return '%s/%s' % (self.repo_url, self.component) 
    3036 
     
    3541 
    3642    def local_url(self): 
     43        """Returns the local URL for this component""" 
    3744        return 'file://%s/%s' % (self.repo_dir, self.component) 
    3845 
     
    4855 
    4956    def version_subdir(self): 
     57        """Returns the subdirectory name for the version""" 
    5058        if self.version == 'trunk': 
    5159            subdir = 'trunk' 
     
    5866        return subdir 
    5967 
     68    def check_required_directories(self): 
     69        """Make sure the various urls we require do exist""" 
     70        if not SvnOps.does_url_exist(self.local_url()): 
     71            return 'Component %s does not exist in the repository.' \ 
     72                % self.component 
     73        if not SvnOps.does_url_exist(self.local_url() + '/branches'): 
     74            return 'No directory in which to create branches for ' \ 
     75                'component %s in the repository.' % self.component 
     76        if not SvnOps.does_url_exist(self.baseline_local_url()): 
     77            return 'Version %s for component %s does not exist in the ' \ 
     78                'repository.' % (self.version, self.component) 
     79        return None 
     80 
  • /mergebot/trunk/mergebot/BranchActor.py

    r20 r30  
    22"""Module for creating new branches for tickets""" 
    33 
    4 import os 
    54import time 
    65 
     
    2019 
    2120        # Make sure the various urls we require do exist 
    22         if not SvnOps.get_branch_info(self.local_url(), logfile): 
    23             comment = 'Component %s does not exist in the repository.' \ 
    24                 % self.component 
    25             return results, comment, False 
    26         if not SvnOps.get_branch_info(self.local_url() + '/branches', logfile): 
    27             comment = 'No directory in which to create branches for component %s in the repository.' % self.component 
    28             return results, comment, False 
    29         if not SvnOps.get_branch_info(self.baseline_local_url(), logfile): 
    30             comment = 'Version %s for component %s does not exist in the repository.' % (self.version, self.component) 
    31             return results, comment, False 
     21        problems = self.check_required_directories() 
     22        if problems: 
     23            return results, problems, False 
    3224 
    3325        commit_header = 'Ticket #%s: %s' % (self.ticket, self.summary) 
     
    3527        # Delete the branch if it already exists.  This can happen if the branch 
    3628        # was merged, but we're still working on it. 
    37         if SvnOps.get_branch_info(self.branch_local_url(), logfile): 
     29        if SvnOps.does_url_exist(self.branch_local_url()): 
    3830            # This branch already exists. 
    3931            commit_message = "\n".join([commit_header, 
     
    5951            comment = 'Failed to create branch.' 
    6052            return results, comment, False 
     53 
    6154        results['mergebotstate'] = 'branched' 
    6255        comment = '\n'.join([ 
    6356            'Created branch from %s for %s.' % (self.version, self.requestor), 
    6457            '', 
    65             'Browse branch [source:%s/branches/ticket-%s source code] and [log:%s/branches/ticket-%s commit log].' %  
     58            'Browse branch [source:%s/branches/ticket-%s source code] and ' \ 
     59                '[log:%s/branches/ticket-%s commit log].' %  
    6660                (self.component, self.ticket, self.component, self.ticket), 
    6761            '', 
  • /mergebot/trunk/mergebot/CheckMergeActor.py

    r20 r30  
    2828 
    2929        # Make sure the various urls we require do exist 
    30         if not SvnOps.get_branch_info(self.local_url(), logfile): 
    31             comment = 'Component %s does not exist in the repository.' \ 
    32                 % self.component 
    33             return results, comment, False 
    34         if not SvnOps.get_branch_info(self.local_url() + '/branches', logfile): 
    35             comment = 'No directory in which to create branches for ' \ 
    36                 'component %s in the repository.' % self.component 
    37             return results, comment, False 
    38         if not SvnOps.get_branch_info(self.baseline_local_url(), logfile): 
    39             comment = 'Version %s for component %s does not exist in the ' \ 
    40                 'repository.' % (self.version, self.component) 
    41             return results, comment, False 
     30        problems = self.check_required_directories() 
     31        if problems: 
     32            return results, problems, False 
    4233 
    4334        branch_info = SvnOps.get_branch_info(self.branch_local_url(), logfile) 
  • /mergebot/trunk/mergebot/MergeActor.py

    r20 r30  
    2626 
    2727        # Make sure the various urls we require do exist 
    28         if not SvnOps.get_branch_info(self.local_url(), logfile): 
    29             comment = 'Component %s does not exist in the repository.' \ 
    30                 % self.component 
    31             return results, comment, False 
    32         if not SvnOps.get_branch_info(self.local_url() + '/branches', logfile): 
    33             comment = 'No directory in which to create branches for component %s in the repository.' % self.component 
    34             return results, comment, False 
    35         if not SvnOps.get_branch_info(self.baseline_local_url(), logfile): 
    36             comment = 'Version %s for component %s does not exist in the repository.' % (self.version, self.component) 
    37             return results, comment, False 
     28        problems = self.check_required_directories() 
     29        if problems: 
     30            return results, problems, False 
    3831 
    3932        rev_info = SvnOps.get_branch_info(self.branch_local_url(), logfile) 
    4033        if not rev_info: 
    41             comment = 'Branch for ticket %s does not exist in the repository.' % (self.ticket) 
     34            comment = 'Branch for ticket %s does not exist in the repository.' \ 
     35                % (self.ticket) 
    4236            return results, comment, False 
    4337        startrev, endrev = rev_info 
  • /mergebot/trunk/mergebot/RebranchActor.py

    r20 r30  
    3636 
    3737        # Make sure the various urls we require do exist 
    38         if not SvnOps.get_branch_info(self.local_url(), logfile): 
    39             comment = 'Component %s does not exist in the repository.' \ 
    40                 % self.component 
    41             return results, comment, False 
    42         if not SvnOps.get_branch_info(self.local_url() + '/branches', logfile): 
    43             comment = 'No directory in which to create branches for ' \ 
    44                 'component %s in the repository.' % self.component 
    45             return results, comment, False 
    46         if not SvnOps.get_branch_info(self.baseline_local_url(), logfile): 
    47             comment = 'Version %s for component %s does not exist in the ' \ 
    48                 'repository.' % (self.version, self.component) 
    49             return results, comment, False 
     38        problems = self.check_required_directories() 
     39        if problems: 
     40            return results, problems, False 
    5041 
    5142        rev_info = SvnOps.get_branch_info(self.branch_local_url(), logfile) 
     
    9788                "Rebranch internal error: Unable to recreate the branch.  %s" \ 
    9889                    % (instructioncomment, )), 
    99             (lambda x: SvnOps.checkout(self.branch_local_url(), workingcopy, x), 
    100                 "Rebranch internal error: Unable to get working copy.  %s" % \ 
    101                     (instructioncomment, )), 
    10290        ) 
    10391        for cmd, error_comment in commanderrors: 
     
    10896                results['mergebotstate'] = 'rebranchfailed' 
    10997                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 
    110121 
    111122        # On success, we're in the same state as if we had just branched. 
     
    135146                    "commit your work to the branch.", 
    136147            ])  
     148            success = False # the rebranch failed because there were conflicts 
    137149        else: # No conflicts, do the commit. 
    138150            mergemessage = "\n".join([ 
  • /mergebot/trunk/mergebot/SvnOps.py

    r20 r30  
    88import time 
    99import re 
     10import subprocess 
    1011 
    1112def shell_quote(string): 
     
    2425    """Given a log entry split out of svn log, return its revision number""" 
    2526    return int(logentry.split()[0][1:]) 
     27 
     28def does_url_exist_14(url): 
     29    """Given a subversion url return true if it exists, false otherwise.""" 
     30    return not subprocess.call(['svn', 'log', '--limit=1', '--non-interactive', 
     31                                url], 
     32                    stdout=open('/dev/null', 'w'), 
     33                    stderr=open('/dev/null', 'w')) 
     34 
     35def does_url_exist_15(url): 
     36    """Given a subversion url return true if it exists, false otherwise.""" 
     37    return not subprocess.call(['svn', 'ls', '--depth', 'empty', 
     38                                '--non-interactive', url], 
     39                    stdout=open('/dev/null', 'w'), 
     40                    stderr=open('/dev/null', 'w')) 
     41 
     42does_url_exist=does_url_exist_14 # default to most compatible form for now 
    2643 
    2744def get_branch_info(url, logfile): 
  • /mergebot/trunk/setup.py

    r20 r30  
    55setup( 
    66    name = "TracMergeBot", 
    7     version = "0.11", 
     7    version = "0.11.1", 
    88    author = "Eli Carter", 
    99    author_email = "eli.carter@retracile.net", 
Note: See TracChangeset for help on using the changeset viewer.