2019-11-13 16:19:19 -08:00
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
def build_filter(args):
|
|
|
|
|
return Filter(args)
|
|
|
|
|
|
|
|
|
|
class Filter:
|
|
|
|
|
|
|
|
|
|
def __init__(self, args):
|
|
|
|
|
args = args.split(',')
|
2020-07-31 10:38:24 +02:00
|
|
|
self.branch_name = args[0].encode('ascii', 'replace')
|
|
|
|
|
self.starting_commit_hash = args[1].encode('ascii', 'strict')
|
2019-11-13 16:19:19 -08:00
|
|
|
self.branch_parents = set()
|
|
|
|
|
|
|
|
|
|
def commit_message_filter(self, commit_data):
|
2020-07-31 10:38:24 +02:00
|
|
|
hg_hash = commit_data['hg_hash']
|
2019-11-13 16:19:19 -08:00
|
|
|
rev = commit_data['revision']
|
|
|
|
|
rev_parents = commit_data['parents']
|
2020-07-31 10:38:24 +02:00
|
|
|
if (hg_hash == self.starting_commit_hash
|
2019-11-13 16:19:19 -08:00
|
|
|
or any(rp in self.branch_parents for rp in rev_parents)
|
|
|
|
|
):
|
|
|
|
|
self.branch_parents.add(rev)
|
2020-07-31 10:38:24 +02:00
|
|
|
commit_data['branch'] = self.branch_name
|
2019-11-13 16:19:19 -08:00
|
|
|
sys.stderr.write('\nchanging r%s to branch %r\n' % (rev, self.branch_name))
|
|
|
|
|
sys.stderr.flush()
|