# HG changeset patch # User Matt Mackall # Date 1334080152 18000 # Node ID 79fecd735d267630ed860dda23ffb54cfbd12d88 # Parent e03d8a40521fbcd271157d1ca11000e4492e9490 graft: add --dry-run support (issue3362) diff -r e03d8a40521f -r 79fecd735d26 mercurial/commands.py --- a/mercurial/commands.py Fri Apr 06 16:18:33 2012 +0300 +++ b/mercurial/commands.py Tue Apr 10 12:49:12 2012 -0500 @@ -2492,7 +2492,7 @@ _('record the current date as commit date')), ('U', 'currentuser', False, _('record the current user as committer'), _('DATE'))] - + commitopts2 + mergetoolopts, + + commitopts2 + mergetoolopts + dryrunopts, _('[OPTION]... REVISION...')) def graft(ui, repo, *revs, **opts): '''copy changes from other branches onto the current branch @@ -2611,7 +2611,10 @@ for pos, ctx in enumerate(repo.set("%ld", revs)): current = repo['.'] + ui.status(_('grafting revision %s\n') % ctx.rev()) + if opts.get('dry_run'): + continue # we don't merge the first commit when continuing if not cont: @@ -2654,7 +2657,7 @@ date=date, extra=extra, editor=editor) # remove state when we complete successfully - if os.path.exists(repo.join('graftstate')): + if not opts.get('dry_run') and os.path.exists(repo.join('graftstate')): util.unlinkpath(repo.join('graftstate')) return 0 diff -r e03d8a40521f -r 79fecd735d26 tests/test-debugcomplete.t --- a/tests/test-debugcomplete.t Fri Apr 06 16:18:33 2012 +0300 +++ b/tests/test-debugcomplete.t Tue Apr 10 12:49:12 2012 -0500 @@ -247,7 +247,7 @@ debugsub: rev debugwalk: include, exclude debugwireargs: three, four, five, ssh, remotecmd, insecure - graft: continue, edit, currentdate, currentuser, date, user, tool + graft: continue, edit, currentdate, currentuser, date, user, tool, dry-run grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude heads: rev, topo, active, closed, style, template help: extension, command diff -r e03d8a40521f -r 79fecd735d26 tests/test-graft.t --- a/tests/test-graft.t Fri Apr 06 16:18:33 2012 +0300 +++ b/tests/test-graft.t Tue Apr 10 12:49:12 2012 -0500 @@ -107,6 +107,14 @@ Graft out of order, skipping a merge and a duplicate + $ hg graft 1 5 4 3 'merge()' 2 -n + skipping ungraftable merge revision 6 + skipping already grafted revision 2 + grafting revision 1 + grafting revision 5 + grafting revision 4 + grafting revision 3 + $ hg graft 1 5 4 3 'merge()' 2 --debug skipping ungraftable merge revision 6 scanning for duplicate grafts