74 if not repo.is_valid(): |
74 if not repo.is_valid(): |
75 # If the repo does not exist, clone it. |
75 # If the repo does not exist, clone it. |
76 try: |
76 try: |
77 repo.clone() |
77 repo.clone() |
78 |
78 |
79 # We need to un-alias a few things, they may be aliased on the host machine (e.g. mine) |
79 # We need to un-alias a few things in case they're aliased |
80 comms=['log', 'incoming', 'pull', 'commit', 'push', 'outgoing', 'strip', 'transplant'] |
80 comms=['log', 'incoming', 'pull', 'commit', 'push', 'outgoing', 'strip', 'transplant'] |
81 try: |
81 try: |
82 with open (os.path.join (repo.name, '.hg', 'hgrc'), 'a') as fp: |
82 with open (os.path.join (repo.name, '.hg', 'hgrc'), 'a') as fp: |
83 fp.write ('\n[alias]\n' + ''.join(['%s=%s\n' % (x, x) for x in comms])) |
83 fp.write ('\n[alias]\n' + ''.join(['%s=%s\n' % (x, x) for x in comms])) |
84 except Exception as e: |
84 except Exception as e: |
85 print ('Warning: unable to alter hgrc of %s: %s' % repo.name, e) |
85 print ('Warning: unable to alter hgrc of %s: %s' % repo.name, e) |
86 print ('Cloning done.') |
86 print ('Cloning done.') |
87 except Exception as e: |
87 except Exception as e: |
88 raise HgProcessError ('Unable to clone %s from %s: %s' % (repo.name, repo.url, e)) |
88 raise HgProcessError ('Unable to clone %s from %s: %s' % (repo.name, repo.clone_url, e)) |
89 quit (1) |
89 quit (1) |
90 |
90 |
91 if not repo.is_valid(): |
91 if not repo.is_valid(): |
92 raise HgProcessError ('''%s is not a valid repository after cloning ''' |
92 raise HgProcessError ('''%s is not a valid repository after cloning ''' |
93 '''(.hg is missing)''' % repo.name) |
93 '''(.hg is missing)''' % repo.name) |
279 (commit['node'], existingrepos)) |
279 (commit['node'], existingrepos)) |
280 continue |
280 continue |
281 |
281 |
282 username = Config.find_developer_by_email (commit['email']) |
282 username = Config.find_developer_by_email (commit['email']) |
283 committer = username if username else commit['author'] |
283 committer = username if username else commit['author'] |
284 descriptor = """commit""" if int (random.random() * 100) != 0 else """KERMIT""" |
284 descriptor = """commit""" if random.randrange (100) != 0 else """KERMIT""" |
285 |
285 |
286 if not isMergeFromSandbox: |
286 if not isMergeFromSandbox: |
287 commitMessage = """\003%d%s\003: new %s\0035 %s%s\003 by\0032 %s\003: %s""" % \ |
287 commitMessage = """\003%d%s\003: new %s\0035 %s%s\003 by\0032 %s\003: %s""" % \ |
288 (repo.color, repo.name, descriptor, commit['node'], commit['bookmarks'], |
288 (repo.color, repo.name, descriptor, commit['node'], commit['bookmarks'], |
289 committer, utility.shorten_link (commit['url'])) |
289 committer, utility.shorten_link (commit['url'])) |
311 |
311 |
312 if match: |
312 if match: |
313 announce_ticket_resolved (match.group (2), commit['node'], db) |
313 announce_ticket_resolved (match.group (2), commit['node'], db) |
314 break |
314 break |
315 |
315 |
316 # Encode messages |
|
317 for messagelist in messages: |
|
318 for i in range (0, len (messagelist)): |
|
319 messagelist[i] = messagelist[i].decode ("utf-8", "ignore").encode("ascii", "ignore") |
|
320 |
|
321 fullMessageLength = len (''.join (messages[2])) |
316 fullMessageLength = len (''.join (messages[2])) |
322 |
317 |
323 if fullMessageLength > 3000: |
318 if fullMessageLength > 3000: |
324 messageSizeClass = LENGTH_MINIMUM |
319 messageSizeClass = LENGTH_MINIMUM |
325 elif fullMessageLength > 768: |
320 elif fullMessageLength > 768: |