Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git Tfs unshelve returns the error "A shelved pending change on a file is required: path\to\file" #419

Open
vitalybe opened this issue Aug 8, 2013 · 11 comments · Fixed by #636

Comments

@vitalybe
Copy link

vitalybe commented Aug 8, 2013

In my case it happens when a folder is deleted in a shelve.

It seems that the error comes from TFS and there isn't much Git TFS can do about it. However, I thought to add a "--ignore-errors" flag that will basically try-catch-log specific unshelve errors, show them in the output, but won't cancel the unshelve process.

What are your thoughts on this?

@sc68cal
Copy link
Contributor

sc68cal commented Aug 8, 2013

Make it --force, and you've got my vote.

@spraints
Copy link
Member

Or --not-strict.

@Kazark
Copy link

Kazark commented Jun 27, 2014

@vitalybe What's the status of this? I'm experiencing the same problem.

@vitalybe
Copy link
Author

@Kazark I made a fix in the code to make it happen, but never matured it enough for a PR... I am not really sure I have that code now. So my best suggestion to you would be to run "git tfs" via Visual Studio and add that exception handling ad-hoc.

If you can a PR that'd be even better :)

@spraints
Copy link
Member

I started a PR in #636. I'm not sure if I added error handling to the right place. @vitalybe or @Kazark - if you still have a repro case around, can you try it out and see if it helps?

@vitalybe
Copy link
Author

I don't have it anymore, sorry

@Kazark
Copy link

Kazark commented Aug 4, 2014

@spraints I should have left myself a better paper trail on this. It has been long enough with enough life events in between that even though I am sure there are still shelfsets out there that would do it for me I don't know which ones they are. :( 😦 If I get a chance I could look around...

@idealist1508
Copy link

@spraints Today I run in this issue. I try this fix, but it didn't help. Here is a log

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: A shelved pending change on a file is required: $/SAGE.DE.SEOS/Provisioning/Dev/Provisioning.Services/MnSResource
   at Microsoft.TeamFoundation.VersionControl.Client.PendingChange.DownloadShelvedFile(String localFileName)
   at Sep.Git.Tfs.VsCommon.TfsHelperBase.UnshelveItem.Get(ITfsWorkspace workspace)
   at Sep.Git.Tfs.VsCommon.TfsHelperBase.Unshelveable.Get(ITfsWorkspace workspace, IEnumerable`1 changes)
   at Sep.Git.Tfs.Core.TfsChangeset.Apply(String lastCommit, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary`2 initialTree, Action`1 ignorableErrorHandler) in z:\github\sp\git-tfs\GitTfs\Core\TfsChangeset.cs:line 35
   at Sep.Git.Tfs.Core.GitTfsRemote.<>c__DisplayClass1e.<Apply>b__1d(ITfsWorkspace workspace) in z:\github\sp\git-tfs\GitTfs\Core\GitTfsRemote.cs:line 670
   at Sep.Git.Tfs.VsCommon.TfsHelperBase.WithWorkspace(String localDirectory, IGitTfsRemote remote, TfsChangesetInfo versionToFetch, Action`1 action)
   at Sep.Git.Tfs.Core.GitTfsRemote.WithWorkspace(TfsChangesetInfo parentChangeset, Action`1 action) in z:\github\sp\git-tfs\GitTfs\Core\GitTfsRemote.cs:line 787
   at Sep.Git.Tfs.Core.GitTfsRemote.Apply(String parent, ITfsChangeset changeset, IDictionary`2 entries, Action`1 ignorableErrorHandler) in z:\github\sp\git-tfs\GitTfs\Core\GitTfsRemote.cs:line 667
   at Sep.Git.Tfs.Core.GitTfsRemote.Apply(String parent, ITfsChangeset changeset, Action`1 ignorableErrorHandler) in z:\github\sp\git-tfs\GitTfs\Core\GitTfsRemote.cs:line 661
   at Sep.Git.Tfs.Core.GitTfsRemote.Unshelve(String shelvesetOwner, String shelvesetName, String destinationBranch, Action`1 ignorableErrorHandler) in z:\github\sp\git-tfs\GitTfs\Core\GitTfsRemote.cs:line 718
   at Sep.Git.Tfs.Commands.Unshelve.Run(String shelvesetName, String destinationBranch) in z:\github\sp\git-tfs\GitTfs\Commands\Unshelve.cs:line 52
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Sep.Git.Tfs.Util.GitTfsCommandRunner.Run(GitTfsCommand command, IList`1 args) in z:\github\sp\git-tfs\GitTfs\Util\GitTfsCommandRunner.cs:line 38
   at Sep.Git.Tfs.GitTfs.Main(GitTfsCommand command, IList`1 unparsedArgs) in z:\github\sp\git-tfs\GitTfs\GitTfs.cs:line 69
   at Sep.Git.Tfs.GitTfs.Run(IList`1 args) in z:\github\sp\git-tfs\GitTfs\GitTfs.cs:line 50
   at Sep.Git.Tfs.Program.MainCore(String[] args) in z:\github\sp\git-tfs\GitTfs\Program.cs:line 34
   at Sep.Git.Tfs.Program.Main(String[] args) in z:\github\sp\git-tfs\GitTfs\Program.cs:line 22
A shelved pending change on a file is required: $/S

I change https://github.com/spraints/git-tfs/blob/ignore-unshelve-errors/GitTfs/Core/TfsChangeset.cs#L35 to:

