diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2074,6 +2074,8 @@ ('c', 'continue', False, _('resume interrupted graft')), ('e', 'edit', False, _('invoke editor on commit messages')), ('', 'log', None, _('append graft info to log message')), + ('', 'no-commit', None, + _("don't commit, just apply the changes in working directory")), ('f', 'force', False, _('force graft')), ('D', 'currentdate', False, _('record the current date as commit date')), @@ -2313,9 +2315,11 @@ else: cont = False + node = None # commit - node = repo.commit(text=message, user=user, - date=date, extra=extra, editor=editor) + if not opts.get('no_commit'): + node = repo.commit(text=message, user=user, + date=date, extra=extra, editor=editor) if node is None: ui.warn( _('note: graft of %d:%s created no changes to commit\n') % diff --git a/tests/test-graft.t b/tests/test-graft.t --- a/tests/test-graft.t +++ b/tests/test-graft.t @@ -1373,3 +1373,30 @@ note: graft of 7:d3c3f2b38ecc created no changes to commit $ cd .. + +Graft a change from a branch without making any commit using --no-commit option + + $ hg init dirtochecknocommit + $ cd dirtochecknocommit + $ echo a > a + $ hg ci -qAm0 + $ echo b > b + $ hg ci -qAm1 + $ hg up -q 0 + $ echo c > c + $ hg ci -qAm2 + $ hg graft 1 --no-commit + grafting 1:925d80f479bb "1" + note: graft of 1:925d80f479bb created no changes to commit + + $ hg tip -T "rev : {rev}\n" + rev : 2 + + $ hg diff + diff -r db815d6d32e6 b + --- /dev/null Thu Jan 01 00:00:00 1970 +0000 + +++ b/b Thu Jan 01 00:00:00 1970 +0000 + @@ -0,0 +1,1 @@ + +b + + $ cd ..