in order to bypass the JIRA-mercurial plugin, I need to replicate my (private) mercurial repository in a private mercurial repository in bitbucket. I and the other users will continue to "push" our commits to our own private repository, but I want pushed commits to be "forwarded" to a certain bitbucket repository. This way, I can use the JIRA's bitbucket plugin and see the changes related to my bugs.
In other words, I want that, after each push in my private mercurial repository, the commits are forwarded to my repository hosted by bitbucket. I think I should create a push hook, but I never used them before...
I think that the following hook (installed on my server) solves my problem...
[hooks]
changegroup = hg push ssh://hg#bitbucket.org/path/to/my/repository
(Pls, move it into comment of Matteo answer)
changegroup isn't correct type of hook for this task, because
The changegroup hook is activated once for each push/pull/unbundle,
unlike the commit hook, which is run once for each changeset
according to docs, and I suppose, more right way is
[hooks]
commit =
Depending on what mercurial client you are using, there are a number of different ways to have your local repository "push after commit".
The TortoiseHg windows client allows you to configure this per-repository for all commits (under the "settings->commit" dialog), as well as for individual commits under the "options" menu when committing.
There are also hook scripts that you can use. A quick google search finds many different options.
Related
We have some restrictions on what we are allowed to put in our central Mercurial repository.
Is there some way I can keep stuff in my local Hg repository, without having it pushed to the central one?
Note:
The files might be connected to files in the central repository (branches for example).
Local stuff might later be incorporated in the central repository.
If you're using branches, you can set their visibility to secret. This will prevent them to be pushed.
hg phase --secret --force my-branch
When you want to share, you change their phase to draft and then they will be automatically collected during a push operation.
See hg help phases for more information.
You could also use Mercurial Queues. With MQ, you can work with patches (which are changesets) and update or re-order them based on changes in the official repository. This will also make it easier to incorporate some or all of your changes into the main repository or just discard them later.
Commit to your local repo, then push to the remote repo when you are finished.
You can push to your local repo as well, but from my understanding that is where your current development is?
I think you want Shelve Extension or Attic Extension.
The other option is if your using a newer Hg with better branching you can just fork the central repo somewhere like bitbucket and use that as your repository for your temporary stuff and potentially branch that.
Finally you could also just use .hgignore but that could be problematic later when someone does check in the file with the same name.
I have a mercurial server, running RhodeCode, that I commit my code to. My client has a Redmine installation and has requested that code I modify for them be stored on their server (understandable).
I would like to still commit to RhodeCode and after a successful commit, push these changes to their repository automatically. They have their code in both an SVN repository and a mercurial repository. I am allowed to commit to either - and they handle the synchronization between the two. My assumption is that it'd be easier to push to a mercurial repository.
I have a changegroup hook in mind, but I have a few technical questions on how this should work.
What is the best way to handle both receiving and pushing out to an external repository though?
User ----> RhodeCode ----> Redmine
At the RhodeCode step/changegroup hook, how do I forward on my changes? Can I do it directly from the main repository or am I forced to clone it into another directory and push that to the client?
Is there a better way to maintain my master repository and push my client's changes on?
I see no problem with this; the Mercurial hook in Buildbot works this way, doesn't it?
When I type hg outgoing, I get a response like this:
comparing with ssh://server:1234/path/to/repo
and a delay while it communicates over the network.
Why is this network traffic necessary? Is there something fundamental about Mercurial which means it can't remember which commits have been pushed, and which haven't?
Is there an alternative command which can give me similar information without having to communicate over the network?
As Mercurial is a distributed system, there are multiple ways for your changes to get from your local repo to the remote repo.
For example:
it is possible for someone to pull changes from you and then push those changes to the remote repo
you could actually just copy your local repo using whatever operating system you have and Mercurial would be totally unaware of that. You could then push the changes in this copy to the remote repo.
However, if you have Mercurial 2.1 or later you can use hg phase to determine which changesets have been pushed. Assuming you don't use hg phase to change the status of any changesets then the changesets with a phase of draft or secret have not been pushed and those with a phase of public have. Use
$ hg log -r "not public()"
to see unpublished changesets.
It won't catch the two examples I gave above but it will probably be good enough if you just want to know which changesets you have not pushed.
Look here or check hg help phases for instructions on how to work with phases.
A mercurial repository can potentially connect with multiple other repositories. So, I guess it needs to make sure the changes that weren't pushed from your repository, didn't arrive from another repository already.
I am in the process of setting up some third-party subrepositories under a Mercurial repository. One subrepo is another Mercurial repo hosted on Bitbucket.
Since it is a public repo, and I am not a contributor to it, I don't wish to push back to it. However I would like to still have the repository automatically cloned when I clone the parent repository. For one thing, I'd like to have access to the collective history of the subrepository so I can see what may or may not have changed over time.
So, I made an entry in the parent repo's .hgsub file as follows:
thesubrepo = https://bitbucket.org/user/repo
and cloned the repo using
$ hg clone https://bitbucket.org/user/repo thesubrepo
I made a commit to record the subrepo state. I then went to push my parent repo back to it's server (Kiln) only to discover that it was trying to push the subrepo I back to the Bitbucket server. The push to the Bitbucket subrepository appears to not do anything, though.
I did not observe this behaviour when I made a Git subrepo in the same manner (hosted on Git hub) using an entry in .hgsub like this
abc = [git]git://github.com/xyz/abc
Is it best for me just to do this by not setting up a subrepository, and just let Mercurial store the files as files? Or (preferably) is there some setting somewhere that I can use to tell Mercurial to never actually push the contents of this subrepo back to it's source location?
I'd rather be able to configure it to only push those subrepos manually, so if anyone can shed some light on this, I would appreciate it.
I found a reference to commitsubrepos = no in another stack overflow answer, which as far as i can tell is about commits, and not pushes of sub repositories. I then looked this up on the mercurial website, in the hope there might be some reference to a setting pertaining to pushing subrepos, but... no
You cannot (currently, as of version 2.0) ask Mercurial to not push subrepositories.
The fundamental problem is that Mercurial must ensure that you have a consistent state on the remote repository when you push. It would be unsafe if you could push back to Kiln and then have a changeset there that references a revision on Bitbucket that isn't there. Mercurial doesn't know if a changeset you have locally is published or if you created it — so it has to (try to) push.
We're currently working on a concept called phases. With that in place, Mercurial will begin tracking if a changeset is created locally or already published. That can be used for subrepositories too: if there are only changesets in the "public" phase in a subrepo, then there's no need to try pushing!
I've configured Mercurial to talk to Fogbugz as explained in their documentation. Should hg commit inform Fogbugz of the commit making the repository appear in the list of repositories and the commit message in the related bug as per the Bugz tag?
Judging by the instructions here, the trigger is not commit, but push: the hook is an incoming hook. The idea would appear to be that you have a central repo with this configuration installed, and when you push your change to the central repo it takes care of informing fogbugz. You might also be able to change the hook from incoming to commit, but it's probably better to pair the bug update with a push to some semi-official location.