4

Mercurial Queues is about patches, and patches know nothing about file renames. Is this the reason why Mercurial Queues don't support file renames, or am I doing something wrong renaming the file? I have worked on a patch queue modifying just one file called foo. Now I go back to patch 4 and rename the file via hg mv:

hg qpop 4     # Unapply all patches until patch 4.
hg mv foo bar # Rename file and led Mercuial know about it.
hg qrefresh   # Should apply changes to unapplied patch 4.
hg qpush -a   # Should apply all unapplied patches.

I get the following error:

unable to find 'foo' for patching
1 out of 1 hunks FAILED -- saving rejects to file foo.rej
patch failed, unable to continue (try -v)
patch failed, rejects left in working dir
errors during apply, please fix and refresh 5.diff

So how should I do to handle file renames with Mercurial Queues? Mercurial commits handle file renames for a reason (as without, it would lose the whole history about the editing of the file after renaming).

Update

Just noticed that hg histedit folding changesets and hg collapse also lose the information of file renaming, the file shows up as a new one instead of a renamed one, and I guess this is for the same reason. Seems like collapsing private changesets is not possible in Mercurial without loosing that information?

Update 2

Found out collapsing private changesets without loosing rename information is possible with hg rebase and its --collapse option, e.g. hg rebase -s 5 -d 4 --collapse. The issue that the other commands should sostain rename information is still vacant, but using the hg rebase command there is at least a way to achieve the desired result.

Iodnas
  • 3,414
  • 24
  • 26
  • it looks sort of strange, because `hg help mq` has note about exactly your case: _"By default, mq will automatically use git patches when required to avoid losing file mode changes, copy records, binary files or empty files creations or deletions."_ – Andrei Dziahel Dec 17 '12 at 07:47

1 Answers1

0

Is this the reason why Mercurial Queues don't support file renames,

no.

or am I doing something wrong renaming the file?

no.

Yes, patches in chain will have troubles, if they was prepared for foo file, but later in will be bar, but due to different reasons: patches are independent, and every and each patch know nothing about changes in others - they work with context, not with sequence of operations in separate patches. You done rename correctly, but this changeset invalidates later changesets, prepared on old content

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • 1
    So how should I do to handle file renames with Mercurial Queues? – Iodnas Dec 10 '12 at 16:36
  • 1
    maybe (just guessing, can't verify it atm) you could manually create a git styled diff (supports renames), put it in .hg/patches/somename and echo somename >> .hg/patches/series and see if it applies? – Łukasz Gruner Jan 21 '13 at 22:38
  • I'll confirm creating a git styled .patch file retains rename information once imported at very least – Thymine Jul 22 '13 at 16:31