git-import-patches 765 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python
  2. import argparse
  3. import os
  4. import sys
  5. from lib import git
  6. from lib.patches import patch_from_dir
  7. def main(argv):
  8. parser = argparse.ArgumentParser()
  9. parser.add_argument("patch_dir",
  10. help="directory containing patches to apply")
  11. parser.add_argument("-3", "--3way",
  12. action="store_true", dest='threeway',
  13. help="use 3-way merge to resolve conflicts")
  14. args = parser.parse_args(argv)
  15. # save the upstream HEAD so we can refer to it when we later export patches
  16. git.update_ref(
  17. repo='.',
  18. ref='refs/patches/upstream-head',
  19. newvalue='HEAD'
  20. )
  21. git.am(
  22. repo='.',
  23. patch_data=patch_from_dir(args.patch_dir),
  24. threeway=args.threeway
  25. )
  26. if __name__ == '__main__':
  27. main(sys.argv[1:])