It should just be the portfolio template code since the other parts of the portfolio are already present in the functions file. Then of course the files in the lib folder of the other theme.
Just make sure if you copy the code from another theme that you change the theme name to the one you’re using if it doesn’t work at first.