How do I diff one branch with my default branch

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


How do I diff one branch with my default branch



I switched to a branch on my local repo and noticed it gave me message showing x files updated. This surprised me as I didn't know there were any differences on that branch. How do I compare that branch with the default branch to see what has changed?




3 Answers
3



Use hg diff -r BRANCH1:BRANCH2, where BRANCH1 and BRANCH2 are the names of the branches. This will show you the differences between the heads of the two branches.


hg diff -r BRANCH1:BRANCH2



You got the message about "x files updated" because there were files changed on the original branch, not necessarily because there were files changed on the other branch. Mercurial shows you the union of the sets of changed files from both branches.





...and if you're already (cleanly) switched to that branch: hg diff -r default will do the same
– declension
Jun 18 '14 at 17:28


hg diff -r default





How to diff with file name only output?
– BMW
Sep 19 '17 at 4:49



To just list the files with differences, add the --stat option:


hg diff --stat -r BRANCH1:BRANCH2



This gives output like this:


mypath/file1.cpp | 1 -
mypath/file2.cpp | 143 ++++++++++
mypath/file3.cpp | 18 +-
3 files changed, 160 insertions(+), 2 deletions(-)



Or to clean up the output a bit, pipe it through sed to remove everything after the pipe symbols:


hg diff --stat -r BRANCH1:BRANCH2 | sed "s/|.*$//g"



This gives you just a list of the changed files and the summary line at the end:


mypath/file1.cpp
mypath/file2.cpp
mypath/file3.cpp
3 files changed, 160 insertions(+), 2 deletions(-)



To view a diff of branch otherbranch with the current branch:


otherbranch


hg diff -r otherbranch






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived