This page does not meet our wiki style guidelines. Please help improve this page by cleaning up its formatting. |
Generate a diff between two Repositories
Usually, you can use the -p option to either incoming or outgoing. Example:
cd /path/to/repo1 hg incoming -p /path/to/repo2
Sometimes you may want a single diff. There are a number of ways to do this. We'll describe two:
a) The clone method
The basic idea is to use a cheap temporary clone to do the work. If the diff is agreeable, you can then pull from your temporary clone.
MYTIP=`hg tip --template "{rev}"` hg clone -U . tmp # make a temporary clone with no working directory hg -R tmp pull http://remoterepo # pull the remote changes into the temporary repo hg -R tmp diff -r $MYTIP -r tip # rm -rf tmp
b) The bundle method
MYTIP=`hg tip --template "{rev}"` hg in -q --bundle tmp.hg http://remoterepo && hg -R tmp.hg diff -r $MYTIP -r tip
This grabs a bundle of incoming changes then overlays the bundle on your current repository (see LookingIntoBundles) to generate the diff. If the diff is agreeable, you can unbundle the repo to make the changes permanent.
c) Or just use RdiffExtension and run hg diff http://remoterepo
d) diff with bash (maybe works with other shells)
hg in/out is sometimes confusing, when many merges have been done. If just want to compare the tip of two repositories do:
cd /path/to/repo1 for file in $(hg status -nmarc); do diff -Nua <(hg cat $file) <(hg --cwd /path/to/repo2 cat $file); done
The same can be done for the working copies:
cd /path/to/repo1 for file in $(hg status -nmarc); do diff -Nua $file /path/to/repo2/$file; done