Dump the commit contents into the editor when editing a Jujutsu commit

I’m so happy with this config that I need to share it even though I’ve only been using this for a few hours. Put this in ~/.config/jj/config.toml.

[templates]
draft_commit_description = '''
concat(
  description,
  surround(
    "\nJJ: This commit contains the following changes:\n", "",
    indent("JJ:     ", diff.stat(72)),
  ),
  surround("\nJJ: Diff:\n", "", indent("JJ:  ", diff.git(4)))
)
'''

It’s awesome. Now editing a commit message looks like this.

Bug 1930698 - Add invalidation logging for fuses r?iain

Differential Revision: https://phabricator.services.mozilla.com/D228689

JJ: This commit contains the following changes:
JJ:     js/src/vm/InvalidatingFuse.cpp | 6 ++++++
JJ:     js/src/vm/Logging.h            | 1 +
JJ:     2 files changed, 7 insertions(+), 0 deletions(-)

JJ: Diff:
JJ:  diff --git a/js/src/vm/InvalidatingFuse.cpp b/js/src/vm/InvalidatingFuse.cpp
JJ:  index 6fbc9b2aa0..e7b541ff20 100644
JJ:  --- a/js/src/vm/InvalidatingFuse.cpp
JJ:  +++ b/js/src/vm/InvalidatingFuse.cpp
JJ:  @@ -10,8 +10,9 @@
JJ:   #include "jit/Invalidation.h"
JJ:   #include "jit/JitSpewer.h"
JJ:   #include "vm/JSContext.h"
JJ:   #include "vm/JSScript.h"
JJ:  +#include "vm/Logging.h"
JJ:   
JJ:   #include "gc/StableCellHasher-inl.h"
JJ:   #include "vm/JSScript-inl.h"
JJ:   
JJ:  @@ -33,8 +34,10 @@
JJ:   
JJ:   void js::InvalidatingRuntimeFuse::popFuse(JSContext* cx) {
JJ:     // Pop the fuse in the base class
JJ:     GuardFuse::popFuse(cx);
JJ:  +  JS_LOG(fuseInvalidation, mozilla::LogLevel::Verbose,
JJ:  +         "Invalidating fuse popping: %s", name());
JJ:     // do invalidation.
JJ:     for (AllZonesIter z(cx->runtime()); !z.done(); z.next()) {
JJ:       // There's one dependent script set per fuse; just iterate over them all to
JJ:       // find the one we need (see comment on JS::Zone::fuseDependencies for
JJ:  @@ -70,8 +73,11 @@
JJ:       // before calling invalidate.
JJ:       if (script->hasIonScript()) {
JJ:         JitSpew(jit::JitSpew_IonInvalidate, "Invalidating ion script %p for %s",
JJ:                 script->ionScript(), reason);
JJ:  +      JS_LOG(fuseInvalidation, mozilla::LogLevel::Debug,
JJ:  +             "Invalidating ion script %s:%d for reason %s", script->filename(),
JJ:  +             script->lineno(), reason);
JJ:         js::jit::Invalidate(cx, script);
JJ:       }
JJ:     }
JJ:   }
JJ:  diff --git a/js/src/vm/Logging.h b/js/src/vm/Logging.h
JJ:  index f4b63e3773..a593c249bd 100644
JJ:  --- a/js/src/vm/Logging.h
JJ:  +++ b/js/src/vm/Logging.h
JJ:  @@ -83,8 +83,9 @@
JJ:   
JJ:   #define FOR_EACH_JS_LOG_MODULE(_)                                            \
JJ:     _(debug)                /* A predefined log module for casual debugging */ \
JJ:     _(wasmPerf)             /* Wasm performance statistics */                  \
JJ:  +  _(fuseInvalidation)     /* Invalidation triggered by a fuse  */            \
JJ:     JITSPEW_CHANNEL_LIST(_) /* A module for each JitSpew channel. */
JJ:   
JJ:   // Declare Log modules
JJ:   #define DECLARE_MODULE(X) inline constexpr LogModule X##Module(#X);

JJ: Lines starting with "JJ: " (like this one) will be removed.

Many thanks to Erich at work!