The #include directive allows to significantly reduce size of the shader code duplication.
There was a try to implement #include: https://trac.wildfiregames.com/attachment/ticket/3640/preprocessor_include_with_hotload_impl.patch. But it was incorrect in terms of macro-context, also it has some design and leak issues. The current patch was inspired by that one though.
The patch doesn't change Ogre code to reduce third_party changes, and it completely follows original Ogre approach. They use the same technique to parse #include directives before the main preprocessor pass: https://github.com/OGRECave/ogre/blob/155b2385de92e81ce7688888ff327d7d27992e45/RenderSystems/GLSupport/src/GLSL/OgreGLSLShaderCommon.cpp#L82, _resolveIncludes: https://github.com/OGRECave/ogre/blob/155b2385de92e81ce7688888ff327d7d27992e45/OgreMain/src/OgreHighLevelGpuProgram.cpp#L263
The algorithm is similar but allows some white space padding (like for a usual preprocessor directive).