I have a repository where:
> hg st
shows that my working directory has some uncommitted changes, while
> hg diff > hg diff -g > hg diff --git
display nothing.
I read here: 4.10. hg status shows changed files but hg diff doesn't! the following:
hg status reports when file contents or flags have changed relative to either parent. hg diff only reports changed contents relative to the first parent. You can see flag information with the --git option to hg diff and deltas relative to the other parent with -r.
However, if I run hg parents
it shows only one parent (the tip). As I mention above, I have also tried hg diff --git
and it still displays nothing.
Note:
hg status
only shows M
next to a regular file.hg diff
and hg diff -g
print nothinghg parents
prints only one parentIf you are using the terminal in windows add hg status --rev x:y > your-file. txt to save the list to a file. To only see changes in the current directory: hg status --rev x:y .
hg status shows the status of a repository. Files are stored in a project's working directory (which users see), and the local repository (where committed snapshots are permanently recorded). hg add tells Mercurial to track files. hg commit creates a snapshot of the changes to 1 or more files in the local repository.
Some excerpts from Mercurial in daily use (Mercurial: the definitive guide) (copying here because there seems to be no way to give a convinient link to the end of the page):
The default output of the
hg diff
command is backwards compatible with the regulardiff
command, but this has some drawbacks.The output of hg diff above obscures the fact that we simply renamed a file. The hg diff command accepts an option,
--git
or-g
, to use a newer diff format that displays such information in a more readable form.This option also helps with a case that can otherwise be confusing: a file that appears to be modified according to
hg status
, but for whichhg diff
prints nothing. This situation can arise if we change the file's execute permissions.The normal diff command pays no attention to file permissions, which is why
hg diff
prints nothing by default. If we supply it with the-g
option, it tells us what really happened.
To summarize, hg diff
command misses several kinds of information on changes: attributes, permissions, file names, etc. These changes may exist even if you have a single parent. And hg status
correctly takes into account all changes. To see what has happened, use hg diff -g
. It's the answer to the question 'what happens'.
Seems like backwards compatibility is the 'why'. I'm not sure, but I suppose that the 'normal diff' is some widespread or built-in Unix/Linux tool (judging from the fact that both hg and git come from that world).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With