Search code examples
version-controlmercurialimportpatchworking-directory

Can I import a patch without touching the working directory?


Normally, Mercurial will abort if I have a dirty working copy when I try to import a patch:

$ hg import x.patch
abort: outstanding uncommitted changes

Is it possible to import it anyway?


Solution

  • With Mercurial 1.9, you can use hg import --bypass to apply a patch without touching the working copy. The patch will be applied on the working copy parent revision by default. Use the --exact flag to apply the patch onto the changeset mentioned in the patch header instead.