1 #! /usr/bin/env python3
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 assert __name__
!= '__main__'
9 Any time we vendor[1] from an external git repo, we want to keep a record of the csets
12 This script leaves a record of the merge-base reference tip and cherry-picks that we pull
13 into Gecko. (such as gfx/angle/cherry_picks.txt)
27 def run_checked(*args
, **kwargs
):
30 return subprocess
.run(args
, check
=True, **kwargs
)
34 def record_cherry_picks(dir_in_gecko
, merge_base_origin
):
35 # merge_base_origin is not always 'origin'!
36 merge_base_from
= Path(dir_in_gecko
, 'MERGE_BASE').read_text().split('\n')[0]
37 merge_base_from
= merge_base_origin
+ '/' + merge_base_from
39 assert '/' in merge_base_from
, 'Please specify a reference tip from a remote.'
40 log_path
= Path(dir_in_gecko
, 'cherry_picks.txt')
41 print_now('Logging cherry picks to {}.'.format(log_path
))
43 merge_base
= run_checked('git', 'merge-base', 'HEAD', merge_base_from
,
44 stdout
=subprocess
.PIPE
).stdout
.decode().strip()
46 mb_info
= run_checked('git', 'log', '{}~1..{}'.format(merge_base
, merge_base
),
47 stdout
=subprocess
.PIPE
).stdout
48 cherries
= run_checked('git', 'log', merge_base
+ '..', stdout
=subprocess
.PIPE
).stdout
50 with
open(log_path
, 'wb') as f
:
52 f
.write(b
'\nCherries picked')
53 f
.write(b
'\n' + (b
'=' * 80))
54 f
.write(b
'\nMerge base from: ' + merge_base_from
.encode())