SVN List of files modified solely by one user

Our company has 7 developers working on a project for which we use SVN as a VCS.

I'm not sure if this is possible, but there is a way to find out a list of files in the repository that have been changed exclusively by a specific user throughout the history of the repository.

For instance:

  • There are 3 users - user1 , user2 , user3
  • There are also 3 files - "folder1 / file1" , "folder1 / file2" and "folder2 / file1"

There are 10 commits in the repository -

  • "folder1 / file1" has only user1 changes .
  • "folder1 / file2" has the changes user2 and user3 .
  • "folder2 / file1" has the changes user1 , user2 and user3 .

Essentially, in the above case, if the file search is changed exclusively with user1 , the result will be "folder1 / file1" , as other files have changes from several authors.

I tried Google and SO Search, but could not find a solution for this. We will be very grateful if there is a way to achieve this.

Hello

+4
source share
3 answers

Hmmm. Interest Ask.

If you are only interested in the files visible in the latest version, you can do something like this:

$ svn --recursive list 

This will give you a list of all the files in Subversion (at least the ones that are currently in the HEAD branches and trunk)

From there, you can pass this to the Subversion log command for each file to see which users modified this file during this file.

 $ svn -R $URL | while read file do echo "FILE = $file" svn log $URL/$file done 

Now everything will be a little complicated (at least do it in a shell). You will have to analyze the output of the svn log , which means that you are reading STDIN again. To get around this, you will have to open a different device number for this output and do this by reading from this ...

Ok, let's do it in Perl ...

 # Bunch of Pragmas that don't mean much use strict; use warnings; use feature qw(say); # Defining some constants for svn command and url use constant { URL => "svn://localhost", SVN => "svn", }; my $cmd; # This creates the svn list command to list all files # I'm opening this command as if it a file $cmd = SVN . " list -R " . URL; open (FILE_LIST, "$cmd|") or die "Can't open command '$cmd' for reading\n"; # Looping through the output of the "svn list -R URL" # and setting "$file" to the name of the file while (my $file = <FILE_LIST>) { chomp $file; # Now opening the "svn log URL/$file" command as a file $cmd = SVN . " log " . URL . "/$file"; open(FILE_LOG, "$cmd|") or die "Can't open command '$cmd' for reading\n"; my $initialChanger = undef; my $changer; # Looping through the output of the "svn log" command while (my $log = <FILE_LOG>) { chomp $log; # Skipping all lines that don't start with a revision number. # I don't care about the commit log, I want the name of the # user who is in the next section over between two pipes next unless ($log =~ /^\s*r\d+\s+\|\s*([^|]+)/); # The previous RegEx actually caught the name of the changer # in the parentheses, and now just setting the changer $changer = $1; # If there is no initialChanger, I set the changer to be initial $initialChanger = $changer if (not defined $initialChanger); # And if the changer isn't the same as the initial, I know at least # two people edited this file. Get the next file if ($initialChanger ne $changer) { close FILE_LOG; next; } } # Finished with file log, if we're down here, there was only # one person who edited the file. close FILE_LOG; say qq(Sole Changer of "$file" is "$changer"); } 

Quick and dirty and not very well tested. I tested it in my repository, but then I am the only changer in my repository. I know you did not ask Perl, but I tried my best to explain what I was doing. This is a tool that I can use. When you have a hammer, everything looks like a nail. Even if it's a big ugly old obsolete hammer that you have.

+4
source

Given the file name, you can find out how many people submitted changes to it using

 svn log --xml filename | grep "<author>" | sort -u | wc -l 

You can change this to see if the file has been edited with a specific username.

 svn log --xml filename | grep "<author>" | sort -u | grep username | wc -l 
+1
source

I don’t know very well the SVN command line commands, but I know that with TortoiseSVN on Windows I can view the log, put my name in the search field and set the date range from beginning to end, select all the commits that are returned in the search, and then browse all the files that I have in the file list.

Probably not too useful if you are not using something like TortoiseSVN, but at least if it is possible then it should be possible!

Edit: Added sample image so you can see what I mean

Example TortoiseSVN

0
source

All Articles