Uploaded image for project: 'Maven SCM'
  1. Maven SCM
  2. SCM-583

mvn release:prepare fails when there is a different branch in hg outgoing changes

    XMLWordPrintableJSON

Details

    • Patch

    Description

      Hello

      Using release:prepare, the hg provider assumes it is free to use the basic 'push' command as in 'hg push repoUrl'.

      However, if you have created and commited a local feature branch, the release will fail, because the default behaviour of Mercurial is to abort the push if it would create new remote branches, as illustrated :

      MacBook-Pro-de-laurent:hgsample laurent$ hg out
      comparaison avec http://macbook-pro-de-laurent.local:8000
      searching for changes
      changeset:   57:33b0705da6e8
      branch:      local-dev ### the local feature branch you are working on
      user:        laurent
      date:        Fri Nov 12 21:10:37 2010 +0100
      summary:     add local-dev
      
      changeset:   91:ca4aabf8d3b3
      tag:         tip ### the working branch you want to release
      user:        laurent
      date:        Sat Nov 13 00:49:49 2010 +0100
      summary:     ajout hgrelease
      
      MacBook-Pro-de-laurent:hgsample laurent$ hg push
      pushing to http://macbook-pro-de-laurent.local:8000
      searching for changes
      abort: push creates new remote branches: local-dev!
      (use 'hg push --new-branch' to create new remote branches)
      

      Since the hg provider does not check for possible local branches, all pushes (checkin and tag) will fail with exit code 1 when the hg push command is triggered :

      MacBook-Pro-de-laurent:hgsample laurent$ mvn release:prepare
      ...
      [INFO] EXECUTING: /bin/sh -c cd /Users/laurent/Desktop/work/rrepo/hgsample && hg push http://127.0.0.1:8000
      [ERROR] 
      EXECUTION FAILED
        Execution of cmd : push failed with exit code: 1.
        Working directory was: 
          /Users/laurent/Desktop/work/rrepo/hgsample
        Your Hg installation seems to be valid and complete.
          Hg version: 1.6.4+20101001 (OK)
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      

      The expected Mercurial fix for this case is to use push --force or --new-branch to push the feature branch (which is not always the preferred solution) to the repository, or to use push -rbranchname to only push working branch changesets.

      The attached patch uses the second solution. It introduces a HgOutgoingConsumer and a HgChangeSet to parse the output of 'hg out', looks for a possible local feature branch, warns (like Mercurial) if one is found, but does not abort the release, instead, it will find the current working branch name, and use the push to use the -rbranchname option.

      I believe this is a legitimate fix, since Mercurial, like all DCVS, promotes local feature branches usage, and it was a bit sad to see the mvn release fail on the releasable branch because of this

      Attachments

        1. SCM-583-maven-scm-provider-hg.patch
          15 kB
          Laurent Perez
        2. SCM-583-maven-scm-provider-hg-reopen.patch
          1 kB
          Laurent Perez

        Issue Links

          Activity

            People

              olamy Olivier Lamy
              laurent7979 Laurent Perez
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: