• Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • mercurial-plugin
    • None

      When using a tag as the branch with mercurial, in some cases, the build will fail (example bellow).

      This is because the branch is used as a param to "hg incoming". Only the revisions up to the tagged one are pulled in the local clone. Since the tag is set in a changeset after the tagged revision itself, the tag name becomes unknown to the local clone -> The hg command that use the tag fails.

      The only solution I know is to avoid using "--rev" for the incoming command (same for pull).
      The drawback is that more changesets than needed will be retrieved, but at least we are sure to have the required ones.

      Example of log (TAG is set to "5.131-p18"):

      [Starform-6.0] $ hg incoming --quiet --bundle hg.bundle --template "<changeset node='

      {node}

      ' author='

      {author|xmlescape}

      ' rev='

      {rev}

      ' date='

      {date}

      '><msg>

      {desc|xmlescape}

      </msg><added>

      {file_adds|stringify|xmlescape}

      </added><deleted>

      {file_dels|stringify|xmlescape}

      </deleted><files>

      {files|stringify|xmlescape}

      </files><parents>

      {parents}

      </parents></changeset>\n" --rev ${TAG}
      [Starform-6.0] $ hg unbundle hg.bundle
      adding changesets
      adding manifests
      adding file changes
      added 12 changesets with 13 changes to 3 files (+1 heads)
      (run 'hg heads' to see heads, 'hg merge' to merge)
      [Starform-6.0] $ hg update --clean --rev ${TAG}
      abort: unknown revision '5.131-p18'!

      (jglick, I assigned you the issue since you seem to be maintaining the plugin)

          [JENKINS-5396] Support tags instead of branches

          cdevienne created issue -

          cdevienne added a comment -

          The problem is the same on the first build. The issued command is :

          hg clone --rev ${TAG}

          which has the same effect : only the tagged revision, and not the one containing the tags, is retrieved.

          I suggest :

          $ hg clone --noupdate REPO TARGET
          $ hg update --rev TAG

          Regards

          Christophe

          cdevienne added a comment - The problem is the same on the first build. The issued command is : hg clone --rev ${TAG} which has the same effect : only the tagged revision, and not the one containing the tags, is retrieved. I suggest : $ hg clone --noupdate REPO TARGET $ hg update --rev TAG Regards Christophe

          Jesse Glick added a comment -

          This field was never intended for use with tags. Various aspects of the Hudson control flow make no sense if the revision is a tag; for example, changelog calculation and polling should probably be skipped entirely, since a tag is normally immutable once created.

          (Yes you can move a tag in Mercurial - but you would also need to decide on a branch holding the tag move commits. In other words, different branches can assign a tag of the same name to different revisions. Supporting such scenarios in the Hudson GUI is likely to be overkill when you can more easily run shell commands as part of the build to update your workspace to exactly what you want; changelogs and polling are what make this approach undesirable for regular situations.)

          Probably the user will have to indicate a tag in a separate field (mutually exclusive), or check a box saying that the branch field should be treated as a tag.

          Jesse Glick added a comment - This field was never intended for use with tags. Various aspects of the Hudson control flow make no sense if the revision is a tag; for example, changelog calculation and polling should probably be skipped entirely, since a tag is normally immutable once created. (Yes you can move a tag in Mercurial - but you would also need to decide on a branch holding the tag move commits. In other words, different branches can assign a tag of the same name to different revisions. Supporting such scenarios in the Hudson GUI is likely to be overkill when you can more easily run shell commands as part of the build to update your workspace to exactly what you want; changelogs and polling are what make this approach undesirable for regular situations.) Probably the user will have to indicate a tag in a separate field (mutually exclusive), or check a box saying that the branch field should be treated as a tag.
          Jesse Glick made changes -
          Issue Type Original: Bug [ 1 ] New: New Feature [ 2 ]
          Summary Original: Mercurial cannot build from a tagged revision in some cases New: Support tags instead of branches

          cdevienne added a comment -

          I get your point, and the behavior you propose makes sense. The changelog calculation should indeed be slipped entirely.

          As far a using shell commands as part of the build, the major problem is that hudson won't know what revision we actually build from. Moreover, it would require an additionnal pull since the tag might not be on the pulled branch.

          Do you think the solution you propose is easy to implement ? And when do you think it would be ready for use (if at all) ?

          Thanks,

          Christophe

          cdevienne added a comment - I get your point, and the behavior you propose makes sense. The changelog calculation should indeed be slipped entirely. As far a using shell commands as part of the build, the major problem is that hudson won't know what revision we actually build from. Moreover, it would require an additionnal pull since the tag might not be on the pulled branch. Do you think the solution you propose is easy to implement ? And when do you think it would be ready for use (if at all) ? Thanks, Christophe

          Jesse Glick added a comment -

          I have no current plans to work on it.

          "Hudson won't know what revision we actually build from" - true but this ordinarily only matters for purposes of changelog display and polling, which would be disabled for a tag-based job anyway.

          "it would require an additional pull since the tag might not be on the pulled branch" - if this is the case then there is little hope of a GUI configuration working for you. You would need to write a shell script to the effect of:

          hg pull -r branch-which-defines-tags $remote
          hg up -c branch-which-defines-tags
          hg pull -r $desired-tag remote
          hg up -c desired-tag

          I do not know of any repository "in the wild" which uses this style, and it is not clear Mercurial even makes it possible. According to

          http://hgbook.red-bean.com/read/managing-releases-and-branchy-development.html#id384894

          "when Mercurial is parsing the tags in a repository, it never reads the working copy of the .hgtags file. Instead, it reads the most recently committed revision of the file."

          where by "most recently committed revision" I understand "tip". If you have multiple heads in the repository (such as multiple branches), then it is impractical to control what tip happens to be.

          In my experiments using Hg 1.4.2, the behavior is not even this; after adding a tag on one branch, and setting it (-f) to something else on another branch, the second definition is always used - even if the working copy is updated to the first branch, .hgtags has been more recently edited & committed on the first branch, and .hg/tags.cache has been deleted.

          Jesse Glick added a comment - I have no current plans to work on it. "Hudson won't know what revision we actually build from" - true but this ordinarily only matters for purposes of changelog display and polling, which would be disabled for a tag-based job anyway. "it would require an additional pull since the tag might not be on the pulled branch" - if this is the case then there is little hope of a GUI configuration working for you. You would need to write a shell script to the effect of: hg pull -r branch-which-defines-tags $remote hg up -c branch-which-defines-tags hg pull -r $desired-tag remote hg up -c desired-tag I do not know of any repository "in the wild" which uses this style, and it is not clear Mercurial even makes it possible. According to http://hgbook.red-bean.com/read/managing-releases-and-branchy-development.html#id384894 "when Mercurial is parsing the tags in a repository, it never reads the working copy of the .hgtags file. Instead, it reads the most recently committed revision of the file." where by "most recently committed revision" I understand "tip". If you have multiple heads in the repository (such as multiple branches), then it is impractical to control what tip happens to be. In my experiments using Hg 1.4.2, the behavior is not even this; after adding a tag on one branch, and setting it (-f) to something else on another branch, the second definition is always used - even if the working copy is updated to the first branch, .hgtags has been more recently edited & committed on the first branch, and .hg/tags.cache has been deleted.
          Jesse Glick made changes -
          Link New: This issue is duplicated by JENKINS-7361 [ JENKINS-7361 ]
          Jesse Glick made changes -
          Link New: This issue is duplicated by JENKINS-7600 [ JENKINS-7600 ]
          Jesse Glick made changes -
          Link New: This issue is duplicated by JENKINS-7860 [ JENKINS-7860 ]

          toddh added a comment -

          This just started biting us as well and I wanted to add our use case in hope of getting a fix.

          We setup two projects in Hudson, development and release. Our development project polls the Mercurial repo and builds from tip. This project works fine as-is since no tags are involved. However, our release project is parameterized to build the tagged version.

          For some time now we've worked around the problem by including the variable in the repository URL like this:

          https://myrepo.com/mercurial/mysite/#${BUILD_LABEL}

          The problem with this approach is the Mercurial plug-in sees each build as a unique URL and does a full clone. That changes every file timestamp every time a build is performed. For our sites it's preferable to see different timestamps depending on when files were updated.

          I can get closer to the desired behavior by putting the parameter in the branch field but then I get the problem above. The best I've been able to do is pass a revision hash to the parameter in place of the tag associated with it. But that process is more error prone than communicating tag names.

          Hope all that makes sense. Thanks for your work on this plugin!

          toddh added a comment - This just started biting us as well and I wanted to add our use case in hope of getting a fix. We setup two projects in Hudson, development and release. Our development project polls the Mercurial repo and builds from tip. This project works fine as-is since no tags are involved. However, our release project is parameterized to build the tagged version. For some time now we've worked around the problem by including the variable in the repository URL like this: https://myrepo.com/mercurial/mysite/#$ {BUILD_LABEL} The problem with this approach is the Mercurial plug-in sees each build as a unique URL and does a full clone. That changes every file timestamp every time a build is performed. For our sites it's preferable to see different timestamps depending on when files were updated. I can get closer to the desired behavior by putting the parameter in the branch field but then I get the problem above. The best I've been able to do is pass a revision hash to the parameter in place of the tag associated with it. But that process is more error prone than communicating tag names. Hope all that makes sense. Thanks for your work on this plugin!

            jglick Jesse Glick
            cdevienne cdevienne
            Votes:
            15 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated:
              Resolved: