Mercurial - use hg log to view all ancestors - mercurial

Given changesets
a
--b
----c
------d
--------e
How can I get a listing of all changesets that come before d. Ie: how can you use hg log to return a-b-c?

Use:
hg log -r "ancestors(d)"
This requires the revsets feature in Mercurial 1.7 and later. See hg help revsets for some great fun.

You can do hg log -r :d (but it will also display d).

hg log -r d::a
or
hg log -r a::d
This will require a reasonably recent (I believe 1.6 or later) version of Mercurial to work.

Related

How to detect that commits are pushable

In Git it is easy, because remote/branch is pointing to a different commit than branch. How to do it with Mercurial?
If you mean seeing what's different between your local repo and the one you're pushing to, try
hg outgoing
Since Mercurial 2.1, there is also a purely local solution: phases. The draft phase is probably what you are looking for. For details, refer to:
https://www.mercurial-scm.org/wiki/Phases
You may find hg phase <rev> and hg log -r "draft()" interesting.
There is an remotebranch extension that will give you a Git-like setup. It tracks the remote heads for the repositories listed in the [paths] and exposes them as tags named <path>/<branch>. This lets you run
$ hg diff -r foo/default
to see what has changed since the default branch in the foo repository. There is also new revset keywords that let you do things like
$ hg log -r "not pushed()"
to get what
$ hg outgoing
would do, but without any network traffic.
What's the command line call to show all revisions in the draft phase?
hg log --style phases
That will display the log + the phase, since Mercurial 2.7 (2013-08-01).
I'd just use hg outgoing as others are suggesting, but hg summary will tell you too. It may require the --remote option to have it check the remote default server.
If you need to select the changesets for further processing, then you can use the outgoing revset predicate. This lets you re-implement hg outgoing as
hg log -r "outgoing()"
but the real benefit is that you can use this in other contexts, such as
hg strip "outgoing()"

Mercurial - determine where file was removed?

If you do hg log myfile -v you see a list of changesets that the file was modified in.
In our case, in the most recent changeset, the file was removed. But you can't tell this by looking at the verbose (-v) output of hg log. Is there an easy Mercurial command you can use to determine if and when a file has been removed from the repo?
Update: Note that this is on a Windows client, and we are using Mercurial v 1.4.3
Update 2: Appears the answers below would work with a more recent version of Mercurial, however an upgrade isn't in the cards right now. Any other ideas for v 1.4.3 ???
You can check which revision deleted a file (any many other interesting features) using revsets:
hg log -r 'removes(<myfile>)'
Some examples:
hg log -r 'removes(build.xml)' // where build.xml used to be in the current directory
hg log -r 'removes("**/build.xml")' // where build.xml may have been in sub directories
See hg help revsets for details.
The --removed flag should get you what you are looking for:
hg log myfile -v --removed
From the help for hg log:
--removed include revisions where files were removed
This is what I use to list all the deleted files in my repository:
hg log --template "{rev}: {file_dels}\n" | grep -v ':\s*$'

Tag diffing in mercurial

In mercurial is there a way to diff between 2 different tags?
I have tagged my builds and have a couple commits in between builds and want to figure out the differences between the 2 builds.
hg diff -r tag1:tag2
That's all there is to it.
This answer in the Kiln StackExchange seems quite complete (based on hg diff and hg log):
To see all of the changesets that were introduced between, say, the tags v1.0 and v1.1, run:
hg log -r v1.0:v1.1
To see the net sum of differences introduced in those revisions, you'd instead run:
hg diff -r v1.0:v1.1
Mercurial can even format this output in changelog-style, if you want. Simply add the --style changelog parameter:
hg log -r v1.0:v1.1 --style changelog

See Mercurial changeset summary/user/date

Given a Mercurial changeset 123, how can yous see the summary, user, and date associated with the changeset? Figured there was an hg log option but couldn't see it..
you can also try Mercurial Templates to get just the output you're after. Several keywords are supported, but in your example this command would work:
hg log -r 123 --template '{author}\n{date}\n{desc}\n'
Have you tried hg log -r 123?

How do I rebase in mercurial without merging?

When I try to hg rebase -s 1775 --collapse, I am asked to merge all the files I touched since rev 1774. How can I avoid that?
Details
I am just learning how to rebase. I successfully tried the example given here, and a few minor variations. However, in my own repository, when I try the same steps, I am asked to merge a boat-load of files when I rebase. Here's what I do. What am I doing wrong?
hg update -r 1774
hg tag "Started-New-Feature"
hg rebase -s 1775 --collapse
I thought maybe it was because I had updated to -r1774, so I updated to tip after tagging -r1774. Same result.
hg update -r 1774
hg tag "Started-New-Feature"
hg update
hg rebase -s 1775 --collapse
The hg tag creates a new rev -r1784. So I tried updating specifically to -r1783. Same result.
hg update -r 1774
hg tag "Started-New-Feature"
hg update -r 1774
hg update -r 1783
hg rebase -s 1775 --collapse
I've searched the web and SO for related questions and didn't find anything, which doesn't mean answers don't exist. Pointers to existing answers are welcome.
Edit:
This seems related to a reported mercurial bug that was fixed in 1.4. I have version 1.1. I tried updating to 1.4 or later, but sudo apt-get install mercurial says I have the latest, and the download link on the mercurial page is currently broken. So maybe the answer is just getting the latest version, but hopefully there's another way around this.
Are you using ubuntu? If so you can use the launchpad ppa version of hg, which tends to be very currenty https://launchpad.net/~mercurial-ppa/+archive/releases