Why does “hg status” show changed files when “hg diff -g” doesn't? (One parent)

前端 未结 5 1124
借酒劲吻你
借酒劲吻你 2021-01-31 08:40

I have a repository where:

> hg st

shows that my working directory has some uncommitted changes, while

> hg diff


> h         


        
相关标签:
5条回答
  • 2021-01-31 08:53

    If you have ignorews or ignoreblanklines set in .hgrc then hg status will show it as changed but hg diff won't (assuming the changes are only whitespace of course).

    0 讨论(0)
  • 2021-01-31 08:55

    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 regular diff 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 which hg 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).

    0 讨论(0)
  • 2021-01-31 08:57

    In my case something was broken with hg. (same permissions and hg diff -g shows nothing). I fixed issue with next way:

    1. I cloned repository again in separate folder
    2. I removed everything from this folder except .hg
    3. I moved from old (broken) place everything except .hg to new place

    So after this step i have repository which cloned with current version of mercurial + exactly same files.

    After this steps i received same (empty) results for commands: hg st and hg diff -g

    0 讨论(0)
  • 2021-01-31 08:59

    I just deleted the files that showed up as modified (make a backup if needed) which caused all the files to show up with an ! next to it when I ran

    hg st
    

    After that I ran the following command to revert the files (which were already checked in):

    hg revert --all --no-backup
    

    and that fixed the problem

    0 讨论(0)
  • 2021-01-31 09:00

    In these situations (it happens a lot to my team), I find that this command will fix about anything:

    hg debugrebuilddirstate
    

    or

    hg debugrebuilddirstate -r tip
    

    It's lightly documented in the help documentation, but basically I believe it clears out the "dirstate" file which caches information about working-directory files. The next time you hg stat it will refresh it from scratch.

    One caveat: if you've added or removed files, that information will be lost when the dirstate is rebuilt.

    0 讨论(0)
提交回复
热议问题