Skip to content

Commit e2c60e9

Browse files
committed
avoid _run_command()
1 parent aecd87d commit e2c60e9

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def reposync(self):
9090
# biggest index as this is likely the correct one.
9191
#
9292
hg_command.append("-r")
93-
hg_command.append("max(head() and branch(\".\"))")
93+
hg_command.append('max(head() and branch("."))')
9494

9595
cmd = self.get_command(
9696
hg_command, work_dir=self.path, env_vars=self.env, logger=self.logger
@@ -139,9 +139,17 @@ def strip_outgoing(self):
139139
Check for outgoing changes and if found, strip them.
140140
:return: True if there were any changes stripped, False otherwise.
141141
"""
142-
status, out = self._run_command(
143-
[self.command, "out", "-q", "-b", ".", "--template={rev}\\n"]
142+
# Avoid _run_command() as it complains to the log about failed command
143+
# when 'hg out' returns 1 which is legitimate return value.
144+
cmd = self.get_command(
145+
[self.command, "out", "-q", "-b", ".", "--template={rev}\\n"],
146+
work_dir=self.path,
147+
env_vars=self.env,
148+
logger=self.logger,
144149
)
150+
cmd.execute()
151+
status = cmd.getretcode()
152+
145153
#
146154
# If there are outgoing changes, 'hg out' returns 0, otherwise returns 1.
147155
# If the 'hg out' command fails for some reason, it will return 255.
@@ -150,7 +158,7 @@ def strip_outgoing(self):
150158
if status > 0:
151159
return False
152160

153-
revisions = list(filter(None, out.split("\n")))
161+
revisions = list(filter(None, cmd.getoutputstr().split("\n")))
154162
if len(revisions) == 0:
155163
return False
156164

0 commit comments

Comments
 (0)