Mercurial > hg > mercurial
changeset 605:0e21f908b10d
TW-28776 create a tag in branch to which the labeled revision belongs
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Fri, 07 Jun 2013 19:05:23 +0400 |
parents | 3eb02fd5fd78 |
children | c21027a957d2 1650e9a237b9 |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommand.java mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java |
diffstat | 3 files changed, 33 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommand.java Thu Jun 06 20:59:54 2013 +0400 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/IdentifyCommand.java Fri Jun 07 19:05:23 2013 +0400 @@ -32,6 +32,7 @@ private AuthSettings myAuthSettings; private String myRepositoryUrl; private String myNamedRevision; + private boolean myShowBranch = false; public IdentifyCommand(@NotNull CommandSettings commandSettings, @NotNull String hgPath, @@ -75,6 +76,11 @@ return this; } + public IdentifyCommand showBranch() { + myShowBranch = true; + return this; + } + public String call() throws VcsException { MercurialCommandLine cli = createCL(); cli.addParameter("identify"); @@ -83,6 +89,9 @@ } else { cli.addParameter(myAuthSettings.getRepositoryUrlWithCredentials(myRepositoryUrl)); } + if (myShowBranch) { + cli.addParameter("-b"); + } if (myChangeSet != null) { cli.addParameter("--rev"); cli.addParameter(myChangeSet.getId()); @@ -95,6 +104,10 @@ } CommandResult res = runCommand(cli, myCommandSettings.setFailWhenStderrNotEmpty(true)); String output = res.getStdout().trim(); - return output.contains(" ") ? output.substring(0, output.indexOf(" ")) : output; + if (myShowBranch) { + return output; + } else { + return output.contains(" ") ? output.substring(0, output.indexOf(" ")) : output; + } } }
--- a/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Thu Jun 06 20:59:54 2013 +0400 +++ b/mercurial-server/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupport.java Fri Jun 07 19:05:23 2013 +0400 @@ -537,7 +537,8 @@ hgRoot.setCustomWorkingDir(tmpDir); syncRepository(hgRoot); HgRepo repo = createRepo(hgRoot); - repo.update().branch(hgRoot.getBranchName()).call(); + String branchName = getCommitBranch(repo, version); + repo.update().branch(branchName).call(); String fixedTagname = fixTagName(label); repo.tag().revision(version) @@ -552,6 +553,11 @@ } } + @NotNull + private String getCommitBranch(@NotNull HgRepo repo, @NotNull String cset) throws VcsException { + return repo.id().inLocalRepository().revision(cset).showBranch().call(); + } + private String fixTagName(final String label) { // according to Mercurial documentation http://hgbook.red-bean.com/hgbookch8.html#x12-1570008 // tag name must not contain:
--- a/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java Thu Jun 06 20:59:54 2013 +0400 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java Fri Jun 07 19:05:23 2013 +0400 @@ -270,6 +270,18 @@ } + public void tag_should_be_created_in_branch_to_which_tagged_revision_belongs() throws Exception { + File remoteRepo = copyRepository(myTempFiles, myRep2Path); + VcsRoot root = vcsRoot().withUrl(remoteRepo.getCanonicalPath()).withBranch("default").build(); + RepositoryStateData beforeLabelState = myVcs.getCollectChangesPolicy().getCurrentState(root); + String topicCurrentVersion = beforeLabelState.getBranchRevisions().get("topic"); + myVcs.label("label_in_branch", topicCurrentVersion, root, CheckoutRules.DEFAULT); + RepositoryStateData afterLabelState = myVcs.getCollectChangesPolicy().getCurrentState(root); + assertEquals(beforeLabelState.getBranchRevisions().get("default"), afterLabelState.getBranchRevisions().get("default")); + assertNotEquals(beforeLabelState.getBranchRevisions().get("topic"), afterLabelState.getBranchRevisions().get("topic"));//topic changed => tag was created there + } + + @TestFor(issues = "TW-10076") public void should_allow_to_ignore_changes_where_all_files_excluded() throws Exception { VcsRootImpl root = createVcsRoot(myRep2Path);