Mercurial: Easy way to see changes from last commit

hg log
hg rollback
hg diff
hg reset
mercurial command to view the repository history
hg remove file from commit
hg graft
hg list changed files in commit

In Mercurial, I can see my current (uncommitted) changes by running

$ hg diff

Fine. But after commit, I sometimes want to see this diff again (i.e., the diff of the last changeset). I know I can achieve this by

$ hg log -l 1
changeset:    1234
tag ...

$ hg diff -c 1234

I'm looking for a way to do this in one line.

Use hg diff -c tip, or hg tip -p (shorter, but works only for tip).

This will work until you pull something, since tip is an alias for the most recent revision to appear in the repo, either by local commit or pull/push from remote repositories.

Mercurial Cheat Sheet, Every time you commit a changeset or pull changes from another repository, I use the hg rollback command, and Mercurial makes that last changeset vanish. Let's illustrate how the hg revert command works with yet another small example. It's easier to see this in fig:undo:backout, which presents a graphical view of  Helix Core is easy to use. (See how Helix Core's P4 commands compare to Git commands or Mercurial commands.) It provides stronger security options (including MFA, access control, and more) than Git or Mercurial. And it offers a better way to branch and merge (Perforce Streams). See for yourself why Helix Core might be the best choice for your team.

You can use relative revision numbers for the --change option:

hg diff -c -1

See for more info.

Finding and fixing mistakes, It is intended to make it easy for beginners of version tracking to get going instantly and learn Those further down build on previous workflows. Also you check your history from time to time, so see how you progressed. Workflow. Basics from log keeping. Init your project, add files, see changes and commit them. $ hg init  Like other Mercurial commands, if we don't supply explicit names to commit to the hg commit, it will operate across a repository's entire working directory. Be wary of this if you're coming from the Subversion or CVS world, since you might expect it to operate only on the current directory that you happen to be visiting and its subdirectories.

An alternative is to use: hg diff --rev -2:-1

This form has the advantage that it can be used with the status command (e.g. hg st --rev -2:-1), and using it makes it easy to remember what to do when one needs to determine differences between other revision pairs (e.g. hg diff --rev 0:tip).

Guide, The files will be added to the repository at the next commit. See hg help revert for a way to restore files to the state of another revision. get change stats relative to the last change on some date: Furthermore, some interactive merge programs make it easier to manually resolve conflicting merges, either in a graphical  Init your project, add files, see changes and commit them. $ hg init project $ cd project $ (add files) $ hg add # tell Mercurial to track all files $ (do some changes) $ hg diff # see changes $ hg commit # save changes $ hg cp # copy files or folders $ hg mv # move files or folders $ hg log # see history Seeing an earlier revision

The answer from Macke is quite helpful, but in my case I didn't want to diff tip.

Thankfully you can also just diff the currently selected comment:

hg diff -c .

hg, As we can see, each changeset changes a different file. Of course, this looks easy using a graphic representation, but how simple is it to do such a rebase? Commits are listed from least to most recent # # You can reorder changesets by  Mercurial — revert back to old version and continue from there ; How to abort a merge in mercurial? Mercurial: how to amend the last commit? Mercurial(hg) commit only certain files ; Mercurial: Easy way to see changes from last commit

Changing history, hg pull, get latest changes like git pull use flags like -u IDK why yet. hg add, only for new files. hg commit, add changes to commit with -m for message just like git hg diff -r 0000:0000 /dir/location/path, Diff versions of same file from different  There are a bewildering number of different ways you can work with Mercurial. This is the way that feels the most natural to me. However, I make no claim that this is the correct (or even a correct) way to use TortoiseHg and Mercurial. I want to keep this article short and to the point, but accuracy is important to me.

Mercurial command cheat sheet · GitHub, Is Mercurial better? Find out. Get a comparison of Mercurial vs. Git. Even though Mercurial may be easier to learn and use, its branching model With basic Mercurial, you can only change your last commit with “hg commit  Here you can see the complete history of the repository, including the files changed in each revision and (as we’ll later see) the differences between them. Making modifications Now let’s learn how to make modifications to a file, see the differences between what we’ve committed, and finally commit our changes back to the repository.

Git vs. Mercurial: How Are They Different?, It tracks all changes made to each file (which you can review to see your progress we chose Mercurial because it has simple commands and is easy to The clone command takes two arguments: the path to the repository to clone By default, diff compares the files in the working directory with the last committed revision. See hg push for a way to actively distribute your changes. If a list of files is omitted, all changes reported by hg status will be committed. If you are committing the result of a merge, do not provide any filenames or -I/-X filters. If no commit message is specified, Mercurial starts your configured editor where you can enter a message.

  • Thanks, this is what I've been looking for. Actually it's -c tip, not -r tip, but the key point is the tip alias.
  • @claasz: Glad it helped, and thanks for the tip. I've updated my answer with the right option.
  • There's a handy shortcut in the form of hg tip -p, but it amounts to the same thing, and the solution given here will work for any revision.