// ImportModuleCommand.cs
// Copyright (C) 2001 Mike Krueger
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// As a specption does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
using System;
using System.Collections;
using System.IO;
using CVS.Requests;
using CVS.Misc;
namespace CVS.Commands{
public class ImportModuleCommand : ICommand
{
WorkingDirectory workingdirectory;
string logmessage;
string vendor = "vendor";
string release = "release";
public string LogMessage {
get {
return logmessage;
}
set {
logmessage = value;
}
}
public string VendorString {
get {
return vendor;
}
set {
vendor = value;
}
}
public string ReleaseString {
get {
return release;
}
set {
release = value;
}
}
public ImportModuleCommand(WorkingDirectory workingdirectory, string logmessage)
{
this.logmessage = logmessage;
this.workingdirectory = workingdirectory;
}
/* log
Case
Argument -b
Argument 1.1.1
Argument -m
Argument logmessage
Argumentx
Argument SharpDevelop
Argument vendor
Argument start
Directory .
/cvsroot/sharpdevelop/SharpDevelop
Modified TestME.cs
u=rw,g=rw,o=rw
9
testme :)
Directory c
/cvsroot/sharpdevelop/SharpDevelop/c
Modified te2.cs
u=rw,g=rw,o=rw
14
fojrwpefj4erwp
Directory .
/cvsroot/sharpdevelop/SharpDevelop
import
*/
public void Execute(CVSServerConnection connection)
{
connection.SubmitRequest(new CaseRequest());
connection.SubmitRequest(new ArgumentRequest("-b"));
connection.SubmitRequest(new ArgumentRequest("1.1.1"));
connection.SubmitRequest(new ArgumentRequest("-m"));
connection.SubmitRequest(new ArgumentRequest(logmessage));
connection.SubmitRequest(new ArgumentRequest(workingdirectory.WorkingDirectoryName));
connection.SubmitRequest(new ArgumentRequest(vendor));
connection.SubmitRequest(new ArgumentRequest(release));
Console.WriteLine("IMPORT START");
foreach (DictionaryEntry folder in workingdirectory.Folders) {
foreach (Entry entry in ((Folder)folder.Value).Entries) {
DateTime old = entry.TimeStamp;
entry.TimeStamp = entry.TimeStamp.ToUniversalTime();
string path = workingdirectory.CvsRoot.CvsRepository + "/" + workingdirectory.WorkingDirectoryName + folder.Key.ToString();
string modulepath;
if (folder.Key.ToString().Length < 1) {
modulepath = ".";
} else {
modulepath = folder.Key.ToString().Substring(1);
}
connection.SubmitRequest(new DirectoryRequest(modulepath, path));
connection.SubmitRequest(new ModifiedRequest(entry.Name));
path = workingdirectory.CvsRoot.CvsRepository + folder.Key.ToString();
string fileName = workingdirectory.ToLocalPath(path + "/" + entry.Name);
if (entry.IsBinaryFile) {
connection.UncompressedFileHandler.SendBinaryFile(connection.OutputStream, fileName);
} else {
connection.UncompressedFileHandler.SendTextFile(connection.OutputStream, fileName);
}
entry.TimeStamp = old;
}
}
connection.SubmitRequest(new DirectoryRequest(".", workingdirectory.CvsRoot.CvsRepository + "/" + workingdirectory.WorkingDirectoryName));
connection.SubmitRequest(new ImportRequest());
Console.WriteLine("IMPORT END");
}
}
}
|