Reputation: 5032
I have recently encountered the need to generate a Mercurial diff of all changes up to a particular changeset which includes the first changeset of the repo. I realize this kind of stretches the definition of a diff, but this is for uploading a new project to a code review tool.
Let's assume the following changesets:
p83jdps99shjhwop8 - second feature 12:00 PM
hs7783909dnns9097 - first feature - 11:00 AM
a299sdnnas78s9923 - original app setup - 10:00 AM
If I need a "diff" of all changes that have been committed, the only way that I can seem to achieve this is with the following diff command...
diff -r 00:p83jdps99shjhwop8
In this case the first changeset in the argument param (here - 00
) takes the regexp form of 0[0]+
This seems to be exactly what we need based on a few tests, but I have had trouble tracking down documentation on this scenario (maybe I just can't devise the right Google query). As a result, I am unsure if this will work universally, or if it happens to be specific to my setup or the repos I have tested by chance.
Is there a suggested way to achieve what I am trying to accomplish? If not, is what I described above documented anywhere?
Upvotes: 1
Views: 682
Reputation: 36
It appears this actually is documented, but you need to do some digging...
https://www.mercurial-scm.org/wiki/ChangeSetID
https://www.mercurial-scm.org/wiki/Nodeid
So the special nodeid you're referring to is the 'nullid'.
2 digits may not be adequate to identify the nullid as such (as it may be ambiguous if other hashes start with 2 zeros), so you may be better off specifying 4 0's or more.
Eg: hg diff -r 00:<hash of initial add changeset>
has resulted in the abort: 00changelog.i@00: ambiguous identifier!
error.
Upvotes: 2
Reputation: 50220
I'm a little confused about what you need. The diff between an empty repository and the revision tip
is just the content of every file at tip
-- in other words, it's the state of your project at tip
. In diff format, that'll consist exclusively of +
lines.
Anyway, if you want a way to refer to the initial state of the repository, the documented notation for it is null
(see hg help revisions
). So, to get a diff between the initial (empty) state and the state of your repository at tip
, you'd just say
hg diff -r null -r tip
But hg diff
gives you a diff between two points in your revision graph. So this will only give you the ancestors of tip
: If there are branches (named or unnamed) that have not been merged to an ancestor of tip
, you will not see them.
3--6
/
0--1--2--5--7 (tip)
\ /
4
In the above example, the range from null
to 7
does not include revisions 3
and 6
.
Upvotes: 2