Sort of. Running diff alone will tell you when code is similar or the same, but it won't tell you whether that similarity is because code moved directly from NetBSD to Darwin (or vice versa if that happened) or because they share many common ancestors (from the graphic, that would be at least BSD 4.3, BSD 4.4, BSD NET/2, 386BSD,..)