| 1 |
// SvnTest, a client program used to test SubversionSharp library |
|---|
| 2 |
#region Copyright (C) 2004 SOFTEC sa. |
|---|
| 3 |
// |
|---|
| 4 |
// SvnTest, a client program used to test SubversionSharp library |
|---|
| 5 |
// Copyright 2004 by SOFTEC sa |
|---|
| 6 |
// |
|---|
| 7 |
// This program is free software; you can redistribute it and/or |
|---|
| 8 |
// modify it under the terms of the GNU General Public License as |
|---|
| 9 |
// published by the Free Software Foundation; either version 2 of |
|---|
| 10 |
// the License, or (at your option) any later version. |
|---|
| 11 |
// |
|---|
| 12 |
// This program is distributed in the hope that it will be useful, |
|---|
| 13 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 15 |
// See the GNU General Public License for more details. |
|---|
| 16 |
// |
|---|
| 17 |
// You should have received a copy of the GNU General Public |
|---|
| 18 |
// License along with this program; if not, write to the Free Software |
|---|
| 19 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 20 |
// |
|---|
| 21 |
// Sources, support options and lastest version of the complete library |
|---|
| 22 |
// is available from: |
|---|
| 23 |
// http://www.softec.st/SubversionSharp |
|---|
| 24 |
// |
|---|
| 25 |
// |
|---|
| 26 |
// Initial authors : |
|---|
| 27 |
// Denis Gervalle |
|---|
| 28 |
// Olivier Desaive |
|---|
| 29 |
#endregion |
|---|
| 30 |
// |
|---|
| 31 |
using System; |
|---|
| 32 |
using System.Collections; |
|---|
| 33 |
using System.IO; |
|---|
| 34 |
using Mono.GetOptions; |
|---|
| 35 |
using Softec.AprSharp; |
|---|
| 36 |
using Softec.SubversionSharp; |
|---|
| 37 |
|
|---|
| 38 |
namespace Softec.SubversionSharp.Test { |
|---|
| 39 |
|
|---|
| 40 |
[SubCommand("checkout","co", |
|---|
| 41 |
@"URL... [PATH] |
|---|
| 42 |
Check out a working copy from a repository. |
|---|
| 43 |
|
|---|
| 44 |
Note: If PATH is omitted, the basename of the URL will be used as |
|---|
| 45 |
the destination. If multiple URLs are given each will be checked |
|---|
| 46 |
out into a sub-directory of PATH, with the name of the sub-directory |
|---|
| 47 |
being the basename of the URL." |
|---|
| 48 |
)] |
|---|
| 49 |
class CheckoutCmd : CmdBaseWithAuth |
|---|
| 50 |
{ |
|---|
| 51 |
[Option("checkout revision {REV}", 'r', "revision")] |
|---|
| 52 |
public string oStrRevision { |
|---|
| 53 |
set |
|---|
| 54 |
{ |
|---|
| 55 |
oRevision = StringToRevision(value); |
|---|
| 56 |
} |
|---|
| 57 |
} |
|---|
| 58 |
public SvnRevision oRevision = new SvnRevision(Svn.Revision.Head); |
|---|
| 59 |
|
|---|
| 60 |
[Option("operate on single directory only", 'N', "non-recursive")] |
|---|
| 61 |
public bool oNoRecurse { |
|---|
| 62 |
set { oRecurse = !value; } |
|---|
| 63 |
} |
|---|
| 64 |
public bool oRecurse = true; |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
protected override int Execute() |
|---|
| 68 |
{ |
|---|
| 69 |
int nbUrl = RemainingArguments.Length-1; |
|---|
| 70 |
Uri[] urls = new Uri[nbUrl]; |
|---|
| 71 |
string path; |
|---|
| 72 |
|
|---|
| 73 |
for(int i=1; i<nbUrl; i++) |
|---|
| 74 |
{ |
|---|
| 75 |
urls[i-1] = new Uri(RemainingArguments[i]); |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
try { |
|---|
| 79 |
urls[nbUrl-1] = |
|---|
| 80 |
new Uri(RemainingArguments[nbUrl]); |
|---|
| 81 |
path = string.Empty; |
|---|
| 82 |
} |
|---|
| 83 |
catch(System.UriFormatException) { |
|---|
| 84 |
path = RemainingArguments[nbUrl--]; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
if( nbUrl > 1 |
|---|
| 88 |
|| RemainingArguments.Length == 2) |
|---|
| 89 |
{ |
|---|
| 90 |
if( path != string.Empty ) |
|---|
| 91 |
path += Path.DirectorySeparatorChar; |
|---|
| 92 |
for(int i = 0; i < nbUrl; i++) |
|---|
| 93 |
{ |
|---|
| 94 |
string[] seg = urls[i].Segments; |
|---|
| 95 |
try |
|---|
| 96 |
{ |
|---|
| 97 |
client.Checkout(new SvnUrl(urls[i], client.Pool), |
|---|
| 98 |
new SvnPath(path + seg[seg.Length-1], client.Pool), |
|---|
| 99 |
oRevision, |
|---|
| 100 |
oRecurse); |
|---|
| 101 |
} |
|---|
| 102 |
catch( Exception e ) |
|---|
| 103 |
{ |
|---|
| 104 |
if( oDebug ) |
|---|
| 105 |
Console.WriteLine(e); |
|---|
| 106 |
else |
|---|
| 107 |
Console.WriteLine(e.Message); |
|---|
| 108 |
} |
|---|
| 109 |
client.Clear(); |
|---|
| 110 |
} |
|---|
| 111 |
} |
|---|
| 112 |
else |
|---|
| 113 |
{ |
|---|
| 114 |
client.Checkout(new SvnUrl(urls[0], client.Pool), |
|---|
| 115 |
new SvnPath(path, client.Pool), |
|---|
| 116 |
oRevision, |
|---|
| 117 |
oRecurse); |
|---|
| 118 |
} |
|---|
| 119 |
return(0); |
|---|
| 120 |
} |
|---|
| 121 |
} |
|---|
| 122 |
} |
|---|