@@ -499,8 +499,10 @@ void testBuildTagListOneMore() throws Exception {
499
499
// Branch the repo and add one changeset.
500
500
runHgCommand (repositoryRoot , "unbundle" ,
501
501
Paths .get (getClass ().getResource ("/history/hg-branch.bundle" ).toURI ()).toString ());
502
+
502
503
// Switch to the branch and add tag.
503
- runHgCommand (repositoryRoot , "update" , "mybranch" );
504
+ final String myBranch = "mybranch" ;
505
+ runHgCommand (repositoryRoot , "update" , myBranch );
504
506
final String branchTagName = "branch_tag" ;
505
507
runHgCommand (repositoryRoot , "tag" , branchTagName );
506
508
@@ -509,7 +511,8 @@ void testBuildTagListOneMore() throws Exception {
509
511
510
512
MercurialRepository hgRepo = (MercurialRepository ) RepositoryFactory .getRepository (repositoryRoot );
511
513
assertNotNull (hgRepo );
512
- // Using double space on purpose to test the parsing of tags.
514
+
515
+ // Add tag. Using double space on purpose to test the parsing of tags.
513
516
final String newTagName = "foo bar" ;
514
517
runHgCommand (repositoryRoot , "tag" , newTagName );
515
518
hgRepo .buildTagList (new File (hgRepo .getDirectoryName ()), CommandTimeoutType .INDEXER );
@@ -522,6 +525,23 @@ void testBuildTagListOneMore() throws Exception {
522
525
assertEquals (List .of (7 , 9 ), tags .stream ().map (TagEntry ::getRevision ).collect (Collectors .toList ()));
523
526
List <String > expectedTags = List .of ("start_of_novel" , newTagName );
524
527
assertEquals (expectedTags , tags .stream ().map (TagEntry ::getTags ).collect (Collectors .toList ()));
528
+
529
+ // Add another tag to the default branch.
530
+ runHgCommand (repositoryRoot , "tag" , "another_tag" );
531
+
532
+ // Switch back to the non-default branch, check tags.
533
+ runHgCommand (repositoryRoot , "update" , myBranch );
534
+ // The repository object has to be recreated to reflect the branch switch.
535
+ hgRepo = (MercurialRepository ) RepositoryFactory .getRepository (repositoryRoot );
536
+ assertNotNull (hgRepo );
537
+ hgRepo .buildTagList (new File (hgRepo .getDirectoryName ()), CommandTimeoutType .INDEXER );
538
+ tags = hgRepo .getTagList ();
539
+ assertNotNull (tags );
540
+ assertEquals (3 , tags .size ());
541
+ expectedTags = List .of ("start_of_novel" , newTagName , branchTagName );
542
+ assertEquals (expectedTags , tags .stream ().map (TagEntry ::getTags ).collect (Collectors .toList ()));
543
+
544
+ // cleanup
525
545
IOUtils .removeRecursive (repositoryRootPath );
526
546
}
527
547
}
0 commit comments