Geoffrey Zheng
Geoffrey Zheng

Reputation: 6638

In mercurial, how to deal with identically named file and directory in two revisions?

The problem can be trivially illustrated:

hg init temp
cd temp
touch a
hg ci -A -m file
hg rm a
mkdir a
hg ci -m dir
hg up -r0

The last command fails with abort: Is a directory: a (or a more cryptic Access is denied on Windows).

Is there any workaround?

I ran into this exact problem when converting legacy code base. I really need to fully automate the conversion since I have dozens of versions of a huge code base to deal with, and synonymous file/dir can happen at any time.

Upvotes: 4

Views: 102

Answers (1)

Matthew Flaschen
Matthew Flaschen

Reputation: 285077

Add:

hg purge

before the last update, to get rid of the empty directory. Note that even if you had added the directory, it would still not be tracked; Mercurial does not track empty directories (it only tracks non-empty ones implicitly).

purge removes "Unknown files" and "Empty directories".

Upvotes: 7

Related Questions