How does "hg merge" not affect the working directory?

Let's pretend that:

  • I have a repo called MyRepo.
  • I have uncommitted changes in my working directory.
  • I try from Repo1 and create a branch in MyRepo
  • I want to merge what I already had in my repo with what I just clicked.

As described here , the merge process changes the state of the working directory.

In my scenario, I do not want to lose the uncommitted changes that are in my working directory, because at this moment I am interested in the change of state of MyRepo; not the state of my working directory.

Is there a way to go through the merge process, including resolving conflicts manually without affecting the contents of my working directory? Can this process be performed only in temporary files? Or should I postpone my changes, merge, and then unshelve to restore my working directory to the state it was before the merge?

+6
mercurial
source share
5 answers

Use shelve or attic extensions to temporarily store your changes during a merge.

+4
source share

You cannot do this. As the documentation says, a merge is indeed a working tree. Resolving conflicts without checking the result is crazy. Either postpone or commit the changes, and then merge. If you do not want the commit to be visible anywhere, you can commit the changes, update the previous revision, merge the new branch, apply the temporarily committed patch and delete this temporary branch.

+3
source share

You can clone your repository to your last session, merge the changes with the clone, commit, and then pull the new set of changes from your cloned repository back to your current one.

+1
source share

I'm new to mercurial, but you can't clone from your local storage and copy your working copy to a clown? Could you start your merge in the original? You would save the state of your working copy in the clone, being free to allow the change to the original working copy.

Check it out first. I have never done this in hg.

0
source share

Just do it in clone.

  • Clone MyRepo for a MyRepo merge that will withstand all committed changes, but not your uncommitted changes
  • Inside the MyRepo merge pull out of Repo1.
  • Inside the myrepo merge all the hg merge you want
  • Inside MyRepo-merger, click on Repo1 or the original MyRepo

Clicking on MyRepo will not change the MyRepo working directory, so a safe action.

Remember in Mercurial that clones are incredibly fast and cheap - in modern file systems they use hard links under covers, so they do not even take up much disk space.

0
source share

All Articles