Castro
Castro

Reputation: 1456

How can I see the revision number of each file in a SVN working copy?

I work with another developer in the same working copy (I know that is a bad idea), we usually do updated of individual files, and now we have files in some revision and others in another. How can I see a list of files with their respectives revision numbers? (The working copy is in a linux box, and we're using svn command line.

Thanks in advance for any help

Upvotes: 8

Views: 29124

Answers (6)

Singhak
Singhak

Reputation: 8896

svn -R list --verbose

It will give output like this

109 authorname 3818 Nov 20 2012 JSON/xyz.json

Upvotes: 5

SimonD
SimonD

Reputation: 638

svn info -R . | egrep "^Path:|^Revision:" | paste - -

Which means

  • Recursively get info of every file in the sub tree rooted at the current directory
  • Keep only lines beginning with "Path:" or "Revision:"
  • Join the Path/Revision lines onto a single line

Produces output like this:

Path: Tools/xmlvalidator    Revision: 69114
Path: Tools/xmlvalidator/main.c Revision: 69114

Upvotes: 3

whallz
whallz

Reputation: 2613

Same program in php:

svn info -R > tmp_info && php versions.php

<?php
$lines = explode("\n",file_get_contents("tmp_info"));
array_pop($lines);

$idx = 0;
$files = array();
$files[] = array();

foreach($lines as $i => $line) {
  if(!empty($line)) { 
    $spl = explode(':',$line);
    $key = $spl[0];
    if($key == 'Name' || $key == 'Revision' || $key == 'Path')
      $files[$idx][$key] = $spl[1];
  } else {
    $idx++;
    $files[$idx] = array();
  }
}


echo  'files : ' . count($files) . "\n";
foreach($files as $file) {
  if(isset($file["Name"]))
    echo " REVISION: " . trim($file["Revision"]) . ' -  ' . trim($file["Path"]) .'/' . trim($file["Name"]) . "\n";
}

Upvotes: 0

Castro
Castro

Reputation: 1456

Finally I used combined solution using the command posted by Dmitry Yudakov and a litle script in js-rhino. Now I can find all the files with a different revision number doing something like:

svn info -R > tmp_info rhino read-svn.js | grep -v 295

/* The script */ 
lines = readFile("tmp_info").split("\n");  
lines.pop();
String.prototype.trim = function() {
  return this.replace(/^\s+|\s+$/g,"");
}
var idx = 0;
var files = [];
files[0] = {};
var line;
for (i in lines) {
  line = lines[i].toString();
  if(line.length) { 
    key = line.split(':')[0];
    if(key == 'Name' || key == 'Revision' || key == 'Path')
      files[idx][key] = line.split(':')[1];
  } else {
    idx++;
    files[idx] = {};
  }
}

print( 'files : ' + files.length + "\n");
for (i = 0; i< files.length ; i++) {
  var file = files[i];
  if(typeof(file.Name) !== "undefined")
    print(" REVISION: " + file.Revision.trim() + ' -  ' + file.Path.trim() +'/' + file.Name.trim() );
}

Upvotes: 0

the_mandrill
the_mandrill

Reputation: 30832

The svnversion command may be what you need as it will show the range of revisions in the working copy.

Upvotes: 2

Dmitry Yudakov
Dmitry Yudakov

Reputation: 15734

Try this in your working copy

svn info *

or

svn info -R *

to see all files and directories recursively

You may type svn help info to see other options

Upvotes: 9

Related Questions