85

Can anyone tell me what this Mercurial error means?

untracked file in working directory differs from file in requested revision

This occurred when doing an hg fetch:

C:\myapp>hg fetch ssh://hg/myapp-v1
pulling from ssh://hg/myapp-v1
searching for changes
adding changesets
adding manifests
adding file changes
added 93 changesets with 693 changes to 78 files (+1 heads)
updating to 797:0df7dbe7dc06
196 files updated, 0 files merged, 196 files removed, 0 files unresolved
merging with 704:edb7765768c6
abort: untracked file in working directory differs from file in requested revision: 'a/b/c/d.java'

From what I can tell this file (a/b/c/d.java) does not match any paths configured in .hgignore. And this specific file is also identical in the two (myapp & myapp-v1) repositories..

I am not clear what this even means. ??

Marcus Leon
  • 55,199
  • 118
  • 297
  • 429

5 Answers5

84

It's telling you you already have a file named a/b/c/d.java in your local working directory of the myapp repo, but it hasn't been added (tracked), and fetch isn't willing to overwrite it when updating/merging.

Things you can do are ether:

  • Move your copy of a/b/c/d.java out of the way and then do the pull/update. After that compare your moved a/b/c/d.java to the one fetch brings down.

or

  • hg add a/b/c/d.java, hg commit a/b/c/d.java, and then pull / merge

The former works because there's no longer a file in the way, and the later works because your copy is tracked so Mercurial can merge them.

Also, you should consider stopping using fetch. It combines pull and update and merge for you, which is just not a safe way to be. In this case your pull would have succeeded and both update and merge would have given you much more helpful messages.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • Prior to doing the merge `hg status` returns no outstanding changes. `hg add a/b/c/d.java` returns "a/b/c/d.java already tracked" – Marcus Leon Jan 27 '11 at 21:57
  • Interesting point about fetch vs pull/merge. I did a `pull`, and then `merge` where I get a lot of messages in the form: `remote changed dir/blah.xml which local deleted use (c)hanged version or leave (d)eleted?` – Marcus Leon Jan 27 '11 at 22:02
  • yeah, merging is coding and shouldn't be glossed over. to the first part we could probably figure it out with your `hg stat` output, but might it be the case that your current working directory isn't the repo root?, That would make it possible for hg add to say added but fetch say untracked. Just a guess, though. – Ry4an Brase Jan 27 '11 at 22:22
  • I think the important point is that at some time, these files WERE tracked but are not anymore in your working folder. So when you go to update, it sees the files will need to be overwritten. – O'Rooney Oct 19 '21 at 01:45
38

I got around this by running hg update --clean

peak
  • 105,803
  • 17
  • 152
  • 177
azeroth12
  • 449
  • 4
  • 3
13

Just accept the error dialog then tick Discard local changes, no backup

enter image description here

And you should be good, it will overwrite any untracked local files...

Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265
10

I tried Ry4an's answer (of deleting the file) and it still did not work, so I ran a purge and that got rid of all traces such that it worked after. Just in case somebody is looking for an alternative solution.

Justin Pihony
  • 66,056
  • 18
  • 147
  • 180
2

If using TortoiseHG you can check the "Discard local changes, no backup" option in the Update window.

Owen Pauling
  • 11,349
  • 20
  • 53
  • 64