HG(EXPORT)

πŸ’– HG(EXPORT) πŸ’–

okay so bestie, welcome to hg export β€” the Mercurial manual page that's about to become your whole personality. this is the HG(EXPORT) page and we're gonna read it together, no skimming, no scrolling past the "boring" bits (there are none, i checked 🫢).


✨ NAME ✨

hg export β€” dump the header and diffs for one or more changesets


🌸 SYNOPSIS 🌸

hg export [OPTION]... [-o OUTFILESPEC] [-r] [REV]...

πŸ¦‹ DESCRIPTION πŸ¦‹

So like, what does it do? It prints the changeset header and the diffs for one or more revisions. That's the whole job. And if you don't give it a revision? No worries bestie, it just uses the parent of the working directory. she's self-sufficient like that πŸ’…

The info that shows up in the changeset header is: author, date, branch name (only if it's non-default), changeset hash, parent(s) and the commit comment. that's the little intro card before the actual diff content, iconic.

⚠️ Note: hg export may generate unexpected diff output for merge changesets, because it will compare the merge changeset against its first parent only. so heads up, it's giving "not the full picture" energy for merges 😭

Output may go to a file, and when it does, the name of that file is given using a template string. See hg help templates. And in addition to the common template keywords, these formatting rules are supported:

  • %% β€” a literal "%" character
  • %H β€” changeset hash (40 hexadecimal digits)
  • %N β€” number of patches being generated
  • %R β€” changeset revision number
  • %b β€” basename of the exporting repository
  • %h β€” short-form changeset hash (12 hexadecimal digits)
  • %m β€” first line of the commit message (only alphanumeric characters)
  • %n β€” zero-padded sequence number, starting at 1
  • %r β€” zero-padded changeset revision number
  • \ β€” a literal "" character

Without the -a/--text option, export will avoid generating diffs of files it detects as binary. With -a, export will generate a diff anyway β€” probably with undesirable results. you were warned, periodt.

With -B/--bookmark, the changesets reachable by the given bookmark are selected. πŸŽ€

Use the -g/--git option to generate diffs in the git extended diff format. See hg help diffs for more information.

With the --switch-parent option, the diff will be against the second parent. This can be useful to review a merge. lowkey a life saver for merge review, ngl.

πŸ’œ Template

The following keywords are supported in addition to the common template keywords and functions. See also hg help templates.

  • diff β€” String. Diff content.
  • parents β€” List of strings. Parent nodes of the changeset.

🌈 Examples

  1. use export and import to transplant a bugfix to the current branch:
hg export -r 9353 | hg import -
  1. export all the changesets between two revisions to a file with rename information:
hg export --git -r 123:150 > changes.txt
  1. split outgoing changes into a series of patches with descriptive names:
hg export -r "outgoing()" -o "%n-%m.patch"

Returns 0 on success. ✨


πŸ‘‘ OPTIONS πŸ‘‘

  • -B, --bookmark <BOOKMARK> β€” export changes only reachable by given bookmark
  • -o, --output <FORMAT> β€” print output to file with formatted name
  • --switch-parent β€” diff against the second parent
  • -r, --rev <REV[+]> β€” revisions to export
  • -a, --text β€” treat all files as text
  • -g, --git β€” use git extended diff format (DEFAULT: diff.git)
  • --binary β€” generate binary diffs in git mode (default)
  • --nodates β€” omit dates from diff headers
  • -T, --template <TEMPLATE> β€” display with template
[+] marked option can be specified multiple times

okay that's the whole page bestie, you ate that πŸ“ and for the cute sign-off: this gorgeous thing lives under the name HG(EXPORT), top and bottom, header and footer, matching like a little matching set πŸŽ€πŸ’– go export something, you got this 🫢✨