Mercurial > dotfiles
comparison unixSoft/bin/hgimp @ 391:24d75bc4a3a1
hgimp: add support for using --partial on imported patches
Most of the time that's not what I want, but recently it was useful a couple
of times in a row.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Wed, 16 Mar 2016 14:32:55 -0400 |
parents | 2ac43cd7bbf7 |
children | 957632211aa3 |
comparison
equal
deleted
inserted
replaced
389:2dd040318107 | 391:24d75bc4a3a1 |
---|---|
14 | 14 |
15 def main(argv): | 15 def main(argv): |
16 p = argparse.ArgumentParser('import patches') | 16 p = argparse.ArgumentParser('import patches') |
17 p.add_argument('repo', type=str, nargs=1, | 17 p.add_argument('repo', type=str, nargs=1, |
18 help='repo name to apply patches to') | 18 help='repo name to apply patches to') |
19 p.add_argument('--partial', action='store_true', | |
20 help='Commit partially-applied patches.') | |
19 args = p.parse_args(argv[1:]) | 21 args = p.parse_args(argv[1:]) |
20 name, = args.repo | 22 name, = args.repo |
21 if name in _MAP: | 23 if name in _MAP: |
22 repo = _MAP[name] | 24 repo = _MAP[name] |
23 else: | 25 else: |
31 elif len(c) != 1: | 33 elif len(c) != 1: |
32 print 'abort: ambiguous repo name %s matches %s' % ( | 34 print 'abort: ambiguous repo name %s matches %s' % ( |
33 name, ', '.join(c)) | 35 name, ', '.join(c)) |
34 sys.exit(1) | 36 sys.exit(1) |
35 repo = _MAP[c[0]] | 37 repo = _MAP[c[0]] |
36 hg = subprocess.Popen(['hg', '-R', repo, 'import', '--obsolete', '-'], | 38 importargs = ['hg', '-R', repo, 'import', '--obsolete'] |
37 stdin=subprocess.PIPE) | 39 if args.partial: |
40 importargs.append('--partial') | |
41 importargs.append('-') | |
42 hg = subprocess.Popen(importargs, stdin=subprocess.PIPE) | |
38 hg.stdin.write(sys.stdin.read()) | 43 hg.stdin.write(sys.stdin.read()) |
39 hg.stdin.close() | 44 hg.stdin.close() |
40 hg.wait() | 45 hg.wait() |
41 sys.exit(hg.returncode) | 46 sys.exit(hg.returncode) |
42 | 47 |