Mercurial patch building is broken? "Failed to build patch for build"

I recently removed some files from source control (via the mercurial delete), and now the patches aren't being built correctly and are causing my builds to fail. See this message:

[Updating sources: server side checkout...] Failed to build patch for build #17 {build id=92}, VCS root: mercurial: https://ynab.kilnhg.com/Repo/Repositories/YNABDesktop/YNABAIR {id=7}, due to error: '"C:\Program Files\TortoiseHg\hg.exe" cat -o C:\TeamCity\temp\mercurial7520992316082275493catresult\%p -r 30c08ac2698e TypedCollectionGenerator\TypedCollectionGenerator.sln TypedCollectionGenerator\TypedCollectionGenerator\Program.cs TypedCollectionGenerator\TypedCollectionGenerator\Properties\AssemblyInfo.cs TypedCollectionGenerator\TypedCollectionGenerator\TypedCollectionGenerator.csproj TypedCollectionGenerator\TypedCollectionGenerator\bin\Debug\TypedCollectionGenerator.exe TypedCollectionGenerator\TypedCollectionGenerator\bin\Debug\TypedCollectionGenerator.pdb TypedCollectionGenerator\TypedCollectionGenerator\bin\Debug\TypedCollectionGenerator.vshost.exe TypedCollectionGenerator\TypedCollectionGenerator\bin\Debug\TypedCollectionGenerator.vshost.exe.manifest YNABLibrary\libs\asx3m_0.91.swc YNABParser\build\build.Current.properties YNABParser\build\build.MelroseCurrent.properties YNABParser\src\TabTest.mxml' command failed. stderr: TypedCollectionGenerator\TypedCollectionGenerator.sln: no such file in rev 30c08ac2698e TypedCollectionGenerator\TypedCollectionGenerator\Program.cs: no such file in rev 30c08ac2698e TypedCollectionGenerator\TypedCollectionGenerator\Properties\AssemblyInfo.cs: no such file in rev 30c08ac2698e TypedCollectionGenerator\TypedCollectionGenerator\TypedCollectionGenerator.csproj: no such file in rev 30c08ac2698e TypedCollectionGenerator\TypedCollectionGenerator\bin\Debug\TypedCollectionGenerator.exe: no such file in rev 30c08ac2698e TypedCollectionGenerator\TypedCollectionGenerator\bin\Debug\TypedCollectionGenerator.pdb: no such file in rev 30c08ac2698e TypedCollectionGenerator\TypedCollectionGenerator\bin\Debug\TypedCollectionGenerator.vshost.exe: no such file in rev 30c08ac2698e TypedCollectionGenerator\TypedCollectionGenerator\bin\Debug\TypedCollectionGenerator.vshost.exe.manifest: no such file in rev 30c08ac2698e YNABLibrary\libs\asx3m_0.91.swc: no such file in rev 30c08ac2698e YNABParser\build\build.Current.properties: no such file in rev 30c08ac2698e YNABParser\build\build.MelroseCurrent.properties: no such file in rev 30c08ac2698e YNABParser\src\TabTest.mxml: no such file in rev 30c08ac2698e

Which folder on the build machine do I need to delete to get it to forget about the TypedCollectionGenerator files that it is insistent upon trying to include in the patch somehow?

Many thanks for any help you can offer!

10 comments
Comment actions Permalink

Hello Taylor,
what version of Teamcity do you use?

0
Comment actions Permalink

Taylor, I checked our code - we do not try to build diff for deleted files. In our hg support we rely on default format of hg messages, have you customized them?

0
Comment actions Permalink

I am also experiencing this issue, using 6.0.2. However, I don't see the issue when the build is triggered by the VCS trigger, only when I try to run the build manually.

The stack trace I see whenever I try to manually start a build is as follows:

jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl$1: Server was not able to build correct patch, most likely due to VCS errors, will try again. at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.throwError(PatchDownloaderImpl.java:113)
at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.checkPatch(PatchDownloaderImpl.java:103)
at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.copyPatchAndCheck(PatchDownloaderImpl.java:64)
at jetbrains.buildServer.agent.impl.patch.UpdateSourcesPatcherBase.copyPatchToTempFile(UpdateSourcesPatcherBase.java:70)
at jetbrains.buildServer.agent.impl.patch.UpdateSourcesFromServer.updateSources(UpdateSourcesFromServer.java:62)
at jetbrains.buildServer.agent.impl.patch.UpdateSourcesBuildStageBase.doSourceUpdate(UpdateSourcesBuildStageBase.java:90)
at jetbrains.buildServer.agent.impl.patch.UpdateSourcesBuildStageBase.doRecoverableStage(UpdateSourcesBuildStageBase.java:58)
at jetbrains.buildServer.agent.impl.buildStages.startStages.RecoverableBuildStage.doLastAttempt(RecoverableBuildStage.java:112)
at jetbrains.buildServer.agent.impl.buildStages.startStages.RecoverableBuildStage.doBuildStage(RecoverableBuildStage.java:70)
at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor$1.callStage(BuildStagesExecutor.java:31)
at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor$1.callStage(BuildStagesExecutor.java:29)
at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.callRunStage(StagesExecutor.java:68)
at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.doStages(StagesExecutor.java:31)
at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor.doStages(BuildStagesExecutor.java:24)
at jetbrains.buildServer.agent.impl.BuildRunAction.doStages(BuildRunAction.java:65)
at jetbrains.buildServer.agent.impl.BuildRunAction.runBuild(BuildRunAction.java:48)
at jetbrains.buildServer.agent.impl.BuildAgentImpl.doActualBuild(BuildAgentImpl.java:250)
at jetbrains.buildServer.agent.impl.BuildAgentImpl.access$100(BuildAgentImpl.java:48)
at jetbrains.buildServer.agent.impl.BuildAgentImpl$1.run(BuildAgentImpl.java:223)
at java.lang.Thread.run(Unknown Source)

