How can I merge the two heads in Hg now? - mercurial

I read many posts already, and it seems like none can help.
yeukhon#glasslab:~/hg/graphyte-webclient/webclient/apps$ hg merge
merging .hgignore
merging webclient/codebundle_ldap.log
warning: conflicts during merge.
merging webclient/codebundle_ldap.log failed!
merging webclient/codebundle_lib.log
warning: conflicts during merge.
merging webclient/codebundle_lib.log failed!
merging webclient/graphyte_lib.log
warning: conflicts during merge.
merging webclient/graphyte_lib.log failed!
merging webclient/profile_models.log
warning: conflicts during merge.
merging webclient/profile_models.log failed!
30 files updated, 1 files merged, 0 files removed, 4 files unresolved
use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
I tried this, which marks each as resolved I think
hg resolve -m webclient/profile_models.log
etc
and then update again, but doesn't work. It still tells me
abort: outstanding uncommitted merges
This is my hg summary
yeukhon#glasslab:~/hg/graphyte-webclient/webclient/apps$ hg summary
parent: 106:5082a4f13c33 tip
merged with yeukhon's repo
parent: 96:0e3cfc289a18
Put logs into one directory called logs.
branch: default
commit: 35 modified, 4 unresolved (merge)
update: (current)
MY co-worker pushed one and I just pushed another one. How do I deal with this problem? Thanks.
Those logs are no longer needed. In fact, in my push I removed them because I put them in a directory called "logs".

After resolving the merge, you must do a commit before updating again.
Each time you merge, you must commit before doing anything else. So just do hg commit, give some meaningful commit message and you will be able to continue your job.

Related

"hg push" reports "added 1 changesets with 0 changes to 0 files." Huh?

