0

I've worked on some project. I'm able to see the difference between my project and its (sole) parent with:

hg kdiff3

(After I've configured "kdiff3" as shown here). However, I want to be able to edit my files, perhaps remove some of my changes, edit some of them or make new changes. But that command only shows me the differences, rather than let me edit them. If I try:

hg merge 5861231e8335

(When "5861231e8335" is the (sole) parent of the working directory) I get:

abort: merging with a working directory ancestor has no effect

So how can I "merge" with the parent? (preferably using "kdiff3")

Yaron Cohen-Tal
  • 2,005
  • 1
  • 15
  • 26
  • I'm not quite clear what you're asking. Can you give `hg log -G` output to illustrate the situation? Do you simply want to fold several changesets into a single one, i.e. combine several changesets into one? Then `hg fold` might be your friend. Mind, it is a history-editing function, thus you permanently change the history (make a backup!) and you might need to (forcibly) change the phase to draft before you can do so. – planetmaker Jul 16 '15 at 10:30
  • No, I just want to see the differences between the working directory and its (sole) parent, but in a way that I can edit my files. – Yaron Cohen-Tal Jul 16 '15 at 11:25
  • you want to edit the patch file as would be created by `hg diff`, thus between your current working dir state and the unmodified version you checked out? Or just see concurrently the current state of the working dir and in a 2nd view the unmodified state of the parent revision? – planetmaker Jul 16 '15 at 11:38

2 Answers2

0

First, you have misunderstood what hg merge does. It merges changesets from 2 parents. It doesn't merge uncommitted changes.

To merge uncommitted changes into the current tip changeset, you want:

hg commit --amend

which replaces the current tip with a new one.

To answer your question about editing in a differencer. I'm not aware of any method of editing a bunch of files in a file differencer; that's because the set of files get copied into the temp directory where it's obviously pointless to edit them. You can however, diff and edit one file at a time because one file is diffed in place without copying to the temp directory.

But surely, isn't it better to edit files in your normal editor rather than in a file differencer? Surely, one can edit, but only as a last resort. OTOH, if you use the trick of viewing diffs one file at a time, it is possible to edit in your real editor, then watch the diffs change in the differencer.

John Jefferies
  • 1,176
  • 7
  • 13
0

hg shelve lets you temporarily put aside (on a shelf) parts of the diff between the working directory and its parent, so it will give you the "remove some changes" part of what you want. It does not let you edit, but you could put what you have changed on one shelf, then reimplement the change. If you want to revert to the original change, you just put the new change on a new shelf, and pull the original change off its shelf.


Alternatively, create a copy of the parent changeset using hg export (or hg clone and update to the parent changeset, but you don't need the history for this), Once you've got your copy, you can merge the copy of parent with your working directory using kdiff3 directly, outside of Mercurial.

Sigve Kolbeinson
  • 1,133
  • 1
  • 7
  • 16