Caused by: jetbrains.buildServer.vcs.patches.UnsuccessfulPatchException: Failed to build patch for build #2.af885cd2ff24 {build id=162}, VCS root: mercurial: http://[url redacted] {id=3}, due to error: 'cmd /c hg cat -o C:\TeamCity\temp\mercurial144187046310189202catresult\%p -r af885cd2ff24 [filename redacted] [filename redacted] [filename redacted] [...] [filename redacted]' command failed.
stderr:
[filename redacted]: no such file in rev af885cd2ff24
[filename redacted]: no such file in rev af885cd2ff24
[filename redacted]: no such file in rev af885cd2ff24
[...]
[filename redacted]: no such file in rev af885cd2ff24
at jetbrains.buildServer.vcs.patches.AbstractPatcher$1.fail(AbstractPatcher.java:93)
at jetbrains.buildServer.vcs.patches.LowLevelPatcher.readPatchStream(LowLevelPatcher.java:156)
at jetbrains.buildServer.vcs.patches.LowLevelPatcher.applyPatch(LowLevelPatcher.java:79)
at jetbrains.buildServer.vcs.patches.AbstractPatcher.applyPatch(AbstractPatcher.java:42)
at jetbrains.buildServer.agent.impl.patch.PatchApplierImpl.applyPatch(PatchApplierImpl.java:18)
at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.checkPatchInFileIsCompleted(PatchDownloaderImpl.java:83)
at jetbrains.buildServer.agent.impl.patch.PatchDownloaderImpl.checkPatch(PatchDownloaderImpl.java:93)
... 18 more
0
Comment actions Permalink

Sorry guys, I still cannot reproduce it. I did several commits which remove/add/change files and TeamCity detects changes and build patches correctly. At the moment I can see only one reason for this error - hg output which TeamCity cannot parse.

Could you please run a following command at TeamCity server machine in one of repositories at <BuildServerHome>/system/caches/mercurial:

hg status --rev <from>:<to>

where interval of revisions <from>:<to> contains commits with file removal, and provide an output?

0
Comment actions Permalink

Hi Dmitry,

I looked back through the revision logs to find out where the files mentioned in the error logs were removed, and was surprised to find that firstly they were from different revisions and secondly that neither was the most recent revision when I attempted to build.

Here's the HG status output for the revision that removed the majority of affected files:

 C:\Users\Administrator\.BuildServer\system\caches\mercurial\hg_498477970932201378>hg status --rev 2463:2464
R company\page1.aspx
R company\page1.aspx.cs
R company\page2.aspx
R company\page2.aspx.cs
R company\page3.aspx
R company\page3.aspx.cs
R company\page4.aspx
R company\page4.aspx.cs
R company\page5.aspx
R company\page6.aspx
R company\page6.aspx.cs
R company\page7.aspx
R company\page7.aspx.cs
R company\page8.aspx
R company\page8.aspx.cs
R company\page9.aspx
R company\page9.aspx.cs
R company\page10.aspx
R company\page10.aspx.cs
R company\page11.aspx
R company\page11.aspx.cs
R company\page12.aspx
R company\page12.aspx.cs
R company\page13.aspx
R company\page13.aspx.cs
R company\page14.aspx
R company\page14.aspx.cs
R company\page15.aspx
R company\page15.aspx.cs


I'm having to munge what I paste here slightly so our marketing department can't claim I'm interfering with their SEO (amongst other reasons), but I assure you there's nothing unusual about the paths. Also, when I look up the corresponding revision in TeamCity's revision history, it clearly shows all of those files as being removed, which suggests to me that it isn't a parse issue - unless TeamCity reads from hg again when building the patches?

There are also files removed in more recent revisions that it isn't complaining about...
0
Comment actions Permalink

Oh, and just to reiterate, the changesets containing the removal of the files TC is now complaining about built perfectly happily when they were pushed to the repository TC is watching and the VCS trigger caused the build - it's only when I run the builds manually that I see this issue.

0
Comment actions Permalink

Andy, could you please enable 'debug-vcs' logging preset at 'Administration > Server Configuration > Diagnostics' tab and reproduce the issue. After that teamcity-vcs.log in TeamCityHome/logs dir should contain all hg commands teamcity run and their output. Could you please provide this output? Real file/revision names do not matter unless they are unusual in some respect.

0
Comment actions Permalink

Hi Dmitry,

Unfortunately, at about 13,000 lines it's a bit long for me to censor :) Is there any way I could email it to you?

0
Comment actions Permalink

Yes, send it to teamcity-feedback@jetbrains.com with a link to this thread.

0
Comment actions Permalink

Dmitry spotted that the repository working directory had been populated with the problematic files, as I'd run an hg update there manually in an attempt to diagnose an unrelated issue. Cleaning the repository out completely and starting afresh (remove all files, hg init followed by hg pull) has resolved the problem. Thanks Dmitry :)

0

Please sign in to leave a comment.