Mercurial Hg and multiple users on a single repo - mercurial

User A commited and pushed File A to the repo incrementing the version to 10. In the meantime, User B commited File B and started pushing out to the repo. User B got a message about 'pushing changes will create a new head, merge when possible'. User B did not know what to do at that time.
User B is me. What should I have done? I just freaked out and re-cloned the repo. My local copy was at version 9 at the time of my commit. So I wanted to update mine to 10 and then push mine out.
I am using Mercurial Hg.
Thanks.

You have to pull changes and merge them (In details you can read about it here: http://hginit.com/04.html)
Also - don't refer to revision number, it makes sense only for single repository. As long as you have several copies of the one - the better is to refer to the commit by its hash.

Related

Pulling without merging

I'm trying to make a crontab that pulls and makes a repository every day for me, but whenever i do that and the repository merges the crontab gets stuck.
Is there a way to pull without prompting a merge and without deleting my code?
Is there a way to pull without prompting a merge
Just hg pull by itself does not merge, nor does it ask the user for anything. The local repository will be added to, but the local working directory will not be touched. Nothing will be deleted.
If your .hgrc file is using a [defaults] section, you might be silently adding the -u/--update option without realizing it. That option tries to automatically do an update. If that's the case, then don't use defaults sections.
If this doesn't answer your question, then show us exactly what commands your cron entry is running, what the output is, where it "gets stuck" (is SSH asking for authentication credentials?), and which part you're trying to avoid.
The literal answer to how do you pull without merging is you hg fetch which gets the new remote changesets but doesn't update any files in your working directory. It sounds like what you're really asking though is "how do I update to tip and throw away any local changes?". If that's what you're going for you'd do:
hg fetch # gets new changesets
hg update --clean # update to latest files THROWING AWAY LOCAL CHANGES
Is that what you're going for?

Pushing/Pulling specific files/folders in Mercurial

I am (still) trying to completely migrate our company's SVN to HG.
For the most part I've succeeded, but we ran across a problem.
Our codebase has over 30 different projects, each one on its folder.
I've been asked multiple times how to commit and then push specific files to our central repository instead of being forced to commit everything everywhere to then push it, it's certainly annoying. Not being able to pull only specific projects is also an nuisance.
Is there any way to handle this like we used to in SVN? Where we could just commit what we wanted and not everything, and update only what was necessary.
Thank you.
A major difference between SVN and Mercurial is that you should have one repository per project in Mercurial.
You can change your repository to be multiple repositories using the convert extension.
Like Steve Kaye said you should create one repo per project, but as well you may want to create one master repo and include all your projects as subrepos This will allow svn like behavior of getting a copy of everything.

How to pull & merge particular folder, file from other repo

I have few questions and i would appreciate your help:
Say, i need specific folders from another repo merged into my repo/working dir. How would i do properly?
If i pull anothers repo and then merge. Afterwards, realizing this is not working, so i call 'hg update -C'. Did this cleaned my repo from the changes i pulled from another repo that i released is not what i need?
Can i do a pessimistic merge where it only adds and updates, but not deletes?
Thanks for helping learn Mercurial
Margots
I would just copy the needed files and folders from the other repo and commit them. You could technically do what you want as a merge but it's a manual, error-prone, finicky process.
If you haven't committed your merge update -C will abandon the merge. Do update -C <myVersion> to get the specific version you want.
This would be a messy process (see 1.) and I wouldn't bother. If there are problems you can always revert your file to a previous version.

Mercurial - getting changes from other repository

We have a Mercurial repository on BitBucket. This repository is used by a bunch of people.
Now I have another local repository which is a super-set of the BitBucket repo. What I want to do is work in my repo and get changes from the other repo whenever the others commit and push. I do not want to get the history of those other files just the last revision.
What is the best way to do that?
At the moment, I have cloned the other repository and I pull changes from that one into mine. That works but my issue is that whenever I get a change I have to do a huge merge in order to fix my repository. Is there another way to just get changes from the other repository and put them in my branch? I don't care about getting the history of those files. I could just copy and paste them in my repo but I'd like to be able to merge changes whenever possible which is not possible just by overwriting the updated files by copy-pasting...
You could put the other repository as a subrepository into yours.
This is not exactly what you requested, since you said that you don't want the history of the other repository, only the last revision.
But as you already noticed yourself, everything else that you tried (pulling the other repository into yours, copying files manually, ...) is a hassle.
With subrepositories, you can just update the subrepository to get the changes tht the others made.

How to create an alias for a mercurial user?

I am looking for a way to create an alias for a user that has commited to a mercurial repository. For example, if there is a user named user1 I'd like every commit done by him to be under the name user2.
If you're talking about changing the name that was already used for some commits, you can do that using hg convert with a source and destination type of hg and a --authors mapping file. However, in doing so you change the hash of every changeset, and if anyone has already cloned your repo you'll be hosing them.
If you're talking about commits to come, then just make them whatever you want using the -u option to hg commit.