Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-10558

Jenkins mercurial plugin - add support for bookmarks

    Details

    • Type: New Feature
    • Status: Open (View Workflow)
    • Priority: Critical
    • Resolution: Unresolved
    • Component/s: mercurial-plugin
    • Labels:
      None
    • Environment:
      all
    • Similar Issues:

      Description

      Mercurial plugin supports branches, which is nice. However, there are a lot of people, especially these coming from git, who think that such named branches are no good (they stay for ever, the branch is baked into the commit), and prefer using bookmarks* instead. There seems to be a lot of momentum around that extension, which culminated in it being incorporated into mercurial core since hg 1.8 (which means it is not an extension any more; rather, it is a first-class citizen now).

      Bookmarks is the closest thing that mercurial currently supports that resembles git-like branches. This is what we would love to use (as we share the view that such long running named branches are no good), but we can't since the Jenkins plugin doesn't support this (we would like to create ad-hoc Jenkins jobs for our features (topic branches), which are bookmarks, not branches, and once the feature is implemented, we drop the Jenkins job).

      A basic bookmarks workflow (in a repository):
      $ hg bookmark feature_x
      ... work work work
      $ hg commit -m 'some feature_x code'
      ... push to some canonical repo for others to see
      $ hg push -B feature_x -f // -f most likely needed as bookmarks are simply 'named heads' - but it doesn't matter for Jenkins

      Now some other collaborator:
      $ hg incoming -B // shows that there is a new bookmark, 'feature_x'
      $ hg pull -B feature_x
      and they can now start working on this bookmark ('lightweight branch').

      I tried simply changing the value of the 'branch' field in my project configuration, but it doesn't work. But it is very close. What seems not to work is the fact that Jenkins doesn't know the '-B' switch, and doesn't know that I want to import the bookmark. What Jenkins does is this (shortened a little, the template is not used):
      $ hg incoming --quiet --bundle hg.bundle --template "..." --rev feature_x
      $ hg unbundle hg.bundle
      adding changesets
      adding manifests
      adding file changes
      added 1 changesets with 1 changes to 1 files (+1 heads)
      (run 'hg heads' to see heads, 'hg merge' to merge)
      $ hg update --clean --rev feature_x
      abort: unknown revision 'test'!

      This means that the incoming changes were found with the bookmark name and were pulled, but the bookmark itself wasn't imported, and doesn't exist locally - and update fails. With the '-B' switch, it would work fine (tested on the command line):

      $ hg incoming --quiet --bundle hg.bundle --template "..." --rev feature_x
      $ hg unbundle hg.bundle
      adding changesets
      adding manifests
      adding file changes
      added 1 changesets with 1 changes to 1 files (+1 heads)
      (run 'hg heads' to see heads, 'hg merge' to merge)
      $ hg pull B feature_x // <---------------------------- that's the missing link
      no changes found
      importing bookmark test
      $ hg update --clean --rev feature_x
      1 files updated, 0 files merged, 0 files removed, 0 files unresolved

      With the single call to pull the bookmark (which effectively imports it) makes it work!

      Of course, there could be a mix of branch and bookmark, so the 'incoming' should use the branch name, and if and only if a bookmark is specified, a 'pull -B <bookmark_name>' should be issued, and the update should use the bookmark and not the branch. This means there should be some additional field for the bookmark, and some additional logic, but not that much, I think?

      I will take a look at the source code on GitHub to see if maybe I could help you with that, if you are interested?

      I as setting it as critical, as it has the potential to influence the decision whether we can use Jenkins or not for this project. Naturally, you are the bosses so feel free to squash it.

      As a side note: what is the relationship between the Jenkins Mercurial Plugin (version 1.37, code on GitHub) and Hudson Mercurial Plugin (version 1.35, couldn't find a repository)? I am asking since we use both, and it would be nice if the code could be written once and work for both servers, of course ;d

      Regards,
      wujek

        Attachments

          Issue Links

            Activity

            wujek_srujek wujek srujek created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Link This issue is related to JENKINS-5396 [ JENKINS-5396 ]
            jglick Jesse Glick made changes -
            Assignee Kohsuke Kawaguchi [ kohsuke ] Jesse Glick [ jglick ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 140752 ] JNJira + In-Review [ 175342 ]

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                wujek_srujek wujek srujek
              • Votes:
                8 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated: