This depends to a degree on your interpretation of "same meaning". Two different sentences will almost invariably have slightly different implications. Even substituting a synonym or alternate spelling can alter the meaning read into a sentence, if not the meaning written into it. "I like the colour red" is not the same as "I like the color red". One might read "I'm British and I like red", while the other might read "I'm American and I like red". That said, it's probably safe to assume most people will interpret "same meaning" as either "same intent" or "similar enough meaning".
Contrary to the other answers, I don't feel that there would necessarily be a contradiction - the more natural reading would be to assume ellipsis.
First, let's look at the original sentence and try to understand it by imagining what the thoughts might have been. Let's imagine that Will thought "apple", but thought that he thought "potato". Let's also mark the verb "thought" with "[v]":
Just thought[v] a thought[apple] but the thought[apple] I thought[v] wasn't the thought[potato] I thought[v] I thought[v].
Clear enough. Now let's write the sentence again, minus the final "I thought":
Just thought[v] a thought[apple] but the thought[apple] I thought[v] wasn't the thought[potato] I thought[v].
This sounds clumsy, and to some it will sound like a paradox: "[the thought I thought] wasn't [the thought I thought]". However, the sentence is not as paradoxical as you might think
it is. Most people will read an implicit word or phrase beyond what has actually been written. This is ellipsis.
Interpreting the shortened sentence in this way is a little ambiguous. We can either recover the original sentence exactly or perhaps more naturally:
Just thought a thought but the thought I thought wasn't the thought I thought it was.
Whether you think this has the same meaning as the original sentence is up to you. Both sentences describe a situation in which Will thought "apple", but imagined that he had thought "potato".