I don't know why this myth about the depth of field being utterly independent of focal length (for constant magnification) keeps on going, because it's easy to prove that it's wrong and sometimes it really matters that it's wrong.
Nonetheless, it is a myth and it is wrong.
Here's the real skinny. At close working distances, depth of field is nearly independent of focal length. In fact here's a handy approximate equation for depth of field that depends solely on circle of confusion (c), aperture (f), and on-film (or sensor) magnification (M):
DoF (on either side of the subject) = c*f*(M+1)/(M*M)
As you decrease the magnification, lens focal length starts to become more important. As you get close to the hyperfocal distance, to maintain comparable total depth of field, the magnification becomes inversely proportional to the focal length of the lens rather than being independent of it!
A good rule of thumb is that for just about any photography you do indoors, depth of field isn't going to be affected by focal length, just on-film magnification. But as you start photographic more distant subjects, the effect of focal length increases and eventually becomes as important as aperture.
At intermediate distances, the total depth of field (in front of and behind the subject combined) decreases as the focal length of the lens increases, for the same on-film magnification (and same aperture and circle of confusion). The distribution also changes. The shorter focal length lens will always have less depth of field in front of the subject than the longer focal length lens, but it will have more depth of field behind the subject than the longer focal length lens. In other words, for the shorter lens the depth of field is not only greater but more asymmetric.
These comparison photos illustrate how changing the focal length of the lens can change depth of field even when the on-film magnification stays the same. The photograph in the upper left was made with a 25mm lens and the one in the upper right with a 300mm lens. The lower photographs are enlargements of the ones directly above them.
I moved the camera to keep the on-film magnification 0.02X, but the distance between the targets didn't change and both photographs were made at ƒ/11. The front target is equally sharp in both photographs, but the far target is much blurrier in the 300mm photograph than in the 25mm photograph.
This graph shows how depth of field changes with on-film magnification for the 25mm and 300mm lenses. At closer distances (greater magnifications) focal length has minimal effect on depth of field; it becomes increasingly important as the distance increases. Notice that the total depth of field is always greater for the shorter lens, but the shorter lens has less depth of field in front of the subject and more depth of field behind it than the longer lens does.
Assuming you don't want to take my word for any of this, you can prove it yourself any one of several ways:
1. Mathematically—if depth of field really depends upon magnification and not lens focal length, you should be able to recast the depth of field equations using magnification as one of the variables so that focal length drops out entirely. Give it a try! Good luck!
2. Numerically—set up a spreadsheet with the depth of field equations that computes depth of field in front of and behind the subject as a function of on-film magnification (for a given f-stop and circle of confusion, of course). Try it out on a bunch of cases.
3. Pragmatically—pull out some of your lenses that still have depth of field markings on them. Compare the depth of field of markings between, oh say, your 50mm lens and a 300mm lens at distances that would correspond to the same on-film magnification (about six times further for the 300mm lens).
4. Logically—consider two extremes. First hyperfocal distance. Go to your textbook and pull out the standard equation for hyperfocal distance. Figure out what on-film magnification it corresponds to. You'll see that the magnification varies inversely with the focal length of the lens. No, that's not an artifact of having the far distance go to infinity. You could pick a far depth of field that was huge but finite, like say, 1 km, and plug that into the full depth of field equations and you'd get the same result as close as matters.
5. Reductio ad absurdum—consider the depth of field in front of the subject for any particular lens and situation you choose. It'll be some finite number. Now imagine swapping that lens for a lens of shorter focal length; to keep the on-film magnification the same (which, according to myth, will keep the depth of field the same) you will have to move proportionately closer to the subject. Keep making the lens shorter and shorter. At some point the total distance from the shorter lens to the subject is going to be less than the near-side depth of field you calculated for the longer lens.