Mercurial > hg
comparison mercurial/commands.py @ 16389:79fecd735d26
graft: add --dry-run support (issue3362)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 10 Apr 2012 12:49:12 -0500 |
parents | 329887a7074c |
children | d54d4de56aa7 |
comparison
equal
deleted
inserted
replaced
16388:e03d8a40521f | 16389:79fecd735d26 |
---|---|
2490 ('e', 'edit', False, _('invoke editor on commit messages')), | 2490 ('e', 'edit', False, _('invoke editor on commit messages')), |
2491 ('D', 'currentdate', False, | 2491 ('D', 'currentdate', False, |
2492 _('record the current date as commit date')), | 2492 _('record the current date as commit date')), |
2493 ('U', 'currentuser', False, | 2493 ('U', 'currentuser', False, |
2494 _('record the current user as committer'), _('DATE'))] | 2494 _('record the current user as committer'), _('DATE'))] |
2495 + commitopts2 + mergetoolopts, | 2495 + commitopts2 + mergetoolopts + dryrunopts, |
2496 _('[OPTION]... REVISION...')) | 2496 _('[OPTION]... REVISION...')) |
2497 def graft(ui, repo, *revs, **opts): | 2497 def graft(ui, repo, *revs, **opts): |
2498 '''copy changes from other branches onto the current branch | 2498 '''copy changes from other branches onto the current branch |
2499 | 2499 |
2500 This command uses Mercurial's merge logic to copy individual | 2500 This command uses Mercurial's merge logic to copy individual |
2609 if not revs: | 2609 if not revs: |
2610 return -1 | 2610 return -1 |
2611 | 2611 |
2612 for pos, ctx in enumerate(repo.set("%ld", revs)): | 2612 for pos, ctx in enumerate(repo.set("%ld", revs)): |
2613 current = repo['.'] | 2613 current = repo['.'] |
2614 | |
2614 ui.status(_('grafting revision %s\n') % ctx.rev()) | 2615 ui.status(_('grafting revision %s\n') % ctx.rev()) |
2616 if opts.get('dry_run'): | |
2617 continue | |
2615 | 2618 |
2616 # we don't merge the first commit when continuing | 2619 # we don't merge the first commit when continuing |
2617 if not cont: | 2620 if not cont: |
2618 # perform the graft merge with p1(rev) as 'ancestor' | 2621 # perform the graft merge with p1(rev) as 'ancestor' |
2619 try: | 2622 try: |
2652 date = opts['date'] | 2655 date = opts['date'] |
2653 repo.commit(text=ctx.description(), user=user, | 2656 repo.commit(text=ctx.description(), user=user, |
2654 date=date, extra=extra, editor=editor) | 2657 date=date, extra=extra, editor=editor) |
2655 | 2658 |
2656 # remove state when we complete successfully | 2659 # remove state when we complete successfully |
2657 if os.path.exists(repo.join('graftstate')): | 2660 if not opts.get('dry_run') and os.path.exists(repo.join('graftstate')): |
2658 util.unlinkpath(repo.join('graftstate')) | 2661 util.unlinkpath(repo.join('graftstate')) |
2659 | 2662 |
2660 return 0 | 2663 return 0 |
2661 | 2664 |
2662 @command('grep', | 2665 @command('grep', |