Question

I'm toying with the idea of adding a "remote-run (personal build) for Mercurial" ability in the TeamCity Visual Stuio plugin.

Since v6.5, TeamCity supports a "remote run branch trigger", where if a named branch matching the trigger in TeamCity is pushed, TeamCity will run a personal build of that branch.

The idea is taking the current outgoing changeset(s) from the current branch (let's say default), and moving them to a temporary named branch called remote-run. This is then pushed to the CI, so the personal build gets triggered, and if the personal build is successful, changes are moved back to the original branch, and the remote-run branch is deleted.

I have a few questions regarding this:

  1. Does it even makes sense?
  2. Which extension should I use for this? I believe MqExtension does everything I would need, but are there alternatives?
  3. What would happen if the user commits additional changes during the remote run? How would the "temporary branch" changesets merge back into the original branch?

The scenario I'm currently targeting is as follows: while working on the default branch, user adds 3 new revisions. He then wants to run those changes as a personal build on TeamCity, but he forgot to commit those revisions to a specially named branch. Instead, my addin will take those outgoing changes, and put them in the named branch. Once the personal build succeeds, those changes are then placed back in the original (default) branch, and pushed to the remote repository.

Something like this:

[default] A---B---C---D

Assuming B, C and D are the new revisions, I want the tool to do:

[default] A
           \
            [remote-run] B---C---D

And after it's done, return it to the original state, i.e.:

[default] A---B---C---D

EDIT: I managed to move the changes to another branch with Mq, this ended up being very easy. Unfortunately, I have no idea how to revert this change :)

Hope this makes sense!

Was it helpful?

Solution

That is exactly what 'hg rebase' command for. In your case use

hg rebase -s B -d A --detach

Make sure you use the latest version (latest night build). Recently a bug had been fixed that can affect this specified situation. Also, 'rebase' extension must be enabled for this to work. Make sure yo have following line in ~/.hgrc (or mercurial.ini) file:

[extensions]
rebase = 

EDIT: It seems I answered an opposite question (how to remove a local branch). To create a new named branch and import B,C,D revisions into it you'll need following sequence of commands:

hg qimport -r tip:B       #Revisions B,C,D will be imported into mq
                          #(here B is revision id of the "B" commit)
hg qpop --all             #Unapply all patches
hg branch remote-run      #Create a new branch
hg qpush --all            #Push patches into the new branch
hg qfinish -a             #Transform applied patches to regular commits

OTHER TIPS

You can have TeamCity tag your VCS root upon successful build. Might it not make more sense to just tag each successful build on default, without the separate branch?

I'm not sure otherwise of the motive behind your mission, what specific workflow do you want to benefit from?

Regarding item 3, there is no way to guarantee an automated merge back into default. If there are merge conflicts, whatever command script you put into your build config for the "personal build" will require its hand holding to get you back into a stable state - not particularly "CI".

Sorry I can't help more on first pass.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top