3996 (r, repo[r], rev, ctx)) |
3996 (r, repo[r], rev, ctx)) |
3997 revs.remove(r) |
3997 revs.remove(r) |
3998 if not revs: |
3998 if not revs: |
3999 return -1 |
3999 return -1 |
4000 |
4000 |
4001 try: |
4001 for pos, ctx in enumerate(repo.set("%ld", revs)): |
4002 for pos, ctx in enumerate(repo.set("%ld", revs)): |
4002 desc = '%d:%s "%s"' % (ctx.rev(), ctx, |
4003 desc = '%d:%s "%s"' % (ctx.rev(), ctx, |
4003 ctx.description().split('\n', 1)[0]) |
4004 ctx.description().split('\n', 1)[0]) |
4004 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) |
4005 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node()) |
4005 if names: |
4006 if names: |
4006 desc += ' (%s)' % ' '.join(names) |
4007 desc += ' (%s)' % ' '.join(names) |
4007 ui.status(_('grafting %s\n') % desc) |
4008 ui.status(_('grafting %s\n') % desc) |
4008 if opts.get('dry_run'): |
4009 if opts.get('dry_run'): |
4009 continue |
4010 continue |
4010 |
4011 |
4011 extra = ctx.extra().copy() |
4012 extra = ctx.extra().copy() |
4012 del extra['branch'] |
4013 del extra['branch'] |
4013 source = extra.get('source') |
4014 source = extra.get('source') |
4014 if source: |
4015 if source: |
4015 extra['intermediate-source'] = ctx.hex() |
4016 extra['intermediate-source'] = ctx.hex() |
4016 else: |
4017 else: |
4017 extra['source'] = ctx.hex() |
4018 extra['source'] = ctx.hex() |
4018 user = ctx.user() |
4019 user = ctx.user() |
4019 if opts.get('user'): |
4020 if opts.get('user'): |
4020 user = opts['user'] |
4021 user = opts['user'] |
4021 date = ctx.date() |
4022 date = ctx.date() |
4022 if opts.get('date'): |
4023 if opts.get('date'): |
4023 date = opts['date'] |
4024 date = opts['date'] |
4024 message = ctx.description() |
4025 message = ctx.description() |
4025 if opts.get('log'): |
4026 if opts.get('log'): |
4026 message += '\n(grafted from %s)' % ctx.hex() |
4027 message += '\n(grafted from %s)' % ctx.hex() |
4027 |
4028 |
4028 # we don't merge the first commit when continuing |
4029 # we don't merge the first commit when continuing |
4029 if not cont: |
4030 if not cont: |
4030 # perform the graft merge with p1(rev) as 'ancestor' |
4031 # perform the graft merge with p1(rev) as 'ancestor' |
4031 try: |
4032 try: |
4032 # ui.forcemerge is an internal variable, do not document |
4033 # ui.forcemerge is an internal variable, do not document |
4033 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
4034 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), |
4034 'graft') |
4035 'graft') |
4035 stats = mergemod.graft(repo, ctx, ctx.p1(), |
4036 stats = mergemod.graft(repo, ctx, ctx.p1(), |
4036 ['local', 'graft']) |
4037 ['local', 'graft']) |
4037 finally: |
4038 finally: |
4038 repo.ui.setconfig('ui', 'forcemerge', '', 'graft') |
4039 repo.ui.setconfig('ui', 'forcemerge', '', 'graft') |
4039 # report any conflicts |
4040 # report any conflicts |
4040 if stats and stats[3] > 0: |
4041 if stats and stats[3] > 0: |
4041 # write out state for --continue |
4042 # write out state for --continue |
4042 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] |
4043 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]] |
4043 repo.vfs.write('graftstate', ''.join(nodelines)) |
4044 repo.vfs.write('graftstate', ''.join(nodelines)) |
4044 extra = '' |
4045 extra = '' |
4045 if opts.get('user'): |
4046 if opts.get('user'): |
4046 extra += ' --user %s' % opts['user'] |
4047 extra += ' --user %s' % opts['user'] |
4047 if opts.get('date'): |
4048 if opts.get('date'): |
4048 extra += ' --date %s' % opts['date'] |
4049 extra += ' --date %s' % opts['date'] |
4049 if opts.get('log'): |
4050 if opts.get('log'): |
4050 extra += ' --log' |
4051 extra += ' --log' |
4051 hint=_('use hg resolve and hg graft --continue%s') % extra |
4052 hint=_('use hg resolve and hg graft --continue%s') % extra |
4052 raise error.Abort( |
4053 raise error.Abort( |
4053 _("unresolved conflicts, can't continue"), |
4054 _("unresolved conflicts, can't continue"), |
4054 hint=hint) |
4055 hint=hint) |
4055 else: |
4056 else: |
4056 cont = False |
4057 cont = False |
4057 |
4058 |
4058 # commit |
4059 # commit |
4059 node = repo.commit(text=message, user=user, |
4060 node = repo.commit(text=message, user=user, |
4060 date=date, extra=extra, editor=editor) |
4061 date=date, extra=extra, editor=editor) |
4061 if node is None: |
4062 if node is None: |
4062 ui.warn( |
4063 ui.warn( |
4063 _('note: graft of %d:%s created no changes to commit\n') % |
4064 _('note: graft of %d:%s created no changes to commit\n') % |
4064 (ctx.rev(), ctx)) |
4065 (ctx.rev(), ctx)) |
|
4066 finally: |
|
4067 # TODO: get rid of this meaningless try/finally enclosing. |
|
4068 # this is kept only to reduce changes in a patch. |
|
4069 pass |
|
4070 |
4065 |
4071 # remove state when we complete successfully |
4066 # remove state when we complete successfully |
4072 if not opts.get('dry_run'): |
4067 if not opts.get('dry_run'): |
4073 util.unlinkpath(repo.join('graftstate'), ignoremissing=True) |
4068 util.unlinkpath(repo.join('graftstate'), ignoremissing=True) |
4074 |
4069 |