Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 519
sdaau Avatar asked Nov 04 '11 23:11

sdaau


People also ask

How do I view svn files?

SVN has incremented the version of your file (NOT the repository… just the file) to the next logical revision, revision 2. If you want to review what's happened to your files then you can check this by selecting the top-level parent folder and clicking on the Visual SVN 'Show log' option.

How do I view local changes in svn?

To get an overview of your changes, use the svn status command. You may use svn status more than any other Subversion command. If you run svn status at the top of your working copy with no arguments, it detects all file and tree changes you've made.

What is in svn status?

The svn status command informs you about what has changed in your local repository checkout compared to the moment you first checked it out or last did an update. It does not compare it to the contents of the svn server. For this reason svn status may be invoked offline.

What is revision number in svn?

As you saw in the section called “Revisions”, revision numbers in Subversion are pretty straightforward—integers that keep getting larger as you commit more changes to your versioned data. Still, it doesn't take long before you can no longer remember exactly what happened in each and every revision.


2 Answers

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.

like image 164
manojlds Avatar answered Sep 29 '22 01:09

manojlds


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.

like image 41
stgatilov Avatar answered Sep 29 '22 02:09

stgatilov