Mercurial会为每一个销毁操作(如histedit,rebase和strip)备份提交/变更集。就我而言,它有很多这样的文件。
如何将这些扩展名为.hg的文件转换为补丁,以便我们可以检查其内容?
我看过https://www.mercurial-scm.org/wiki/ManuallyUnpackingStripBundle,但没有帮助。
import os
import glob
import bz2
for filepath in glob.glob(os.path.join('hg-cs-bundles', '*.hg')):
i = 1
with open(filepath) as f:
content = f.read()
b = bz2.decompress("BZ" + content[6:])
open(str(i)+".patch", "w").write(b)
i = i + 1
python convert.py
Traceback (most recent call last):
File "convert.py", line 9, in <module>
b = bz2.decompress("BZ" + content[6:])
IOError: invalid data stream