From: <dr...@us...> - 2003-11-19 02:42:55
|
Update of /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode/SharpCvsLib/Commands In directory sc8-pr-cvs1:/tmp/cvs-serv1984/src/ICSharpCode/SharpCvsLib/Commands Modified Files: CheckoutModuleCommand.cs UpdateCommand.cs Log Message: Changes to the console parser implementation. Index: CheckoutModuleCommand.cs =================================================================== RCS file: /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode/SharpCvsLib/Commands/CheckoutModuleCommand.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CheckoutModuleCommand.cs 11 Nov 2003 00:01:04 -0000 1.11 --- CheckoutModuleCommand.cs 19 Nov 2003 02:42:52 -0000 1.12 *************** *** 45,116 **** namespace ICSharpCode.SharpCvsLib.Commands { - /// <summary> - /// Checkout module command - /// </summary> - public class CheckoutModuleCommand : ICommand - { - private WorkingDirectory workingDirectory; - - private ILog LOGGER = LogManager.GetLogger (typeof (CheckoutModuleCommand)); /// <summary> ! /// Constructor /// </summary> ! /// <param name="workingDirectory"></param> ! public CheckoutModuleCommand(WorkingDirectory workingDirectory) ! { ! this.workingDirectory = workingDirectory; ! } ! /// <summary> ! /// Execute checkout module command. ! /// </summary> ! /// <param name="connection">Server connection</param> ! public void Execute(ICommandConnection connection) ! { ! workingDirectory.Clear(); ! connection.SubmitRequest(new CaseRequest()); ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName)); ! connection.SubmitRequest(new DirectoryRequest(".", ! workingDirectory.CvsRoot.CvsRepository + ! "/" + workingDirectory.ModuleName)); ! connection.SubmitRequest(new ExpandModulesRequest()); ! connection.SubmitRequest( ! new ArgumentRequest(ArgumentRequest.Options.MODULE_NAME)); ! if (workingDirectory.HasRevision) { ! connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.REVISION)); ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.Revision)); ! } ! if (workingDirectory.HasDate) { ! connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.DATE)); ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.GetDateAsString())); ! } ! if (workingDirectory.HasOverrideDirectory) { ! connection.SubmitRequest ( ! new ArgumentRequest (ArgumentRequest.Options.OVERRIDE_DIRECTORY)); ! connection.SubmitRequest ( ! new ArgumentRequest (workingDirectory.OverrideDirectory)); ! } ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName)); ! connection.SubmitRequest(new DirectoryRequest(".", ! workingDirectory.CvsRoot.CvsRepository + ! "/" + workingDirectory.ModuleName)); ! connection.SubmitRequest(new CheckoutRequest()); ! Manager manager = new Manager (); ! if (LOGGER.IsDebugEnabled) { ! LOGGER.Debug ("looking for directories to add to the " + ! "entries file in=[" + ! this.workingDirectory.WorkingPath + "]"); ! } ! manager.AddDirectories (this.workingDirectory.WorkingPath); } - } } --- 45,114 ---- namespace ICSharpCode.SharpCvsLib.Commands { /// <summary> ! /// Checkout module command /// </summary> ! public class CheckoutModuleCommand : ICommand { ! private WorkingDirectory workingDirectory; ! private ILog LOGGER = LogManager.GetLogger (typeof (CheckoutModuleCommand)); ! /// <summary> ! /// Constructor ! /// </summary> ! /// <param name="workingDirectory"></param> ! public CheckoutModuleCommand(WorkingDirectory workingDirectory) { ! this.workingDirectory = workingDirectory; ! } ! /// <summary> ! /// Execute checkout module command. ! /// </summary> ! /// <param name="connection">Server connection</param> ! public void Execute(ICommandConnection connection) ! { ! workingDirectory.Clear(); ! connection.SubmitRequest(new CaseRequest()); ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName)); ! connection.SubmitRequest(new DirectoryRequest(".", ! workingDirectory.CvsRoot.CvsRepository + ! "/" + workingDirectory.ModuleName)); ! connection.SubmitRequest(new ExpandModulesRequest()); ! connection.SubmitRequest( ! new ArgumentRequest(ArgumentRequest.Options.MODULE_NAME)); ! if (workingDirectory.HasRevision) { ! connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.REVISION)); ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.Revision)); ! } ! if (workingDirectory.HasDate) { ! connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.DATE)); ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.GetDateAsString())); ! } ! if (workingDirectory.HasOverrideDirectory) { ! connection.SubmitRequest ( ! new ArgumentRequest (ArgumentRequest.Options.OVERRIDE_DIRECTORY)); ! connection.SubmitRequest ( ! new ArgumentRequest (workingDirectory.OverrideDirectory)); ! } ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.ModuleName)); ! connection.SubmitRequest(new DirectoryRequest(".", ! workingDirectory.CvsRoot.CvsRepository + ! "/" + workingDirectory.ModuleName)); + connection.SubmitRequest(new CheckoutRequest()); + Manager manager = new Manager (); + if (LOGGER.IsDebugEnabled) { + LOGGER.Debug ("looking for directories to add to the " + + "entries file in=[" + + this.workingDirectory.WorkingPath + "]"); + } + manager.AddDirectories (this.workingDirectory.WorkingPath); + + } } } Index: UpdateCommand.cs =================================================================== RCS file: /cvsroot/sharpcvslib/sharpcvslib/src/ICSharpCode/SharpCvsLib/Commands/UpdateCommand.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** UpdateCommand.cs 11 Nov 2003 00:01:04 -0000 1.14 --- UpdateCommand.cs 19 Nov 2003 02:42:52 -0000 1.15 *************** *** 46,283 **** namespace ICSharpCode.SharpCvsLib.Commands { - /// <summary> - /// Command to refresh the working folder with the current sources - /// from the repository. - /// </summary> - public class UpdateCommand2 : ICommand - { - private readonly ILog LOGGER = - LogManager.GetLogger (typeof (UpdateCommand2)); - - private WorkingDirectory workingDirectory; - private string logmessage; - private string vendor = "vendor"; - private string release = "release"; - /// <summary> ! /// Log message. /// </summary> ! public string LogMessage { ! get { ! return logmessage; ! } ! set { ! logmessage = value; ! } ! } ! /// <summary> ! /// Vendor string. ! /// </summary> ! public string VendorString { ! get { ! return vendor; ! } ! set { ! vendor = value; ! } ! } ! /// <summary> ! /// Release string. ! /// </summary> ! public string ReleaseString { ! get { ! return release; } ! set { ! release = value; } - } ! /// <summary> ! /// Constructor. ! /// </summary> ! /// <param name="workingDirectory"></param> ! public UpdateCommand2(WorkingDirectory workingDirectory) ! { ! this.workingDirectory = workingDirectory; ! } ! /// <summary> ! /// Perform the update. ! /// </summary> ! /// <param name="connection"></param> ! public void Execute(ICommandConnection connection) ! { ! if (LOGGER.IsDebugEnabled) { ! String msg = "In execute, looking for working folders. " + ! "count of working folders=[" + ! workingDirectory.Folders.Count + "]"; ! LOGGER.Debug (msg); } ! Folder[] _foldersToUpdate = ! (Folder[])workingDirectory.FoldersToUpdate.Clone (); ! foreach (Folder folder in _foldersToUpdate) { ! this.SetDirectory (connection, folder); ! // TODO: Move this somewhere else (i.e. I am thinking it should exist on the folder object itself) when I get the fileset ! // system working. This just grabs the tag file at the ! // root folder. ! Tag tag = this.FetchTag (connection.Repository.WorkingPath); ! if (null != tag) { ! connection.SubmitRequest (new StickyRequest (tag.FileContents)); ! } ! if (workingDirectory.HasOverrideDirectory) { ! connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.OVERRIDE_DIRECTORY)); ! connection.SubmitRequest ( ! new ArgumentRequest (workingDirectory.OverrideDirectory)); ! } ! if (workingDirectory.HasRevision) { ! connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.REVISION)); ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.Revision)); ! } ! if (workingDirectory.HasDate) { ! connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.DATE)); ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.GetDateAsString())); } - - foreach (Entry entry in folder.Entries) { - if (!entry.IsDirectory) { - // String path = workingDirectory.CvsRoot.CvsRepository + - // "/" + - // folder.Repos.FileContents; ! //string path = workingDirectory.CvsRoot.CvsRepository + ! // "/" + workingDirectory.WorkingDirectoryName;/* + ! // folder.Key.ToString(); ! ! // if (LOGGER.IsDebugEnabled) { ! // String msg = "Before submit directory request. " + ! // "path=[" + path + "]"; ! // LOGGER.Debug (msg); ! // } ! // try { ! // connection.SubmitRequest(new DirectoryRequest(".", path)); ! // } ! // catch (Exception e) { ! // String msg = "Exception while submitting directory request. " + ! // "path=[" + path + "]"; ! // LOGGER.Error (e); ! // } ! // path = workingDirectory.CvsRoot.CvsRepository + ! // folder.Repos.FileContents; ! // TODO: Remove the LocalDirectory and swap for WorkingPath...unless I remove it all ! // string fileName = ! // this.getFileNameAndPath ( ! // Path.GetDirectoryName (workingDirectory.LocalDirectory), ! // path.Substring (workingDirectory.CvsRoot.CvsRepository.Length), ! // entry.Name); ! //this.FetchFile (connection, entry); } connection.SubmitRequest(new UpdateRequest()); } - } ! } ! private void SetDirectory (ICommandConnection connection, ! Folder folder) { ! String absoluteDir = ! connection.Repository.CvsRoot.CvsRepository + "/" + ! folder.Repository.FileContents; ! try { ! connection.SubmitRequest(new DirectoryRequest(".", ! absoluteDir)); ! } ! catch (Exception e) { ! String msg = "Exception while submitting directory request. " + ! "path=[" + folder.Repository.FileContents + "]"; ! LOGGER.Error (e); } - } - - private Tag FetchTag (String path) { - Manager manager = new Manager (); ! try { ! return manager.FetchTag (path); ! } catch (FileNotFoundException) { ! return null; ! } ! } ! private void FetchFile (ICommandConnection connection, ! Entry entry) { ! bool fileExists; ! DateTime old = entry.TimeStamp; ! entry.TimeStamp = entry.TimeStamp; ! try { ! fileExists = File.Exists (entry.Filename); ! } ! catch (Exception e) { ! LOGGER.Error (e); ! fileExists = false; ! } ! if (!fileExists) { ! connection.SubmitRequest (new EntryRequest (entry)); ! } else if (File.GetLastAccessTime(entry.Filename) != ! entry.TimeStamp.ToUniversalTime ()) { ! connection.SubmitRequest(new ModifiedRequest(entry.Name)); ! connection.SendFile(entry.Filename, entry.IsBinaryFile); ! } else { ! connection.SubmitRequest(new EntryRequest(entry)); ! connection.SubmitRequest(new UnchangedRequest(entry.Name)); } ! entry.TimeStamp = old; ! } ! /// <summary>Returns the local filename and path. ! /// </summary> ! /// <param name="baseDir">The base working dir.</param> ! /// <param name="reposDir">The remote repository relative path.</param> ! /// <param name="entryName">The name of the file to look at.</param> ! private String getFileNameAndPath ( string baseDir, ! string reposDir, ! string entryName) { ! if (LOGGER.IsDebugEnabled) { ! String msg = "baseDir=[" + baseDir + "]" + ! "reposDir=[" + reposDir + "]" + ! "entryName=[" + entryName + "]"; ! LOGGER.Debug (msg); ! } ! string _baseDir; ! if (baseDir.EndsWith (Path.DirectorySeparatorChar.ToString ())) { ! _baseDir = baseDir.Replace (Path.DirectorySeparatorChar.ToString (), ""); ! } ! else { ! _baseDir = baseDir; ! } ! //string _reposDir = reposDir.Replace ('/', Path.DirectorySeparatorChar) + ! // Path.DirectorySeparatorChar; ! //string _entryName = entryName.Replace ('/', Path.DirectorySeparatorChar); ! String path = Path.Combine (_baseDir, reposDir); ! String fileNameAndPath = Path.Combine (path, entryName); ! fileNameAndPath.Replace ('/', Path.DirectorySeparatorChar); ! if (LOGGER.IsDebugEnabled) { ! String msg = "fileNameAndPath=[" + fileNameAndPath + "]"; ! LOGGER.Debug (msg); } - - return fileNameAndPath; } - } } --- 46,262 ---- namespace ICSharpCode.SharpCvsLib.Commands { /// <summary> ! /// Command to refresh the working folder with the current sources ! /// from the repository. /// </summary> ! public class UpdateCommand2 : ICommand ! { ! private readonly ILog LOGGER = ! LogManager.GetLogger (typeof (UpdateCommand2)); ! private WorkingDirectory workingDirectory; ! private string logmessage; ! private string vendor = "vendor"; ! private string release = "release"; ! private class Arguments { ! /// <summary> ! /// Purge any local directories that are empty. This is a client function ! /// and nothing is done on the server. ! /// </summary> ! public const String PURGE = "-P"; ! /// <summary> ! /// Create any new directories that do not exist on the client. ! /// </summary> ! public const String CREATE_NEW_DIRECTORIES = "-d"; } ! /// <summary> ! /// Log message. ! /// </summary> ! public string LogMessage { ! get {return logmessage;} ! set {logmessage = value;} } ! /// <summary> ! /// Vendor string. ! /// </summary> ! public string VendorString { ! get {return vendor;} ! set {vendor = value;} ! } ! /// <summary> ! /// Release string. ! /// </summary> ! public string ReleaseString { ! get {return release;} ! set {release = value;} } ! /// <summary> ! /// Constructor. ! /// </summary> ! /// <param name="workingDirectory"></param> ! public UpdateCommand2(WorkingDirectory workingDirectory) { ! this.workingDirectory = workingDirectory; ! } ! /// <summary> ! /// Perform the update. ! /// </summary> ! /// <param name="connection"></param> ! public void Execute(ICommandConnection connection) { ! if (LOGGER.IsDebugEnabled) { ! String msg = "In execute, looking for working folders. " + ! "count of working folders=[" + ! workingDirectory.Folders.Count + "]"; ! LOGGER.Debug (msg); } ! Folder[] _foldersToUpdate = ! (Folder[])workingDirectory.FoldersToUpdate.Clone (); ! foreach (Folder folder in _foldersToUpdate) { ! this.SetDirectory (connection, folder); ! Tag tag = folder.Tag; ! if (null != tag) { ! connection.SubmitRequest (new StickyRequest (tag.FileContents)); ! } ! if (workingDirectory.HasOverrideDirectory) { ! connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.OVERRIDE_DIRECTORY)); ! connection.SubmitRequest ( ! new ArgumentRequest (workingDirectory.OverrideDirectory)); ! } ! if (workingDirectory.HasRevision) { ! connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.REVISION)); ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.Revision)); ! } ! if (workingDirectory.HasDate) { ! connection.SubmitRequest (new ArgumentRequest (ArgumentRequest.Options.DATE)); ! connection.SubmitRequest(new ArgumentRequest(workingDirectory.GetDateAsString())); ! } ! ! foreach (Entry entry in folder.Entries) { ! // Only submit the entry information if the entry is not ! // a directory. ! if (!entry.IsDirectory) { ! DateTime old = entry.TimeStamp; ! entry.TimeStamp = entry.TimeStamp; ! ! String fileName = Path.Combine(entry.Path, entry.Name); ! bool fileExists; ! fileExists = File.Exists (fileName); ! if (!fileExists) { ! // file does not exist or has been lost, pull down a fresh one ! connection.SubmitRequest (new EntryRequest (entry)); ! } else if (File.GetLastAccessTime(fileName) != entry.TimeStamp) { ! // If the file looks like it has been modified then ! // pass a modified request up to the server. ! connection.SubmitRequest(new ModifiedRequest(entry.Name)); ! connection.SendFile(fileName, entry.IsBinaryFile); ! } else { ! // Else the file is not changed, pass this information ! // up to the server as well, can't hurt. ! connection.SubmitRequest(new EntryRequest(entry)); ! connection.SubmitRequest(new UnchangedRequest(entry.Name)); ! } ! ! entry.TimeStamp = old; + connection.SubmitRequest(new EntryRequest(entry)); + this.FetchFile (connection, entry); + } } connection.SubmitRequest(new UpdateRequest()); } ! } ! private void SetDirectory (ICommandConnection connection, ! Folder folder) { ! String absoluteDir = ! connection.Repository.CvsRoot.CvsRepository + "/" + ! folder.Repository.FileContents; ! try { ! connection.SubmitRequest(new DirectoryRequest(".", ! absoluteDir)); ! } ! catch (Exception e) { ! String msg = "Exception while submitting directory request. " + ! "path=[" + folder.Repository.FileContents + "]"; ! LOGGER.Error (e); ! } } ! private void FetchFile (ICommandConnection connection, ! Entry entry) { ! bool fileExists; ! DateTime old = entry.TimeStamp; ! entry.TimeStamp = entry.TimeStamp; ! try { ! fileExists = File.Exists (entry.Filename); ! } ! catch (Exception e) { ! LOGGER.Error (e); ! fileExists = false; ! } ! if (!fileExists) { ! connection.SubmitRequest (new EntryRequest (entry)); ! } else if (File.GetLastAccessTime(entry.Filename) != ! entry.TimeStamp.ToUniversalTime ()) { ! connection.SubmitRequest(new ModifiedRequest(entry.Name)); ! connection.SendFile(entry.Filename, entry.IsBinaryFile); ! } else { ! connection.SubmitRequest(new EntryRequest(entry)); ! connection.SubmitRequest(new UnchangedRequest(entry.Name)); ! } ! entry.TimeStamp = old; } ! /// <summary>Returns the local filename and path. ! /// </summary> ! /// <param name="baseDir">The base working dir.</param> ! /// <param name="reposDir">The remote repository relative path.</param> ! /// <param name="entryName">The name of the file to look at.</param> ! private String GetFileNameAndPath ( string baseDir, ! string reposDir, ! string entryName) { ! if (LOGGER.IsDebugEnabled) { ! String msg = "baseDir=[" + baseDir + "]" + ! "reposDir=[" + reposDir + "]" + ! "entryName=[" + entryName + "]"; ! LOGGER.Debug (msg); ! } ! string _baseDir; ! if (baseDir.EndsWith (Path.DirectorySeparatorChar.ToString ())) { ! _baseDir = baseDir.Replace (Path.DirectorySeparatorChar.ToString (), ""); ! } ! else { ! _baseDir = baseDir; ! } ! //string _reposDir = reposDir.Replace ('/', Path.DirectorySeparatorChar) + ! // Path.DirectorySeparatorChar; ! //string _entryName = entryName.Replace ('/', Path.DirectorySeparatorChar); ! String path = Path.Combine (_baseDir, reposDir); ! String fileNameAndPath = Path.Combine (path, entryName); ! fileNameAndPath.Replace ('/', Path.DirectorySeparatorChar); ! if (LOGGER.IsDebugEnabled) { ! String msg = "fileNameAndPath=[" + fileNameAndPath + "]"; ! LOGGER.Debug (msg); ! } ! return fileNameAndPath; } } } |