Thanks to both Giok and Jim for more specifics on Tannahill's song. Both are correct. In a different thread Jim pointed out that there are two slightly different texts of this song ascribed to Tannahill.
The song did enter oral tradition after Tannahill wrote it, to be collected by various people including Grieg and Duncan. I'm not sure how Francie McPeake got hold of it--his family was mostly interested in stressing the originality of "Wild Mountain Thyme," and didn't discuss his source much.