HG(IMPORT)

✨ NAME ✨

hg import β€” import an ordered set of patches πŸ’… (this page lives in the HG(IMPORT) corner of the manual, btw, just so you know where you are)


🌸 SYNOPSIS 🌸

hg import [OPTION]... PATCH...

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so bestie, here's the vibe: you're importing a list of patches and it commits them individually β€” unless you said --no-commit, in which case it does not. simple as that.

Want to read a patch from standard input (stdin)? Use "-" as the patch name, that's the move. And if you hand it a URL, it will download the patch from there. iconic behavior honestly.

import first applies changes to the working directory (unless --bypass is in the picture), and it will abort if there are outstanding changes. like, it's not doing all that while your workdir is messy, no ma'am.

Use --bypass to apply and commit patches straight to the repository, without touching the working directory at all. And without --exact, patches get applied on top of the working directory parent revision.

You can also import a patch straight out of a mail message πŸ’Œ. Even patches that come as attachments work β€” but to use the body part, it has to have type text/plain or text/x-patch. The From and Subject headers of the email message get used as the default committer and commit message. And every text/plain body part that shows up before the first diff gets added to the commit message. so thorough.

If the patch you're importing was generated by hg export, then the user and description from the patch override the values from the message headers and body. And then values you pass on the command line with -m/--message and -u/--user override those. hierarchy! πŸ‘‘

If --exact is specified, import will set the working directory to the parent of each patch before applying it, and it will abort if the resulting changeset has a different ID than the one recorded in the patch. Why do we care? Because this guards against all the various ways portable patch formats and mail systems might fail to transfer Mercurial data or metadata 😭. See hg bundle for lossless transmission, bestie.

Use --partial to make sure a changeset gets created from the patch even if some hunks fail to apply. Hunks that fail get written to a <target-file>.rej file. Then you can resolve those conflicts by hand before hg commit --amend is run to update the created changeset. This flag exists so people can import patches that only partially apply without losing the associated metadata (author, date, description, ...). love that for them.

⚠️ Note β€” When no hunks apply cleanly, hg import --partial will create an empty changeset, importing only the patch metadata. that's it. that's the whole changeset. πŸ’€

With -s/--similarity, hg will attempt to discover renames and copies in the patch, the same way hg addremove does. slay.

It's possible to use external patch programs to perform the patch by setting the ui.patch configuration option. And for the default internal tool, the fuzz can also be configured via patch.fuzz. See hg help config for more info about configuration files and how to use these options. iykyk.

See hg help dates for a list of formats valid for -d/--date. πŸ—“οΈ

Examples:

  • import a traditional patch from a website and detect renames:
hg import -s 80 http://example.com/bugfix.patch
  • import a changeset from an hgweb server:
hg import https://www.mercurial-scm.org/repo/hg/rev/5ca8c111e9aa
  • import all the patches in an Unix-style mbox:
hg import incoming-patches.mbox
  • import patches from stdin:
hg import -
  • attempt to exactly restore an exported changeset (not always possible):
hg import --exact proposed-fix.patch
  • use an external tool to apply a patch which is too fuzzy for the default internal tool.
hg import --config ui.patch="patch --merge" fuzzy.patch
  • change the default fuzzing from 2 to a less strict 7
hg import --config ui.fuzz=7 fuzz.patch

Returns 0 on success, 1 on partial success (see --partial). 🌈


πŸŽ€ OPTIONS πŸŽ€

  • -p, --strip <NUM> β€” directory strip option for patch. This has the same meaning as the corresponding patch option (default: 1)
  • -b, --base <PATH> β€” base path (DEPRECATED 🫠)
  • --secret β€” use the secret phase for committing
  • -e, --edit β€” invoke editor on commit messages
  • -f, --force β€” skip check for outstanding uncommitted changes (DEPRECATED 🫠)
  • --no-commit β€” don't commit, just update the working directory
  • --bypass β€” apply patch without touching the working directory
  • --partial β€” commit even if some hunks fail
  • --exact β€” abort if patch would apply lossily
  • --prefix <DIR> β€” apply patch to subdirectory
  • --import-branch β€” use any branch information in patch (implied by --exact)
  • -m, --message <TEXT> β€” use text as commit message
  • -l, --logfile <FILE> β€” read commit message from file
  • -d, --date <DATE> β€” record the specified date as commit date
  • -u, --user <USER> β€” record the specified user as committer
  • -s, --similarity <SIMILARITY> β€” guess renamed files by similarity (0<=s<=100)

πŸ’œ ALIASES πŸ’œ

patch


and that's the whole page bestie 🫢 this one's from the HG(IMPORT) manual page, footer and all β€” go forth and import those patches, you've got this πŸ’–βœ¨