'How to read files on server-side

I have a question, that I can't answer atm by myself. I want to read data from files, that are committed on a subversion server. I want to run a script on the server that needs to read the data (docx and xlsm) from certain files. How can I access the files, since they are not present like in the working directory on my computer? Does anyone know? The "svnlook cat" command doesn't work as I wish unfortunately...

svn


Solution 1:[1]

The SVN cat file://path/to/repo/file will work as you want it. You just need to manipulate it to fit your needs. I was having this exact same issue: How to read from a repository without using a working copy.

For me, I used python to create my script.

import subprocess as sp import os

command = "svn cat file:///path/to/repo/file"

file_content = sp.getoutput(command)

Since svn cat will send output to stdout, you can store that inside of an object and read normally from there. You will not be able to read from your repo without the svn cat command.

Another option is to export the files you need.

If you don't care about having a copy of your repo files out in the open then tripleee gave you a good suggestion. Use svn cat and pipe it to a new file somewhere. Or you can just use svn checkout. Afterall, checkouts very purpose is to provide you access to your repo files.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 asymmonds