The Joyent Community

A place where the Joyent community can gather, help each other out, and stay informed.

You are not logged in.

#1 2005-03-12 17:14:37

misterk
?
From: Mpls, MN
Registered: 2004-06-01
Posts: 1167
Website  Expertise

Add all new file to svn repository at once?

What I want to do is just type one command (svn add-new or something) and have all the new files not yet versioned in the working copy changed from "?" to "A".

Is there some way to do this with svn? I wrote a ruby script to do the same, but it would make sense that this is somewhere in svn itself already, so I just wondered. Here's the script I wrote in case my description above isn't clear:

Code:

#!/usr/bin/env ruby

  1. checks to see if argument is passed, and works on said file
  2. or assumes current directory is a working copy and works from there
    unless ARGV.empty? directory = ARGV status = `cd #{directory};svn status`.split("\n")
    else status = `svn status`.split("\n")
    end

    status.each do |line|

    match = /^\?\t*.*/.match(line).to_s.split # matches all files not yet added to repo (status: ?) unless match1.nil? puts " adding: \t #{match1}" `svn add #{match1}` end
    end


-kjell

Offline

 

#2 2005-03-12 18:03:58

jason
a chief (i started this place)
From: San Francisco
Registered: 2004-06-01
Posts: 8814
Website  Expertise

Re: Add all new file to svn repository at once?

you just go in the working copy and

Code:

svn add *


it'll add anything that isn't in

Offline

 

#3 2005-03-12 20:19:17

brwnx
Member
From: Copenhagen , Denmark
Registered: 2004-09-28
Posts: 335
Website  Expertise

Re: Add all new file to svn repository at once?

svn add * doesnt work recursively...which really sucks...

Offline

 

#4 2005-03-14 07:24:56

yerejm
バカ
Registered: 2004-12-03
Posts: 307
Expertise

Re: Add all new file to svn repository at once?

Would something like

Code:

Dir['**/*'].each {|file| `svn add #{file}`}


do it?

Wait... the docs say svn add is recursive, but it gives examples with a given directory name. So, maybe

Code:

Dir['**'].each {|file| `svn add #{file}`}


will do it?

Last edited by yerejm (2005-03-14 07:32:04)

Offline

 

#5 2005-03-18 19:36:08

Marten
Moderator
From: Netherlands
Registered: 2004-09-13
Posts: 594
Website  Expertise

Re: Add all new file to svn repository at once?

How about

svn status | grep "^\?" | awk '{print $2}' | xargs svn add

Offline

 

#6 2005-03-18 20:06:07

brwnx
Member
From: Copenhagen , Denmark
Registered: 2004-09-28
Posts: 335
Website  Expertise

Re: Add all new file to svn repository at once?

Aha!! Now you're talking...
And then add the following to your .bash_profile

svn_add_all(){
svn status | grep "^\?" | awk '{print $2}' | xargs svn add
}

Good one

Offline

 

#7 2005-03-18 21:10:06

graue
Member
From: Fairfax, VA, USA
Registered: 2005-02-23
Posts: 92
Expertise

Re: Add all new file to svn repository at once?

This ought to be moved into the svn forum.

Offline

 

#8 2005-04-05 05:51:16

yennersnow
New member
Registered: 2005-03-01
Posts: 9
Expertise

Re: Add all new file to svn repository at once?

svn add --force dirname

Offline

 

#9 2005-04-05 18:02:28

poswald
New member
From: Brooklyn, NY
Registered: 2005-03-17
Posts: 22
Website  Expertise

Re: Add all new file to svn repository at once?

I thought one of the strengths of svn is atomic commits. When you write a script that loops to call svn add you lose that.

Offline

 

#10 2005-04-06 02:34:15

jordanbrock
Member
From: Perth, Australia
Registered: 2005-01-31
Posts: 344
Website  Expertise

Re: Add all new file to svn repository at once?

svn add --force *

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson