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

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.

Related

Using mercurial, I added a new file and wrote code in it, then deleted that file. Can I retrieve it?

Pretty much the title. I've looked at a lot of similar questions asked here, and I can't seem to find something that applies.
Started by syncing with HEAD. Created a few new files. Filled in those files, they were being tracked at this point. I then not only deleted the files, but also removed them from being tracked (because of stupid UI). According to my understanding, those files are gone for good, but I thought I'd check with people who are smarter than me: Is it possible to retrieve them?
Mercurial does not store uncommitted changes, so if you did not commit the files then they are lost.
If you did commit them, then hg update -C will restore them (and all other files --- make sure there are no other changes you haven't committed and want to keep) to the latest commit for your working dir.

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.

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 can I commit a set of files only once in Mercurial?

I have some files I'd like to add to have them as a "backup". The thing is, I'd like to commit them only one time, and then, I'd like for Mercurial to don't track them anymore ( don't notify me if they're changed, and don't commit them on other commits ).
Basically, something like this:
hg add my_folder
hg commit -m "added first version of my_folder"
Then, after a while, the contents of that folder might change. And if I commit other files, the new version of that folder will get commited as well. This is something I'd like to avoid. Is it possible, without specifying directly which files I want to commit?
I've never seen any option in Mercurial that might allow that... but why not simply copy them elsewhere ?
I mean, what's the point of using a Version Tracking System if you don't need versioning on these items anyway ?
We ran into a similar case with binary documents ('.doc', images, etc...) and finally decided to commit them on a separate repository, dedicated to those.
I think the traditional way of doing this is to commit files named something like "file.ext.default", and just inform users that they should copy the defaults and modify the copies.
VCSs aren't backup sysytems. consider using a proper backup mechanism.
having said that you should be able to do this using hooks, there are many ways you could do this but ACLs would be an obvious one assuming a remote server