blob: c09dea141a76c9bb22e173eb63f5f7b5651c2cce (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
import patchstate as ps
import io, os, sys
def main(args):
args = iter(args)
arg0 = next(args)
@ps.argparse_all(args)
def path(arg):
raise RuntimeError(f'Invalid argument: {arg!r}')
[repo_path] = path
repo = ps.Repository(repo_path)
with io.open(os.path.join(repo.path, 'series'), 'r') as f:
pcur = ps.Series.parse(f.read())
idmap = {}
for i,pi in enumerate(pcur.info):
h = pi.patch_hash
try:
h = repo.aliases[h]
except KeyError:
pass
p = repo.patches[h]
if pi.patch_id in idmap:
raise RuntimeError(f'duplicate patch id: {pi.patch_id!r}')
idmap[pi.patch_id] = p.id
pcur.info[i] = pi.update(patch=p)
print(idmap)
for i,pi in enumerate(pcur.info):
m = pi.mode
if m.startswith('reverts '):
m = f'reverts {idmap[m[8:]]}'
pcur.info[i] = pi.update(mode=m)
pcur = pcur.fmt()
with io.open(os.path.join(repo.path, 'series'), 'w') as f:
f.write(pcur)
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))
|