Mercurial - 为什么不分歧?

时间:2011-09-21 22:05:35

标签: mercurial diff

我刚开始使用mercurial(用于windows)。根据教程http://hginit.com/01.html我创建了存储库等。但是diff命令没有显示我在文件中所做的任何更改。你有什么想法有什么不对吗? 提前谢谢!

2 个答案:

答案 0 :(得分:2)

基本步骤如下:

hg init .       ---- This make the current directory as blank hg repository

echo "XYZ" > test.txt   --- This creates a new file which is not added to version control yet.

hg add test.txt --- The file is added to repo for commit

hg commit test.txt -m "added file test.txt"  --- Now you can commit the file

hg log  ----- to see the log

hg diff test.txt ----- will show no diff as the latest file committed is same

echo "TTTT" >> test.txt   ----- make some changes

hg diff test.txt   -------- should show the difference of current file to latest in commit

hg commit test.txt -m "second commit"  ----- now once you have committed, latest in repo and working directory is same

hg diff test.txt ------ this diff should again be blank

答案 1 :(得分:2)

默认情况下,如果命令hg diff将显示工作目录与其父目录之间的差异。正如nye17所建议的,如果你在运行hg diff之前提交了一些更改,那么工作目录将与其父目录相同,并且不显示输出。在这些情况下,您可以通过运行hg diff -c -1来查看所做的更改。这将在前一个(-1)变更集上运行hg diff命令。