The phrase lock, stock and barrel means completely, entirely.
It is based on the three principal components that make up a flintlock gun: lock denotes the firing mechanism, stock the handle or wooden shoulder-piece to which it is attached, and barrel the tube down which the bullet is fired.
It is curious that the use of lock, stock and barrel in collocation is first recorded in the early 19th century only, although firearms of this type had been in use for several centuries.
It is often said that this collocation first appeared in figurative contexts, but this is not true. On 24th September 1810, The Washingtonian (Windsor, Vermont) published the fifth chapter of Book 5 of A History of New York from the Beginning of the World to the End of the Dutch Dynasty, by Diedrich Knickerbocker, by the American author Washington Irving (1783-1859), which contains this paragraph:
As, however, the present emergency was pressing, he [= Peter Stuyvesant] was obliged to avail himself of such means of defence as were next at hand, and accordingly appointed a general inspection and parade of the train bands. But oh! Mars and Bellona, and all ye other powers of war, both great and small, what a turning out was here!—Here came men without officers, and officers without men—long fowling pieces and short blunderbusses—muskets of all sorts and sizes, some without bayonets, others without locks, others without stocks, and many without lock, stock, or barrel.
It is always said that the phrase itself, which first appeared as stock, lock and barrel, was first used by the Scottish poet and novelist Walter Scott (1771-1832) in a letter that he wrote on 29th October 1817—because it is the earliest instance recorded in the Oxford English Dictionary (3rd edition, 2015). But I have found an earlier instance in the New York Evening Post (New York, N.Y.) of 18th February 1811—the fact that the phrase is in quotation marks seems to indicate that it was regarded as slang:
Facts—stubborn facts—The whole tonnage of the United States, according to Mr. Gallatin’s last report, amounted to 1,350,281 tons and 41 ninety-fifths, of which rather more than one third or 463,044 tons and 83 ninety-fifths, belong to the state of Massachusetts.
The whole of the southern states, including the city of Baltimore, own 344,336 tons and 15 ninety-fifths. So that the tonnage of the state of Massachusetts alone, exceeds that of the whole of the southern states put together, “stock, lock and barrel,” 118,708, tons and 68 ninety-fifths.
About the phrase as it appeared in the letter written by Walter Scott on 29th October 1817, the persons who quote it do not contextualise it, so that it is incomprehensible; writing to the English actor and playwright Daniel Terry (circa 1780-1829) from—and about—Abbotsford, the new house that he was building near Melrose, in the Scottish Borders, Scott specified that he did not plan to keep the original farmhouse, which he called Mrs. Redford:
I do not believe I should save £100 by retaining Mrs. Redford, by the time she was raised, altered, and beautified, for, like the Highlandman’s gun, she wants stock, lock, and barrel, to put her into repair.
from Memoirs of the life of Sir Walter Scott, Bart., by J. G. Lockhart (New York, 1837)
I seem to be the first to notice that, in fact, Walter Scott was himself quoting a Scottish phrase; earlier, on 1st March 1817, The Morning Post (London) had published an allegorical poem titled The Highlandman’s Pistol, A Fable: For the Present Time, February 1817, by a certain William Jerdan; this poem begins with the following epigraph:
“It wants a new stock, a new lock, and a new barrel, like the Highlandman’s Pistol.”—Old Scottish Saying.
The poem tells how Donald, a Highlandman, who held in his house a “Pistol, ancient as his race”, got deceived by “wicked Counsellors” into changing its “Stock, Lock, and Barrel”:
The work was perfect; Donald sighed—
“It is not like the old,” he cried—
“It may be wondrously improved,
But ’tis not what my fathers loved!”
In Britain’s Isle, so matchless fair,
Of Innovation’s wiles beware.
Your glorious Constitution rears
Its fabric through a thousand years,
Impregnable to every Storm,
Immortal, if insane Reform.
Believe not every spot a stain,
Nor every ancient form mis-spent,
Nor useless each rich ornament.
Experience proves, at endless length,
These may be glory, wisdom, strength;
And Fable only strives to show,
Aptly, that from rash counsels flow
Guilt, Madness, Ruin, Slavery, Woe!!
Likewise, John Morison Duncan (circa 1795-1825) wrote the following from New York on 10th February 1819:
The other great obstacle to the prosperity of the American nation, universal suffrage, will not exhibit the full extent of its evil tendency for a long time to come; and it is possible that ere that time some antidote may be discovered, to prevent or alleviate the mischief which we might naturally expect from it. It does however seem ominous of evil, that so little ceremony is at present used with the constitutions of the various States. The people of Connecticut, not contented with having prospered abundantly under their old system, have lately assembled a convention, composed of delegates from all parts of the country, in which the former order of things has been condemned entirely, and a completely new constitution manufactured; which, among other things, provides for the same process being again gone through, as soon as the profanum vulgus takes it into its head to desire it. A sorry legacy the British Constitution would be to us, if it were at the mercy of a meeting of delegates, to be summoned whenever a majority of the people took a fancy for a new one; and I am afraid that if the Americans continue to cherish a fondness for such repairs, the highlandman’s pistol, with its new stock, lock, and barrel, will bear a close resemblance to what is ultimately produced. This is universal suffrage in its most pestilential character.
from Duncan’s Travels through Part of the United States and Canada in 1818 and 1819 (Glasgow, 1823)