0

There once was almost the [same question]: Append directories to ignored list in SVN that I'm asking, but I'm needing it for windows.

For my needs, I need a script like @nosid wrote in that thread:

#! /bin/bash
ignore="foo"
for pathname in "$@"; do
    lines="$( svn propget svn:ignore "$pathname" )"
    grep -F -x -q "$ignore" - <<< "$lines" ||
    svn propset svn:ignore "$lines"$'\n'"$ignore" "$pathname"
done

Do you know how to implement that with vbscript (or batch)?

At the moment I'm doing it like this and this just unversions WimID.xml but all other ignored files aren't ignored anymore (Ignore file in Subversion removes old values from svn:ignore property).

fso.MoveFile "G:\x\BuildImage\WimID.xml", "G:\WimID.xml"

wshshell.run UnversionBat

fso.MoveFile "G:\WimID.xml", "G:\x\BuildImage\WimID.xml"

The UnversionBat is:

svn commit WimID.xml -m "test"

svn propset svn:ignore WimID.xml .
Community
  • 1
  • 1
rugkei
  • 70
  • 7

1 Answers1

1

In VBScript you'd loop over the argument list like this:

For Each pathname In WScript.Arguments
  ...
Next

The output of an external command can be read like this:

Set sh = CreateObject("WScript.Shell")

Set svn = sh.Exec("svn propget svn:ignore """ & pathname & """")
Do While svn.Status = 0
  WScript.Sleep 100
Loop
If svn.ExitCode = 0 Then lines = Split(svn.StdOut.ReadAll, vbNewLine)

For running an external command without reading its output you can use either the Exec or the Run method.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
  • Thanks. I tried it as follow: `For Each sPath In WScript.Arguments Set svn = wshshell.Exec("svn propget svn:ignore """ & sPath & """") Do While svn.Status = 0 WScript.Sleep 100 Loop If svn.ExitCode = 0 Then lines = Split(svn.StdOut.ReadAll, vbNewLine) Next MsgBox lines` sPath is a directory which has six ignored files in it, so shouldn't the MsgBox give me the names of these six files? What am I doing wrong? I don't really get what's Wscript.Arguments for. I just want to ignore one more file in a specific path, so when I can read out the old ones, I can just add them again. – rugkei Nov 21 '13 at 09:29
  • I was able to make it loop through all files in a specific folder but it still shows me nothing: `Set objFolder = fso.GetFolder(sPath) For Each File In objFolder.Files MsgBox File Set svn = wshshell.Exec("svn propget svn:ignore """ & File & """") Do While svn.Status = 0 WScript.Sleep 100 Loop If svn.ExitCode = 0 Then lines = Split(svn.StdOut.ReadAll, vbNewLine) Next` What could be the problem? – rugkei Nov 21 '13 at 12:33
  • 1
    Does the command work when you run it directly in `CMD`? Property names are case-sensitive, so, is the name spelled correctly? Do you get output on STDERR (`WScript.Echo svn.StdErr.ReadAll`)? – Ansgar Wiechers Nov 21 '13 at 17:45
  • When I run `svn propget svn:ignore G:\depot\stage2\BuildImage\WimID.xml` (WimID.xml is ignored atm) directly in `CMD` I get that it isn't under version control. When I run it on a file that is under version control, I don't get an output at all. The name is spelled correctly. Output on STDERR is only the last file in the directory WimID.xml: `svn: E200005: G:\depot\stage2\BuildImage\WimID.xml isn't under version control` then the output of lines is empty. – rugkei Nov 22 '13 at 07:56
  • Well, version control doesn't control files that aren't under version control, so there's nothing for `svn` to handle there. If the command doesn't produce output on STDOUT that means that either an error occurred (in which case there should be output on STDERR) or that the file doesn't have the specified property. – Ansgar Wiechers Nov 22 '13 at 09:00