Pushing a local clone to remote repository with Mercurial - mercurial

Here is what I did:
Cloned a remote repository to my local computer. Created a second clone from the first clone. Made changes in the second clone. Never touched anything that resides in the first clone.
Now what happens if I directly push to remote repo from the second clone? A new branch is introduced in the remote repo?
Maybe a stupid question but I can't test it because there are other developers working on the code and I don't want to mess anything.
Thanks.

Now what happens if I directly push to remote repo from the second clone? A new branch is introduced in the remote repo?
What you would want to do in this situation is clone the central repo again (in case any other programmers made changes) merge your changes with those, and then push that back to the central repo.
This ensures that your branch is now part of the main branch again.
Metropolis
EDIT
Maybe this will be a little more clear
Clone repo1 to your machine
Make a clone of repo1 on your machine to keep the original in tact
Make changes to repo2 on your machine
Pull changes from repo2 to repo1, merge (if needed)
Clone CR again (in case other programmers made changes)
Pull changes from repo1 to the newly cloned repo (merge if needed)
Push newly cloned repo back to CR
Clone CR again and remove all of your repos to get the newest copy

Related

Mercurial CLONE with PULL on a repository with subrepos doesn't create a fully independent repository

I have a shell repository OriginalWithSubrepo with a subrepository Sub containing a bunch of actual files.
When I clone OriginalWithSubrepo like this
hg clone --pull --noupdate "C:\TestRepo\OriginalWithSubrepo" "C:\TestRepo\OriginalWithSubrepo-clone"
The clone thus created contains just a few mercurial housekeeping files, there is no actual data from the original Sub\.hg directory. I don't know what those files mean but apparently they are enough to recreate the repo because when I update the working directory in clone, the whole thing gets filled out with all the files, including inside the Sub\.hg directory. However, if I clone, then rename the original, and then attempt to update the clone, it doesn't work saying the OriginalWithSubrepo is not found, which means it's all based on links to the original.
This problem doesn't arise when I run clone with update, or when I clone a repository without subrepos.
It behaves the same when I clone to a network share, which is where I really want it to work.
So how do I make a fully independent clone of a repo with subrepos (w/o a simultaneous update)?
Windows XP, hg version 3.4.1
When you add the first subrepo to the parent repo, .hgsub is added to the parent repo. The subrepo only becomes a subrepo from the changeset that commits .hgsub.
When you do hg clone --noupdate --pull parent parent-clone, parent-clone is not at any changeset yet, and so not yet at a changeset at which the subrepo has been created
So how do I make a fully independent clone of a repo with subrepos (w/o a simultaneous update)?
I don't think you can do this as such.
But this may achieve what you're trying to do (I'm reading between the lines here, but I'm guessing to have the repo on the share, but without any files visible):
Create repos on your network share for your parent and sub \\fileserver\repos\OriginalWithSub\ and \\fileserver\repos\Sub\
Modify your local OriginalWithSub .hgsub set the remote path to be \\fileserver\repos\Sub\ and commit.
push your local repositories to their respective network share equivalents.
Both repositories now exist on the network share, without any files visible apart from inside .hg, and you can clone \\fileserver\repos\OriginalWithSub\ (with update) from another computer and get the full history of both OriginalWithSub and Sub.

Moving my mercurial repository to the central server, make mine a clone

Let's say my development team has a central server where we all clone our repos from, and commit/push back to it.
Now let's say I create a new repo on my desktop, hg init, commit. How can I make this repo on my desktop become the "parent" repo in the central server? I know I can either clone or just copy the repo to the central server. But the key is, without me having to clone that repo to my desktop again? Its really big so that initial clone can take a long time. Isn't there a way I can just edit a file to make my repo think its a clone instead of being the "parent"?
Information from where repository is cloned is written in .hg/hgrc file in your repository.
Create that file (if it does not exist) and add following lines
[paths]
default = https://my.parent.repository
Similary, if you want repository to think it is not clone of any repository, just remove those lines if they exist.

Local project workflow with Mercurial Hg and Bitbucket

Usually I create my websites (PHP, HTML, CSS) local on my mac. I've MAMP and Mercurial (Hg) installed.
When I start a new project I draw up a new project directory in "htdocs" and begin with hg init. New files were added by hg add to the project or excluded in .hgignore. All changes in this project are completed with an hg commit.
Additional to the local project I push my whole project into a private repository to Bitbucket (hg push https://bitbucket.org/MyUser/MyProjectRepository). That works perfectly.
The problem begins when a second person works at the project at the same time. He clones with hg clone https://bitbucket.org/MyUser/MyProjectRepository my private Bitbucket repository.
When I change and commit a css file local on my mac, push it afterwords to Bitbucket and the second person changes something on his local css file at the same time he gets a merge problem when he he tries to push his changes to Bitbucket.
Does anyone know what the problem is?
The second person needs to pull and merge your changes from the bitbucket repository before pushing his changes back.
Take a look at HGInit here for a great introduction to using Mercurial with a team.

No pushing of a local Mercurial commits to SVN with HgSubversion?

I am making say 4 local commits in HgSVN, then I updated my local code to an earlier revision, I added changes to it, did local commits, merged with server code and when tried to push, I was not allowed because of the 4 local commits not merged.
How to delete/remove these 4 local commits from HgSVN history and push the code ?
What should be done in this scenario ?
using HgCommit for saving code to the local machine and
HgWorkbench for pushing the local changes to the server
Your main big problem: you prefer do nor read docs and use tools blindly. Otherwise you have to know one of the biggest limitation of HgSubversion: it is not possible to push back to Subversion mergesets from Mercurial
"...Mercurial merges cannot be pushed to Subversion"
Also, HgSubversion page on Mercurial wiki clearly states:
The important point to note is that hgsubversion cannot push merge changesets to a svn repository. This means you should not try to merge this new head -- if you do so, hg push to svn will fail. Instead, you should rebase the changesets that you want to push to the Subversion repository (see Rebasing changes below)

Pushing mercurial repo without pushing subrepos

I'm using Mercurial 1.6. I have a repo with a few subrepos (11). I would like to push the parent repo to the default remote repo without pushing the child repos. Reasons for wanting to do this include:
I'm using SSH repos, and it takes a long time to establish a connection and push nothing to each of the subrepos.
I have commits in subrepos I don't want propagated to the remote repos (yet).
Subrepos have named branches that should not be propagated to the repote repos (and there's apparently no way to pass branch names to the push operation of the subrepos).
However, I've been unable to find a way to accomplish this. I tried deleting the content of .hgsub and .hgsubstate (without committing), but still mercurial insists on pushing the subrepos.
How can I push the changes from the local repo to the remote repo and ignore the subrepos temporarily?
I think you'll need to make local clones of the subrepos.
The problem with pushing the main repo without pushing the subrepos is that the contents of the subrepos are not part of the main repo - only their states are. The contents are referenced from the original location specified in .hgsub. So your main repo's .hgsubstate says "subrepo A is at revision abcd1234", but abcd1234 is a change you made that you don't want to push... and now what would happen if you cloned the main repo? It'd try to clone the subrepo from its original location and update it to abcd1234, but that revision doesn't exist in the original location, so the clone would fail.
Instead, you can make local clones of each external repository and reference those as the external locations of the subrepos. Then when you push the main repo, the subrepo changes will only propagate to your local clones. When you're ready to share those changes, just go over to the local clones and push from there, and you'll be able to pass branch names and so on.