sdaau
sdaau

Reputation: 38641

SVN - show versioned local files only (command line)?

I have a folder, versioned under SVN, with let's say 100 of files which are not under revision control - and about 10 that are.

On svn, version 1.6.6, if I type svn status, I get unversioned files with a question mark, ?, or the modified/added files M/A - but I cannot see local files that are versioned, but haven't changed. svn list goes online, and retrieves say names of, say, four versioned files (but not all ten).

Is there a command I can use on the command line, so svn lists which files are under version control in a given local directory?

Many thanks in advance for any answers,
Cheers!

Upvotes: 8

Views: 8927

Answers (2)

stgatilov
stgatilov

Reputation: 5533

The best solution is indeed running the command:

svn list --recursive .

However, this is rather slow. I have a large SVN repo with 26559 files of total size 7 GB, and this command takes almost 4 minutes.


Modern SVN client stores information about working copy in sqlite database, so it is rather easy to hack it. Here is a python script which extracts the list of versioned files in less than a second (works on SVN 1.9.5):

import sqlite3
db = sqlite3.connect('.svn/wc.db')
cursor = db.cursor()
cursor.execute("SELECT * FROM NODES")
data = cursor.fetchall()
for row in data:
    filename = row[1]
    if len(filename.strip()) == 0:
        continue
    print(filename)

Of course, this is an unsupported hack, so it can easily break. Most likely changing minor version of SVN WC is enough to break it. Also, I have no idea how this solution interacts with complicated features like externals, some sparse/mixed checkouts, and whatever other crazy things SVN allows.

Upvotes: 2

manojlds
manojlds

Reputation: 301327

svn ls will list all files. If you are not seeing all the files that you expect, maybe they are not in the latest revision, in which case specify the revision using --revision, or probably they are within folders and hence you will have to include --recursive.

Otherwise, if you don't want to use svn ls, you will can write a one liner in bash so that you can subtract the output of normal ls and the svn status entries for untracked files.

Upvotes: 14

Related Questions