How can you do a merge 'conflict report' in Mercurial? - mercurial

How can you do a merge 'conflict report' in Mercurial?
Given two conflicting revisions of a file in two heads, how can you output a report showing the parent and the two sets of revisions in each head?
Basically, I would like to send a 'report' of the conficts to the developer who owns the file so he can comment on how best to do the merge.
We use BeyondCompare as our merge tool - couldn't see an option to do this in BeyondCompare.

Revisions span all files, so whatever report you're envisioning it won't have revision info per-file.
If you've begun a merge with hg merge and have gotten merge conflicts you can do hg resolve --list to get a list of all the files that conflict. The hg parents command will, during a merge, list the two heads that are being merged.
You could use something like hg archive -I file1 -I file2 --revision head1 head1.zip to make an archive file with the files file1 and file2 as they stood at revision head1. If you do that for all the files in conflict and for each head you've got something you can send.
Ideally you just tell the dev to pull, merge, and push the merge -- this is easily handled within Mercurial and clumsily handled outside of it.

Related

How to search for filename throughout Mercurial repository?

I want to search for a filename across all my commits/branches and find out which commits/branches contain that filename. I don't know which subdirectory/subdirectories of the repo the file would be in.
I've tried hg grep <filename>, but that only seems to show files containing "filename".
I've also looked at Mercurial - determine where file was removed?, but that really help me if a file was created on a different branch. The person asking that question suggested hg log myfile -v, which seems like it could work, but doesn't. I know that somewhere in my repo the file exists because I get something back when I do find .hg | grep <filename>, but that doesn't tell me (at least not clearly) which commits/branches.
You have to read hg help patterns and maybe hg help filesets in order to write correct pattern for the file (most probably you'll be happy with just pattern)
If file exist now in working directory (i.e. was added and not removed later), you'll find it with hg file <PATTERN> and will determine full path by output, see above (pattern used)
>hg file **/test-extra.t
tests\test-extra.t
and call hg log with full filename
In any case (hg file returned 0 for removed file or file still in WD) you can call hg log <FILESET> and get history too. Log for existing will be too long, will show deleted unique filename sample
>hg log set:**/dulwich/tests/__init__.py -Tcompact
223 0b6c08800d16 2009-07-23 08:48 +0100 a
delete the dulwich fork we have
2 c43c02cc803a 2009-04-22 16:59 -0700 schacon
added dulwich library and got the script to call it for clone
If your set will be too wide and (may) include files with the same name in different folders, you have to verify filenames by calling log with more details about files, f.e. with -Tstatus
hg log 'glob:**/<filename>` -Tstatus
seems to do the job. It doesn't give me the commits containing <filename>, but it does give commits (and their branches) involving filename.
Credit to Lazy Badger's answer for pointing me to this.

can hg copy be used with hg merge?

From one source file I made a copy using hg copy.
Now I'm going to Change some stuff in the second file (the copy) and I want to be able to merge the future changes of the original file into the second file.
Can this be done using hg merge? Right now when I try to do something like
hg merge NewFile.html -r 130:f24199b5b945
using the most current changeset of the original file, I get an error: abort: please specify just one revision.
No, the two files are separate after that, and except for one file originating from the other, they do not share any history after that.
You will either have to duplicate your modifications in the other file, or you need to find another way to do this.

Splitting subfolders of an SVN repo into individual Mercurial repos results in error "abort: expected trunk to be at 'trunk/module1', but not found"

I have an SVN repo with structure like this:
/branch
/tags
/trunk
/trunk/module1
/trunk/module2
/trunk/module3
I am trying to separate this into individual Mercurial repos, where each new Mercurial repo retains the revision history of that module's files. The end result would be
/module1-hg
/module2-hg
/module3-hg
Based on this guide (http://wiki.colar.net/selectively_converting_subversion_repository_to_mercurial),
I have tried using
hg --config convert.svn.trunk=trunk/module1 convert https://repo.url/ module1-hg
but that results in the following error:
abort: expected trunk to be at 'trunk/module1', but not found
I am able to convert the whole SVN repository, but I'd really like to separate the modules at this point. I feel like I just can't find a good example of the syntax to split these apart. Can anyone help?
I recently did this but I did it in several steps.
Firstly, I converted the whole repo to be a mirror of the SVN repo. I used the hgsubversion extension for this but if you've done it using the convert extension then that's fine.
The second step was where I split the repos up. I used the convert extension with a filemap to exclude some folders and rename others.
For example:
hg convert bigrepo module1-hg --filemap module1.txt
And module1.txt would contain the following:
exclude module2
exclude module3
rename module1 .
That would create a repo called module1-hg excluding modules 2 and 3. It would also move the source of module1 into the root of the repo instead of a subdirectory.
You could then repeat the action for modules 2 and 3 with similar filemap files.

delete files in history to save some space in mercurial

ok, when I was young, I put severial big files(like resource file, dll, etc..) in my mercurial repos. and I found the size of it is so big that I cannot easily push it into bitbucket,
any way to delete this files history EASILY?
I put all those files in /res and /dll path.
edit:
this is a solution, but it will delete part of the history, so maybe there is a better solution.
Mercurial Remove History
Your best bet is to use the convert extension, but warning you'll end up with a totally different repo. Every hash will be different and every person who cloned will need to delete their clone and re-clone.
That said, here's what you do:
Create a filemap file named filemap.txt containing:
exclude res
exclude dll
and then run this command:
hg convert --filemap filemap.txt your-source-repository your-destination-repository
For example:
hg convert --filemap filemap.txt /home/you/repos/bloatedrepo /home/you/repos/slenderrepo
That gets you a whole new repo that has all of your history except the history of any files in /res and /dll, but again it will be a new, unrelated repo as far as mercurial (and bitbucket) are concerned.

Mercurial: Remove file from all changesets

I understand how to remove an entire changeset from history but it's not clear how to remove a subset instead.
For example, how do I remove all DLL files from an existing changeset while leaving the source-code alone?
Because the revision ids (e.g. a8d7641f...) are based on a hash of the changeset, it's not really possible to remove a subset of a changeset from history.
However, it is possible to create a new repo with a parallel history, except for a certain set of files, by using the Convert extension. You'll be converting a Mercurial repo to a Mercurial repo, using the filemap to exclude the files you don't want by adding excludes. This will create a new, unrelated repository, which means that any clones people have won't be able to pull from it any more, and will have to re-clone from this new repo.
Make sure all your teammates have pushed their local changes to the
central repo (if any)
Backup your repository
Create a "map.txt" file with the following content:
# this filemap is used to exclude specific files
exclude "subdir/filename1.ext"
exclude "subdir/filename2.ext"
exclude "subdir2"
Run this command:
hg convert --filemap map.txt c:/oldrepo c:/newrepo
NOTE: You have to use "forward-slash" in paths, even on windows.
Wait and be patient
Now you have a new repo at c:\newrepo but without the files
PS. In the "upper" repo you have to remove all changesets and re-push your new repo.
PPS. I actually wrote a blog post about this that has more details (including stripping the changesest in Bitbucket etc.