Today we would say “the whole works,” and mean the same thing as “lock, stock, and barrel”.
The expression is of American origin and, though the earliest literary record appears to be in one of T. C. Haliburton’s “Sam Slick” stories, it probably goes back at least to the American Revolution.
The three items of which the expression is comprised are the three essential components of a gun, the barrel, the stock, and the lock, or firing mechanism.
In other words, the entire gun; the whole thing; the entirety.