Skip to content

Commit 4efb0fd

Browse files
authored
always update to the correct head of Mercurial repositories (#4600)
use the head on given branch with maximum index
1 parent efcec9e commit 4efb0fd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tools/src/main/python/opengrok_tools/scm/mercurial.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

2020
#
21-
# Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
21+
# Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
2222
# Portions Copyright (c) 2020, Krystof Tulinger <k.tulinger@seznam.cz>
2323
#
2424

@@ -78,10 +78,20 @@ def reposync(self):
7878
return 1
7979

8080
hg_command = [self.command, "update"]
81+
#
8182
# Avoid remote branch lookup for default branches since
8283
# some servers do not support it.
84+
#
8385
if branch == "default":
8486
hg_command.append("--check")
87+
88+
#
89+
# In a multi-head situation, select the head with the
90+
# biggest index as this is likely the correct one.
91+
#
92+
hg_command.append("-r")
93+
hg_command.append("'max(head() and branch(\".\"))'")
94+
8595
cmd = self.get_command(hg_command, work_dir=self.path,
8696
env_vars=self.env, logger=self.logger)
8797
cmd.execute()

0 commit comments

Comments
 (0)