diff --git a/eden/scm/sapling/commands/__init__.py b/eden/scm/sapling/commands/__init__.py index bc02b7efdfb3a..b033079458feb 100644 --- a/eden/scm/sapling/commands/__init__.py +++ b/eden/scm/sapling/commands/__init__.py @@ -2691,7 +2691,7 @@ def _dograft(ui, repo, *revs, **opts): # commit editor = cmdutil.getcommiteditor(editform="graft", **opts) - message = _makegraftmessage(ctx, opts) + message = _makegraftmessage(repo, ctx, opts) node = repo.commit( text=message, user=user, date=date, extra=extra, editor=editor ) @@ -2708,8 +2708,12 @@ def _dograft(ui, repo, *revs, **opts): return 0 -def _makegraftmessage(ctx, opts): - description = ctx.description() +def _makegraftmessage(repo, ctx, opts): + if logmessage := cmdutil.logmessage(repo, opts): + description, is_from_ctx = logmessage, False + else: + description, is_from_ctx = ctx.description(), True + message = [] if opts.get("from_path"): # For xdir grafts, include "grafted from" breadcrumb by default. @@ -2718,11 +2722,14 @@ def _makegraftmessage(ctx, opts): for f, t in zip(opts.get("from_path"), opts.get("to_path")): message.append("- Grafted path %s to %s" % (f, t)) - try: - title, rest = description.split("\n", 1) - description = f'Graft "{title}"\n{rest}' - except ValueError: - description = f'Graft "{description}"' + # only update the title if it is from original change context, + # we don't update the user provided title + if is_from_ctx: + try: + title, rest = description.split("\n", 1) + description = f'Graft "{title}"\n{rest}' + except ValueError: + description = f'Graft "{description}"' else: if opts.get("log"): message.append("(grafted from %s)" % ctx.hex()) diff --git a/eden/scm/sapling/commands/subtree.py b/eden/scm/sapling/commands/subtree.py index dc226188f7177..5e49c4f070bdb 100644 --- a/eden/scm/sapling/commands/subtree.py +++ b/eden/scm/sapling/commands/subtree.py @@ -85,6 +85,7 @@ def subtree_copy(ui, repo, *args, **opts): _("record the current user as committer"), ), ] + + commitopts + commitopts2 + mergetoolopts + dryrunopts diff --git a/eden/scm/sapling/ext/fbcodereview.py b/eden/scm/sapling/ext/fbcodereview.py index 103613a73fa0b..3c3d4b9ef100c 100644 --- a/eden/scm/sapling/ext/fbcodereview.py +++ b/eden/scm/sapling/ext/fbcodereview.py @@ -170,8 +170,8 @@ def makebackoutmessage(orig, repo, message: str, node): return message -def makegraftmessage(orig, ctx, opts): - message = orig(ctx, opts) +def makegraftmessage(orig, repo, ctx, opts): + message = orig(repo, ctx, opts) if not opts.get("from_path"): return message diff --git a/eden/scm/tests/test-subtree.t b/eden/scm/tests/test-subtree.t index 5e974ec100196..6e26098f71e9b 100644 --- a/eden/scm/tests/test-subtree.t +++ b/eden/scm/tests/test-subtree.t @@ -133,6 +133,42 @@ test subtree graft -3 +3a +test 'subtree graft -m' + $ newclientrepo + $ drawdag <<'EOS' + > C # C/foo/x = 1a\n2\n3a\n + > | + > B # B/foo/x = 1a\n2\n3\n + > | + > A # A/foo/x = 1\n2\n3\n + > # drawdag.defaultfiles=false + > EOS + $ hg go $C -q + $ hg subtree copy -r $B --from-path foo --to-path bar -m 'subtree copy foo -> bar' + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + + $ hg subtree graft -r $C --from-path foo --to-path bar -m "new C" + grafting 78072751cf70 "C" + $ hg show + commit: 6eac9525eeb2 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + files: bar/x + description: + new C + + Grafted from 78072751cf70f1ca47671c625f3b2d7f86f45f00 + - Grafted path foo to bar + + + diff --git a/bar/x b/bar/x + --- a/bar/x + +++ b/bar/x + @@ -1,3 +1,3 @@ + 1a + 2 + -3 + +3a test subtree merge $ newclientrepo