Using Mercurial, I've just done a merge/commit/push sequence, and the push reported:
remote: added 1 changesets with 0 changes to 0 files
... which had me freaking out for a few seconds.
The full sequence of commands and outputs was:
% hg merge -r that_other_branch
63 files updated, 0 files merged, 1 files removed, 0 files unresolved
(branch merge, don't forget to commit)
% hg status
... <63 files marked 'M', one marked 'R'> ...
% hg commit
% hg push
pushing to ssh://hg#bitbucket.org/mycompany/mycompany-coolwebsite
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 0 changes to 0 files
%
When I look at the remote repository (on Bitbucket), I see that it does list all 64 files, and the diffs look right. So I'm satisfied that the merge and push did what I wanted, but that last message from hg push has me mystified.
Is this a bug in Mercurial? (hg --version reports "2.6+20130507", and I'm on OS X 10.8.5)
Or is the message correct, and I'm just too dense to understand what it's trying to communicate?
(If it makes a difference, the files in the head revision of the target branch were identical to the files in the ancestor revision common to that head and 'that_other_branch' -- which accounts for why there were all 'updates' and no 'merges' resulting from the hg merge.)
Everything's probably fine. Since that 1 new changeset is a merge it's probably being excluded from those totals since every change it contains is already in one head or another that's already on the remote repo.
Other changesets that could yield a similar message are those that only alter the permissions of files, but that's clearly not the case here.

How do I restore files I deleted by mistake from mercurial during an uncommitted merge?

Stupid mistake on my part, but I did a pull & merge and forgot to do a commit after the merge.
I started working with some files and deleted a folder by mistake. I tried doing hg restore on the files, but I get the error:
abort: uncommitted merge with no revision specified
and if I try to do hg ci I get:
abort: cannot commit merge with missing files
How can I restore the files so I can commit the merge and continue working?
Try:
hg revert <file> -r <specific_revision_to_restore>
When there is a merge in progress, Mercurial doesn't know which parent from which to restore the revision.

How to tell mercurial to 1. Discard local file 2. Use remote file

Sometimes I can't seem to be able to track the merge conflicts.
I need a command that allows me to discard one of my uncommitted files and then update it with the remote copy.
I tried hg revert myfile followed by hg pull , hg commit
but it still won't let me merge or commit.
It keeps telling me to fix unresolved conflict first.
You might need to let Mercurial know that you have resolved the conflict, using hg resolve. From the man page:
hg resolve [OPTION]... [FILE]...
redo merges or set/view the merge status of files
Merges with unresolved conflicts are often the result of non-interactive
merging using the "internal:merge" configuration setting, or a command-
line merge tool like "diff3". The resolve command is used to manage the
files involved in a merge, after "hg merge" has been run, and before "hg
commit" is run (i.e. the working directory must have two parents). See "hg
help merge-tools" for information on configuring merge tools.
The resolve command can be used in the following ways:
- "hg resolve [--tool TOOL] FILE...": attempt to re-merge the specified
files, discarding any previous merge attempts. Re-merging is not
performed for files already marked as resolved. Use "--all/-a" to select
all unresolved files. "--tool" can be used to specify the merge tool
used for the given files. It overrides the HGMERGE environment variable
and your configuration files. Previous file contents are saved with a
".orig" suffix.
- "hg resolve -m [FILE]": mark a file as having been resolved (e.g. after
having manually fixed-up the files). The default is to mark all
unresolved files.
- "hg resolve -u [FILE]...": mark a file as unresolved. The default is to
mark all resolved files.
- "hg resolve -l": list files which had or still have conflicts. In the
printed list, "U" = unresolved and "R" = resolved.
Note that Mercurial will not let you commit files with unresolved merge
conflicts. You must use "hg resolve -m ..." before you can commit after a
conflicting merge.
Here's how you pick up the version of the file from the server.
When you "hg pull", all changes from the server come into your copy of the repository. You can get the contents of a file in any revision using:
hg cat -r <rev> <file>
Use that to overwrite the local file, and commit.

Mercurial: How to compact/combine specified old revisions into one?

I've got a repository. In the middle of its life-cycle I deleted a lot of unnecessary files from it (I decided to keep them unversioned).
hg remove
hg commit
The repo grows bigger and bigger.
And I decided to get rid of old revisions the from initial one to the revision where lot of files were removed (let's name it X).
Other words I want combine these revisions (from the initial to the X) into one initial revision.
But same time to keep the history of the following revisions (X+1, etc..) as they are.
I googled for the solution, but failed.
And found nothing clever than do this:
hg init newrepo
cd oldrepo
hg archive -r X newrepo
hg export -r X+1: -o "~/patches/%R-%h.diff"
cd newrepo
hg commit -A -m 'initial release (after archiving)'
hg import ~/patches/*.diff
And damn it, after few successfully applied patches
I receive:
Hunk #1 FAILED at xxx
Hunk #2 FAILED at xxx
2 out of 2 hunks FAILED -- saving rejects to file xxx.rej
abort: patch failed to apply
What I do wrong?
I've got 1 repo without branches (to be more exact to the revision X all branches were merged).
The second solution was
* hg convert to svn
* hg convert to mercurial from revisiob X+1
Failed with python backtrace (probably it was caused by our repo has about 3K files).
To filter out files from repository, you want to use hg convert (Mercurial to Mercurial) with --filemap argument (see documentation for more details). Keep in mind the affected changeset IDs (and those of all their descendants) will change.
Take a look at the Collapse extension which seems to do what you want.
You can fold changesets with MQ, or use histedit extension

How to resolve merging conflicts in Mercurial (v1.0.2)?

I have a merging conflict, using Mercurial 1.0.2:
merging test.h
warning: conflicts during merge.
merging test.h failed!
6 files updated, 0 files merged, 0 files removed, 1 files unresolved
There are unresolved merges, you can redo the full merge using:
hg update -C 19
hg merge 18
I can't figure out how to resolve this. Google search results instruct to use:
hg resolve
but for some reason my Mercurial (v1.0.2) doesn't have a resolve command:
hg: unknown command 'resolve'
How can I resolve this conflict?
To highlight an answer in a comment for Hg 1.1+:
For Hg 1.1+ fix the file by hand and then do
hg resolve -m test.h
to mark the file as merged.
Valid for hg < v1.1 only
There is no need to call any hg commands. Unlike svn, Mercurial does not track conflicted files. If you call hg status, you'll see that the file is simply marked as modified.
Just fix the file by hand and commit.
Tracking conflicts was introduced in Mercurial 1.1, which is a newer version that you are using (you should really upgrade, Mercurial 1.1. was released in December 2008).
In that version you gained the resolve command which works similarly to svn resolve.
As I remember it, Mercurial would leave merge markers (the <<<< and >>>> lines) in your file when there is a conflict, unless you have configured a merge tool. This also applies to newer versions -- I have no merge tool configured and get the merge markers when conflicts occur. I can then manually fix the file and mark it resolved with hg resolve.