- Files:
-
- 26 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
/mergebot/branches/ticket-1/mergebot/SvnOps.py
r30 r20 69 69 skipped_regex = re.compile("Skipped.* '(.*)'", re.M) 70 70 start_rev, end_rev = revision_range 71 pipe = os.popen("cd %s && svn merge -- non-interactive --revision %s:%s %s . 2>>%s" % \71 pipe = os.popen("cd %s && svn merge --revision %s:%s %s . 2>>%s" % \ 72 72 (workingdir, start_rev, end_rev, from_url, logfile)) 73 73 output = pipe.readlines() … … 79 79 filename = skipped_regex.findall(line)[0] 80 80 status = "C" 81 elif line.startswith('--- Merging '):82 continue # ignore this line for now83 elif line.startswith('Summary of conflicts:'):84 continue # ignore this line for now85 elif line.startswith(' Text conflicts:'):86 continue # ignore this line for now87 81 else: 88 82 assert line[4] == ' ', "Unexpected output from svn merge " \ -
/mergebot/trunk/README.txt
r30 r20 3 3 $ svn co <url> mergebot-0.11 4 4 $ cd mergebot-0.11 5 $ python setup.py bdist_rpm5 $ ./rpm/makerpm 6 6 $ su -c "rpm --install dist/TracMergeBot*.noarch.rpm" 7 7 # Create the mergebot work area -
/mergebot/trunk/mergebot/Actor.py
r30 r20 1 """Base class for mergebot actors that do the various kinds of tasks2 """3 1 import os 4 from mergebot import SvnOps5 2 6 3 class Actor(object): 7 """Base class for mergebot actors"""8 4 def __init__(self, work_dir, repo_url, repo_dir, ticket, component, 9 5 version, summary, requestor): … … 27 23 28 24 def logfilename(self): 29 """Returns the absolute path of the logfile for this ticket"""30 25 return os.path.abspath(os.path.join(os.path.dirname(self.work_dir), 31 26 'ticket-%s.log' % self.ticket)) 32 27 33 28 def public_url(self): 34 """Returns the public URL for this component"""35 29 return '%s/%s' % (self.repo_url, self.component) 36 30 … … 41 35 42 36 def local_url(self): 43 """Returns the local URL for this component"""44 37 return 'file://%s/%s' % (self.repo_dir, self.component) 45 38 … … 55 48 56 49 def version_subdir(self): 57 """Returns the subdirectory name for the version"""58 50 if self.version == 'trunk': 59 51 subdir = 'trunk' … … 66 58 return subdir 67 59 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.component73 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.component76 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 None80 -
/mergebot/trunk/mergebot/BranchActor.py
r30 r20 2 2 """Module for creating new branches for tickets""" 3 3 4 import os 4 5 import time 5 6 … … 19 20 20 21 # Make sure the various urls we require do exist 21 problems = self.check_required_directories() 22 if problems: 23 return results, problems, False 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 24 32 25 33 commit_header = 'Ticket #%s: %s' % (self.ticket, self.summary) … … 27 35 # Delete the branch if it already exists. This can happen if the branch 28 36 # was merged, but we're still working on it. 29 if SvnOps. does_url_exist(self.branch_local_url()):37 if SvnOps.get_branch_info(self.branch_local_url(), logfile): 30 38 # This branch already exists. 31 39 commit_message = "\n".join([commit_header, … … 51 59 comment = 'Failed to create branch.' 52 60 return results, comment, False 53 54 61 results['mergebotstate'] = 'branched' 55 62 comment = '\n'.join([ 56 63 'Created branch from %s for %s.' % (self.version, self.requestor), 57 64 '', 58 'Browse branch [source:%s/branches/ticket-%s source code] and ' \ 59 '[log:%s/branches/ticket-%s commit log].' % 65 'Browse branch [source:%s/branches/ticket-%s source code] and [log:%s/branches/ticket-%s commit log].' % 60 66 (self.component, self.ticket, self.component, self.ticket), 61 67 '', -
/mergebot/trunk/mergebot/CheckMergeActor.py
r30 r20 28 28 29 29 # Make sure the various urls we require do exist 30 problems = self.check_required_directories() 31 if problems: 32 return results, problems, False 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 33 42 34 43 branch_info = SvnOps.get_branch_info(self.branch_local_url(), logfile) -
/mergebot/trunk/mergebot/MergeActor.py
r30 r20 26 26 27 27 # Make sure the various urls we require do exist 28 problems = self.check_required_directories() 29 if problems: 30 return results, problems, False 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 31 38 32 39 rev_info = SvnOps.get_branch_info(self.branch_local_url(), logfile) 33 40 if not rev_info: 34 comment = 'Branch for ticket %s does not exist in the repository.' \ 35 % (self.ticket) 41 comment = 'Branch for ticket %s does not exist in the repository.' % (self.ticket) 36 42 return results, comment, False 37 43 startrev, endrev = rev_info -
/mergebot/trunk/mergebot/RebranchActor.py
r30 r20 36 36 37 37 # Make sure the various urls we require do exist 38 problems = self.check_required_directories() 39 if problems: 40 return results, problems, False 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 41 50 42 51 rev_info = SvnOps.get_branch_info(self.branch_local_url(), logfile) … … 88 97 "Rebranch internal error: Unable to recreate the branch. %s" \ 89 98 % (instructioncomment, )), 99 (lambda x: SvnOps.checkout(self.branch_local_url(), workingcopy, x), 100 "Rebranch internal error: Unable to get working copy. %s" % \ 101 (instructioncomment, )), 90 102 ) 91 103 for cmd, error_comment in commanderrors: … … 96 108 results['mergebotstate'] = 'rebranchfailed' 97 109 return results, error_comment, False 98 99 # Check to see if there have been no commits on the branch. If there100 # 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, True111 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 instructioncomment117 if os.path.exists(workingcopy):118 shutil.rmtree(workingcopy)119 results['mergebotstate'] = 'rebranchfailed'120 return results, error_comment, False121 110 122 111 # On success, we're in the same state as if we had just branched. … … 146 135 "commit your work to the branch.", 147 136 ]) 148 success = False # the rebranch failed because there were conflicts149 137 else: # No conflicts, do the commit. 150 138 mergemessage = "\n".join([ -
/mergebot/trunk/mergebot/SvnOps.py
r30 r20 8 8 import time 9 9 import re 10 import subprocess11 10 12 11 def shell_quote(string): … … 25 24 """Given a log entry split out of svn log, return its revision number""" 26 25 return int(logentry.split()[0][1:]) 27 28 def 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 35 def 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 42 does_url_exist=does_url_exist_14 # default to most compatible form for now43 26 44 27 def get_branch_info(url, logfile): -
/mergebot/trunk/setup.py
r30 r20 5 5 setup( 6 6 name = "TracMergeBot", 7 version = "0.11 .1",7 version = "0.11", 8 8 author = "Eli Carter", 9 9 author_email = "eli.carter@retracile.net",
Note: See TracChangeset
for help on using the changeset viewer.