3

I am running an automated hg merge under CruiseControl.NET as part of an MSBuild job. For some reason the merge runs in non-interactive mode even though I have not specified -y in the command. This is causing unexpected results since it takes the first option when prompted about a conflict, I'd rather it just times out and fails so we know we need to look at it manually.

So two questons:

1) Why is it running non-iteractively when I haven't given it a -y?
2) Is there a way to force the hg merge to be interactive so the job will timeout and fail?

Himanshu
  • 31,810
  • 31
  • 111
  • 133
DucatiScotty
  • 31
  • 1
  • 2
  • I'm betting it's detecting that it has no console attached and does the sane thing - ignores interactive mode. – skolima Jul 27 '12 at 08:14
  • I think so too but I don't know how or why it's detecting it's running headless or what I can do to override that. – DucatiScotty Jul 27 '12 at 17:39
  • I was able to confirm that running hg inside MSBuild makes it run in non-interactive mode. I was also able to get it to run in interactive by forcing it to run in a separate command window within MSBuild like this: "start cmd /k " &quote; ". However, this would hang and fail, then leave the repo in a messy, unresolved state which would throw other builds off the rails. Though I got what I wanted it was not what I needed. I'm going to try to sort this out by doing this in PoweShell rather than MSBuild. Thanks for all your help everyone. – DucatiScotty Jul 30 '12 at 18:38

2 Answers2

4

Based on this answer on another question, it looks like Mercurial auto-detects if it is running under a TTY or is headless, thus doesn't prompt you. You could override this by supplying the ui.interactive config option:

hg --config ui.interactive=yes
Community
  • 1
  • 1
Aaron Jensen
  • 25,861
  • 15
  • 82
  • 91
3

I think better idea is to use hg merge --tool internal:merge. Mercurial will try to make automatic merge but will fail if there are any conflicts. There are other options possible here.

I am using it daily after automatic pull from external ClearCase repository and it works great. If there are any conflicts than my CI job just fails imediatelly.

Michal Sznajder
  • 9,338
  • 4
  • 44
  • 62
  • Thanks, I'll try that but I don't know if it will override the non-interactive behavior I'm trying to stop. – DucatiScotty Jul 27 '12 at 17:40
  • 1
    It didn't, still runs non-interactive :( I tried a few other options from you link, also with no luck. Part of the problem may be that I'm running into manifest merges, not just file merges. For examply, where a file is modified in source but deleted in destination. These are treated differently and I think trip a prompt before even the basic internal merge attempt happens. – DucatiScotty Jul 27 '12 at 21:44
  • Mercurial v 2.1.1 installed as part of TortoiseHg 2.3.1 (x64), CCnet v 1.6.7981.1, MSBuild Microsoft (R) Build Engine Version 4.0.30319.1. – DucatiScotty Jul 30 '12 at 17:27