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
Fix missing merge parent #628
Conversation
Awesome!
|
Philippe, |
@@ -133,6 +133,7 @@ public virtual int FindMergeChangesetParent(string path, long targetChangeset, G | |||
{ | |||
var targetVersion = new ChangesetVersionSpec((int)targetChangeset); | |||
var mergeInfo = VersionControl.QueryMerges(null, null, path, targetVersion, targetVersion, targetVersion, RecursionType.Full); | |||
if (mergeInfo.Length == 0) return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
technically you should just return targetChangeset. the subsequent FindCommitByChangesetId will not find any and fall through accordingly. the real fix is avoiding the empty mergeInfo.Max(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I wasn’t sure how things worked and what should be returned, but returning an error indication and then testing for it seemed like a sure cure. But I like your method better.
just built from master and this fix is still necessary to clone my repo. I think it could be reproduced by creating a changeset with a single file in it and then using tf destroy to erase that file. |
@gfody do you have a version of this fix that will work with current master? |
@pmiossec I've tried your patch and unfortunately I still get the "Sequence contains no elements" error at line 273 of Rcheckin.cs |
@voltagex "Sequence contains no elements" error is a "generic" error that could occurs at different places. The one you've got is in no mean related to this issue! I think I have fixed it with #671. Could you try it? PS: But I think that if you encounter this crash, you are doing something at best a "strange" thing, but at least a wrong one :( I would like to warn you before go ahead... You are trying to |
I think I will have to open a new issue. What I'm doing works with git-tf Check out old project from TFS server one -> check out new project from TFS |
Git-tfs and git-tf are not working the same way, so it's possible that the You are right, open a new issue and explain the more possible what you want |
If someone is here because he want to test this fix, see #678 where the commit has been rebased (because this pull request seems not maintained :( ) |
Similiar fix #678 merged in master. |
This pull request fixes issue #627 (and also #590,of which it is a duplicate).
In some cases (probably involving a badly formed TFS changeset, or a merge changeset in which the merge parent has been deleted), the VersionControl.QueryMerges call in FindMergeChangesetParent can return an empty array. In such cases, the subsequent merginfo.Max(x => x.SourceVersion) call will throw a "Sequence contains no objects" InvalidOperationException.
This patch avoids that error by checking for a zero-length array, and returning -1 to the caller, which then checks for that and handles it with a warning message that git-tfs can't locate the parent.