ignorableErrorHandler.Catch(() => _changeset.Get(workspace, sieve.GetChangesToFetch()));

this seems to help. But I'm not sure if it correct, so here is a log:

Command run:git tfs unshelve --force -d -u all MnSApplicationService MnSApplicationService
No authors file used.
git-tfs version 0.20.0.0 (TFS client library 11.0.0.0 (MS)) (64-bit)
Commits visited count:1
Working with tfs remote: default
Looking for changeset 192 in git repository...
 => Commit found! hash: 2127b4969fa605e3f0b85c7fd56fe9a2c508734f
Setting up a TFS workspace at .git\~w
ERROR: unshelve: System.InvalidOperationException: A shelved pending change on a file is required: $/SAGE.DE.SEOS/Provisioning/Dev/Provisioning.Services/MnSResource
   at Microsoft.TeamFoundation.VersionControl.Client.PendingChange.DownloadShelvedFile(String localFileName)
   at Sep.Git.Tfs.VsCommon.TfsHelperBase.UnshelveItem.Get(ITfsWorkspace workspace)
   at Sep.Git.Tfs.VsCommon.TfsHelperBase.Unshelveable.Get(ITfsWorkspace workspace, IEnumerable`1 changes)
   at Sep.Git.Tfs.Core.TfsChangeset.<>c__DisplayClass4.<Apply>b__2() in z:\github\sp\git-tfs\GitTfs\Core\TfsChangeset.cs:line 35
   at Sep.Git.Tfs.Core.Ext.Catch[TException](Action`1 handler, Action work) in z:\github\sp\git-tfs\GitTfs\Core\Ext.cs:line 163
        D       Provisioning.Server.Host/Configuration/AppConfigConfiguration.cs
        D       Provisioning.Services/AzureResources/IAzureResourcesManagementServices.cs
        D       Provisioning.Services/AzureResources/AzureResourcesManagementService.cs
Cannot checkout file 'Provisioning.Services/Provisioning.Services.csproj' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/JobsTerminal/IJobsTerminalService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/JobsTerminal/JobsTerminalService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/MnSApplication/IMnSApplicationService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/MnSApplication/MnSApplicationService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/MnSManagement/IMnSManagementService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/MnSManagement/MnSManagementService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/MnSResource/IMnSResourceService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/MnSResource/MnSResourceService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/Sites/ISitesManagementService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/Sites/ProductPartListDTO.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/Sites/SitesManagementService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/SitesTerminal/ISitesTerminalService.cs' from TFS. Skip it
Cannot checkout file 'Provisioning.Services/SitesTerminal/SitesTerminalService.cs' from TFS. Skip it
Cannot checkout file 'Seedwork/Seedwork.csproj' from TFS. Skip it
Cannot checkout file 'Seedwork/Configuration/ConfigurationBase.cs' from TFS. Skip it
Cannot checkout file 'Seedwork/Configuration/IConfigurationProvider.cs' from TFS. Skip it
Cannot checkout file 'Seedwork/Logger/ILogger.cs' from TFS. Skip it
Cannot checkout file 'Seedwork/RequestBuilder/IRequestBuilder.cs' from TFS. Skip it
Cannot checkout file 'Seedwork/RequestBuilder/RestRequestBuilder.cs' from TFS. Skip it
Cannot checkout file 'Tests/HostedServiceResourceNotifierTests.cs' from TFS. Skip it
Cannot checkout file 'Tests/SeosDatabaseManagementTest.cs' from TFS. Skip it
Cannot checkout file 'Tests/SqlAzureResourceNotifierTests.cs' from TFS. Skip it
Cannot checkout file 'Tests/VirtualMachineResourceNotifierTests.cs' from TFS. Skip it
Cannot checkout file 'Tests/Integration/ProvisionerServiceTests.cs' from TFS. Skip it
Cannot checkout file 'Tests/Mocks/Services/MockBuilder.cs' from TFS. Skip it
Created branch MnSApplicationService from shelveset "MnSApplicationService".

@spraints
Copy link
Member

@idealist1508 - That'll cancel the Get at the first error, which is probably why you've got all those "Skip it" messages. I think spraints@ba5add0 will target the error better, and make the unshelve operation work better. Can you give it a try?

@idealist1508
Copy link

Thanks, It works.

@timabell
Copy link
Contributor

@spraints can we re-open this, as although you can now get the rest of the shelveset I'm losing the deletion of a folder when retrieving a shelved change.

Current trace:

WARNING: unshelve: A shelved pending change on a file is required: $/some/folder/deleted/in/tfs/shelveset
System.InvalidOperationException: A shelved pending change on a file is required: $/some/folder/deleted/in/tfs/shelveset
   at Microsoft.TeamFoundation.VersionControl.Client.PendingChange.DownloadShelvedFile(String localFileName)
   at Sep.Git.Tfs.VsCommon.TfsHelperBase.UnshelveItem.Get(ITfsWorkspace workspace)
   at Sep.Git.Tfs.VsCommon.TfsHelperBase.Unshelveable.<>c__DisplayClass18_0.<Get>b__0()
   at Sep.Git.Tfs.Core.Ext.Catch[TException](Action`1 handler, Action work) in C:\repo\git-tfs\GitTfs\Core\Ext.cs:line 152

@spraints spraints reopened this Apr 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants