Some patch-update & vim ft improvements

- Stash off some gen files when switching patch branches.
- Set the filetype in "env -S" files that vim can't handle.
This commit is contained in:
Wayne Davison
2020-06-27 12:06:13 -07:00
parent 3a6f06003c
commit 0eec25f75b
5 changed files with 44 additions and 5 deletions

1
.gitignore vendored
View File

@@ -49,4 +49,5 @@ aclocal.m4
/testsuite/xattrs-hlink.test
/patches
/SaVeDiR
/.gen-stash
.deps

View File

@@ -171,4 +171,4 @@ if __name__ == '__main__':
args = parser.parse_args()
main()
# vim: sw=4 et
# vim: sw=4 et ft=python

View File

@@ -31,6 +31,10 @@ def main():
starting_branch, args.base_branch = check_git_state(args.base_branch, not args.skip_check, args.patches_dir)
gen_stash(starting_branch)
if starting_branch == 'master':
cmd_run('md5sum configure.ac >.gen-stash/configure.ac.sum')
master_commit = latest_git_hash(args.base_branch)
if args.gen:
@@ -95,6 +99,8 @@ def main():
time.sleep(1)
cmd_chk(['git', 'checkout', starting_branch])
gen_unstash(starting_branch)
def update_patch(patch):
global last_touch
@@ -115,13 +121,16 @@ def update_patch(patch):
while args.gen and last_touch >= time.time():
time.sleep(1)
s = cmd_run(f"git checkout patch/{args.base_branch}/{patch}".split())
branch = f"patch/{args.base_branch}/{patch}"
s = cmd_run(['git', 'checkout', branch])
if s.returncode != 0:
return 0
s = cmd_run(['git', 'merge', based_on])
ok = s.returncode == 0
if not ok or args.shell:
gen_unstash(branch)
m = re.search(r'([^/]+)$', parent)
parent_dir = m[1]
if not ok:
@@ -138,6 +147,7 @@ def update_patch(patch):
if is_clean:
break
print(status_txt, end='')
gen_stash(branch)
with open(f"{args.patches_dir}/{patch}.diff", 'w', encoding='utf-8') as fh:
fh.write(description[patch])
@@ -191,6 +201,34 @@ def update_patch(patch):
return 1
# The autoconf cache dir can totally mess up if 2 different *.ac files have the same mtime!
def gen_stash_prep(branch):
if os.path.isdir('autom4te.cache'):
shutil.rmtree('autom4te.cache')
return '.gen-stash/' + branch.replace('/', '%') + '.tar.gz'
def gen_stash(branch):
files = 'configure.sh config.h.in Makefile'.split()
for fn in files:
if not os.path.exists(fn):
return
if not os.path.isdir('.gen-stash'):
os.mkdir('.gen-stash', 0o700)
tar_fn = gen_stash_prep(branch)
cmd_run(['./prepare-source'])
cmd_chk(['tar', 'czf', tar_fn, *files])
def gen_unstash(branch):
tar_fn = gen_stash_prep(branch)
if os.path.exists(tar_fn):
cmd_chk(['tar', 'xf', tar_fn])
out, rc = cmd_txt_status('md5sum --status -c .gen-stash/configure.ac.sum'.split())
if rc:
print('*' * 10, "configure.ac differs from master version", '*' * 10)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Turn a git branch back into a diff files in the patches dir.", add_help=False)
parser.add_argument('--branch', '-b', dest='base_branch', metavar='BASE_BRANCH', default='master', help="The branch the patch is based on. Default: master.")
@@ -207,4 +245,4 @@ if __name__ == '__main__':
args.patches_dir = args.gen
main()
# vim: sw=4 et
# vim: sw=4 et ft=python

View File

@@ -381,4 +381,4 @@ if __name__ == '__main__':
args = parser.parse_args()
main()
# vim: sw=4 et
# vim: sw=4 et ft=python

View File

@@ -84,4 +84,4 @@ if __name__ == '__main__':
args = parser.parse_args()
main()
# vim: sw=4 et
# vim: sw=4 et ft=python