Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 27613:dffd2ed9a7c4
import: refactor nocommit and importbranch handling
author | timeless <timeless@mozdev.org> |
---|---|
date | Wed, 30 Dec 2015 21:07:51 +0000 |
parents | a0dfe8d286fe |
children | 0bc71f45d362 |
comparison
equal
deleted
inserted
replaced
27612:a0dfe8d286fe | 27613:dffd2ed9a7c4 |
---|---|
875 branch = extractdata.get('branch') | 875 branch = extractdata.get('branch') |
876 nodeid = extractdata.get('nodeid') | 876 nodeid = extractdata.get('nodeid') |
877 p1 = extractdata.get('p1') | 877 p1 = extractdata.get('p1') |
878 p2 = extractdata.get('p2') | 878 p2 = extractdata.get('p2') |
879 | 879 |
880 nocommit = opts.get('no_commit') | |
881 importbranch = opts.get('import_branch') | |
880 update = not opts.get('bypass') | 882 update = not opts.get('bypass') |
881 strip = opts["strip"] | 883 strip = opts["strip"] |
882 prefix = opts["prefix"] | 884 prefix = opts["prefix"] |
883 sim = float(opts.get('similarity') or 0) | 885 sim = float(opts.get('similarity') or 0) |
884 if not tmpname: | 886 if not tmpname: |
929 if p1 != parents[0]: | 931 if p1 != parents[0]: |
930 updatefunc(repo, p1.node()) | 932 updatefunc(repo, p1.node()) |
931 if p2 != parents[1]: | 933 if p2 != parents[1]: |
932 repo.setparents(p1.node(), p2.node()) | 934 repo.setparents(p1.node(), p2.node()) |
933 | 935 |
934 if opts.get('exact') or opts.get('import_branch'): | 936 if opts.get('exact') or importbranch: |
935 repo.dirstate.setbranch(branch or 'default') | 937 repo.dirstate.setbranch(branch or 'default') |
936 | 938 |
937 partial = opts.get('partial', False) | 939 partial = opts.get('partial', False) |
938 files = set() | 940 files = set() |
939 try: | 941 try: |
944 raise error.Abort(str(e)) | 946 raise error.Abort(str(e)) |
945 if partial: | 947 if partial: |
946 rejects = True | 948 rejects = True |
947 | 949 |
948 files = list(files) | 950 files = list(files) |
949 if opts.get('no_commit'): | 951 if nocommit: |
950 if message: | 952 if message: |
951 msgs.append(message) | 953 msgs.append(message) |
952 else: | 954 else: |
953 if opts.get('exact') or p2: | 955 if opts.get('exact') or p2: |
954 # If you got here, you either use --force and know what | 956 # If you got here, you either use --force and know what |
975 for idfunc in extrapostimport: | 977 for idfunc in extrapostimport: |
976 extrapostimportmap[idfunc](repo[n]) | 978 extrapostimportmap[idfunc](repo[n]) |
977 finally: | 979 finally: |
978 repo.ui.restoreconfig(allowemptyback) | 980 repo.ui.restoreconfig(allowemptyback) |
979 else: | 981 else: |
980 if opts.get('exact') or opts.get('import_branch'): | 982 if opts.get('exact') or importbranch: |
981 branch = branch or 'default' | 983 branch = branch or 'default' |
982 else: | 984 else: |
983 branch = p1.branch() | 985 branch = p1.branch() |
984 store = patch.filestore() | 986 store = patch.filestore() |
985 try: | 987 try: |
1000 branch, files, store, | 1002 branch, files, store, |
1001 editor=editor) | 1003 editor=editor) |
1002 n = memctx.commit() | 1004 n = memctx.commit() |
1003 finally: | 1005 finally: |
1004 store.close() | 1006 store.close() |
1005 if opts.get('exact') and opts.get('no_commit'): | 1007 if opts.get('exact') and nocommit: |
1006 # --exact with --no-commit is still useful in that it does merge | 1008 # --exact with --no-commit is still useful in that it does merge |
1007 # and branch bits | 1009 # and branch bits |
1008 ui.warn(_("warning: can't check exact import with --no-commit\n")) | 1010 ui.warn(_("warning: can't check exact import with --no-commit\n")) |
1009 elif opts.get('exact') and hex(n) != nodeid: | 1011 elif opts.get('exact') and hex(n) != nodeid: |
1010 raise error.Abort(_('patch is damaged or loses information')) | 1012 raise error.Abort(_('patch is damaged or loses information')) |