I'd like to know the best/easiest way to get a visual diff of a file given two revisions in Mercurial. I.e., I'd like to visualize the difference between revision 3 and revision 12, etc.
If by 'visual' you mean a text comparison you can do:
hg diff -r 3 -r 12
If you want a GUI tools you can easily configure and use the ExtDiff extension, which comes with Mercurial, and use:
hg yourdiff -r 3 -r 12
where yourdiff was configured in your hgrc file.
In the 'better late than never' category, and in answer to epalm's comment, here is how to compare any two revisions of a file from within TortoiseHG.
From any view that displays the file of interest, right click on the file and select 'File History'. This will open a new window that only displays check-ins for that file. (If the file you want is not visible in the current change set, remember that all files are visible in the Manifest view.)
From the File History window, select the two revisions that you want to compare by doing a CTRL - Left Click on each one. Make sure exactly two revisions are selected or you won't see the context menu you need in the next step.
Right click on one of the selected file and choose the "Diff selected file revisions..." option. A file diff window will open with whatever diff tool TortoiseHG is configured to use.
Note that this answer was written based on TortoiseHG version 2.6.2
Related
The Mercurial Workbench within TortoiseHG allows a graphical use of many mercurial functions. I have a patch sitting in a mercurial queue from which I want to extract some files to another separate patch.
I found a solution here for the command line approach:
Gaol: End up with OP=P1 + P2, where OP=Original Patch, P1=Patch 1, P2=Patch 2
Solution:
hg qpush OP
hg qrefresh <paths to keep> to replace OP with P1, including only the paths you named. The other changes will remain as uncommitted changes in the working directory.
hg qnew -f P2 to pick up those changes.
I simply cannot figure out how to do this within the workbench and would be glad if someone could teach me how to accomplish this. Thanks!
When you use the refresh button in TortoiseHg it acts on the ticked items in the list so to do what you ask you follow the following steps:
Click on your patch OP in the top list
Untick the the files that you want to go into the second patch on the list of changed files on the left
Click the refresh button on the right
Click on the working directory entry on the top list to see the rest of the files
Tick all the files on the list of changes on the left
Click on the new patch button on the right (click on the little down arrow on the commit button if that it's the active button to select the new patch button)
Obviously, enter any commit messages as required.
I had two very large projects in my Mercurial repository.
I am in the process of refactoring both of them into smaller sub-projects.
That involves moving sets of sources from a parent project directory into a sub-project's sub-directory.
For most files, I simply moved them.
For some files, I also had to make changes.
Before I commit my refactoring changes, I would like to review any edits that I made to any source files. In the GUI tool SourceTree - it shows me any modifications (in addition to indicating that the file has been moved/renamed). Is there any way to determine what files have also been modified from the Mercurial command line?
Here is a specific example of what I am talking about:
iphonedev:EveryScape cdoucette$ hg status -C Engineering/iOS/ESSDK/src/ESSDK-Miscellaneous/ESDataManagerInMemory.m
A Engineering/iOS/ESSDK/src/ESSDK-Miscellaneous/ESDataManagerInMemory.m
Engineering/iOS/ESSDK/src/ESDataManagerInMemory.m
How can I compare the old revision with the current working copy in a different location?
If I just do this:
hg diff Engineering/iOS/ESSDK/src/ESSDK-Miscellaneous/ESDataManagerInMemory.m
It shows me the entire contents of the file (since technically it was added in its new location).
Instead, I want to diff between:
Engineering/iOS/ESSDK/src/ESDataManagerInMemory.m (repository copy - previous revision)
Engineering/iOS/ESSDK/src/ESSDK-Miscellaneous/ESDataManagerInMemory.m (working copy)
I did search for similar questions. This post was close - but appears to only make sense if I went ahead and committed my changes. Instead, I would like to find and review my changes before committing.
Mercurial diff not working after move/rename
I would script it up like this:
hg cat -r <oldrev> <oldfilename> > oldfile.oldrev
diff <newfilename> oldfile.oldrev
I gave someone a copy of my code using hg archive a while ago. A lot of commits has happened since then and I cannot remember which was the revision I gave him. There is some information about the version I had given the person in the .hg_archival.txt file. It has the node hash information, for example node: 72f497079285b2c3cf4f8b86950664f84221cd63
Using the information in the .hg_archival.txt file (like the node hash) how do I find the corresponding revision node in the revision graph displayed in TortoiseHg?
This works with TortoiseHg 2.x.y. If the Filter Toolbar is not visible, enable it by choosing View -> Filter Toolbar or pressing Ctrl+S.
In the revision set query textbox of the Filter toolbar paste the node hash and press Enter. If the Filter check box is set, only the revision matching the hash is displayed. If you disable the Filter check box, the revision matching the hash is highlighted in the complete revision graph.
The complete hash is 40 characters long. You only need to paste enough of it to be able to unambiguously match a revision.
hg log -r 72f497079285b2c3cf4f8b86950664f84221cd63 or hg update -r 72f497079285b2c3cf4f8b86950664f84221cd63
How can I browse the history of a chunk of a file, or the whole file if only that is possible, oven though the file was moved?
For example, file r/a/b.txt was moved to r/b.txt but had a history while in r/a,and I would like to see that history, if possible focused on a certain chunk/set of lines of the file.
You see the history of a file with
hg log --follow your-file
This will simply list the changesets that touch the given file. You can add --patch if you want to see the patches along with the log messages.
I don't know of a tool that can focus on a particular hunk. The closest is the annotate command. I always use it from TortoiseHg (works on all Windows, Mac, and Linux) which allows you to right-click on a given line and annotate the parent changeset of the changeset that touched the line. That makes it really convenient to "peel off" layers of history in the file.
I know how to view all changes in a changeset..
But let's say you update your source, you do a pull and you get 3 new changesets. How can you compare the current state of the remote repository (with the 3 changesets checked in) vs. the current source (on your local machine)?
I'd like to do this using the visual diff tool which I currently have configured (Examdiff or Kdiff3).
You want to compare the current working directory with the tip revision, so you should be able to use hg diff -r tip.