Reputation: 41030
I'm using Mercurial and I have a diff thanks to this command : hg diff
Here's my diff (example) :
diff -r 17899716342e config.js
--- a/config.js Sat Mar 17 14:01:53 2012 +0100
+++ b/config.js Sat Mar 17 18:15:16 2012 +0100
@@ -8,6 +8,6 @@
];
config.hostname = 'localhost';
-config.port = '3000';
+config.port = '8080';
-module.exports = canfig;
+module.exports = config;
In another repository, I would like to test is this diff can be applied. I know that hg import
can import the diff in my current repository.
From the man :
-f --force skip check for outstanding uncommitted changes
--no-commit don't commit, just update the working directory
--bypass apply patch without touching the working
directory
But there's no argument to just check if the patch can be applied without modify my repository (and my working tree).
How can I do that ?
Upvotes: 0
Views: 116
Reputation: 78340
I like @Mark Tolonen's answer the most -- in Mercurial a new local clone is nearly instantaneous and takes up almost no space due to the use of hard links.
However, if you just can't abide doing so then use the --no-commit option and then revert.
hg import --no-commit the.diff
# check if that succeeds or failshg revert --all
# undo the attempted importUpvotes: 0
Reputation: 177755
I suggest making a local throw-away clone and apply the patch to it if you don't want to modify your current working directory or repository. I don't think there is a way to do it otherwise.
With extensions you could shelve current changes, apply patch, update clean back to original parent, unshelve changes. Cloning seems simpler.
Upvotes: 2