コード例 #1
0
ファイル: StarTeamList.cs プロジェクト: kiprainey/nantcontrib
        /// <summary> Implements base-class abstract function to perform the checkout
        /// operation on the files in each folder of the tree.</summary>
        /// <param name="starteamFolder">the StarTeam folder from which files to be checked out</param>
        /// <param name="targetFolder">the local mapping of rootStarteamFolder</param>
        protected override void visit(InterOpStarTeam.StFolder starteamFolder, FileInfo targetFolder) {
            try {
                if (null == _rootLocalFolder) {
                    Log(Level.Info, "Folder: {0} (Default folder: {1})", 
                        starteamFolder.Name, targetFolder);
                } else {
                    Log(Level.Info, "Folder: {0} (Local folder: {1})", 
                        starteamFolder.Name, targetFolder);
                }
                System.Collections.Hashtable localFiles = listLocalFiles(targetFolder);

                // For all Files in this folder, we need to check
                // if there have been modifications.
                foreach(InterOpStarTeam.StFile stFile in starteamFolder.getItems("File")) {
                    string filename = stFile.Name;
                    FileInfo localFile = new FileInfo(Path.Combine(targetFolder.FullName,filename));

                    delistLocalFile(localFiles, localFile);

                    // If the file doesn't pass the include/exclude tests, skip it.
                    if (!IsIncluded(filename)) {
                        continue;
                    }

                    list(stFile, localFile);
                }

                // Now we recursively call this method on all sub folders in this
                // folder unless recursive attribute is off.
                foreach(InterOpStarTeam.StFolder stFolder in starteamFolder.SubFolders) {
                    FileInfo targetSubfolder = new FileInfo(stFolder.Path);
                    delistLocalFile(localFiles, targetSubfolder);
                    if (this.recursive) {
                        visit(stFolder, targetSubfolder);
                    }
                }
            } catch (IOException ex) {
                throw new BuildException(ex.Message, Location, ex);
            }
        }
コード例 #2
0
        /// <summary> Implements base-class abstract function to perform the checkin operation on the files in each folder of the tree.</summary>
        /// <param name="starteamFolder">the StarTeam folder to which files will be checked in</param>
        /// <param name="targetFolder">local folder from which files will be checked in</param>
        protected override void visit(InterOpStarTeam.StFolder starteamFolder, FileInfo targetFolder) {
            int notProcessed = 0;
            int notMatched = 0;

            try {
                System.Collections.Hashtable localFiles = listLocalFiles(targetFolder);

                // If we have been told to create the working folders
                // For all Files in this folder, we need to check
                // if there have been modifications.

                foreach(InterOpStarTeam.StFile stFile in starteamFolder.getItems("File")) {
                    string filename = stFile.Name;
                    FileInfo localFile = new FileInfo(Path.Combine(targetFolder.FullName, filename));

                    delistLocalFile(localFiles, localFile);

                    // If the file doesn't pass the include/exclude tests, skip it.
                    if (!IsIncluded(filename)) {
                        if(this.Verbose) {
                            Log(Level.Info, "Skipping : {0}",localFile.ToString());
                        }
                        notMatched++;
                        continue;
                    }

                    // If forced is not set then we may save ourselves some work by looking at the status flag.
                    // Otherwise, we care nothing about these statuses.

                    if (!this.Forced) {
                        int fileStatus = (stFile.Status);

                        // We try to update the status once to give StarTeam another chance.
                        if (fileStatus == starTeamStatusStatics.merge || fileStatus == starTeamStatusStatics.UNKNOWN) {
                            stFile.updateStatus(true, true);
                            fileStatus = (stFile.Status);
                        }
                        if(fileStatus == starTeamStatusStatics.merge) {
                            Log(Level.Info, "Not processing {0} as it needs Merging and Forced is not on.",stFile.toString());
                            continue;
                        }
                        if (fileStatus == starTeamStatusStatics.CURRENT) {
                            //count files not processed so we can inform later
                            notProcessed++;
                            continue;
                        }
                    }

                    //may want to offer this to be surpressed but usually it is a good idea to have
                    //in the build log what changed for that build.
                    Log(Level.Info, "Checking In: {0}", localFile.ToString());

                    //check in anything else
                    stFile.checkinFrom(localFile.FullName, _comment, _lockStatus, true, true, true);

                    _updateLabel(stFile);

                    //track files affected for non-verbose output
                    _filesAffected++;
                }

                //if we are being verbose emit count of files not processed 
                if(this.Verbose) {
                    if(notProcessed > 0) 
                        Log(Level.Info, "{0} : {1} files not processed because they were current.",
                            targetFolder.FullName, notProcessed.ToString());
                    if(notMatched > 0) 
                        Log(Level.Info, "{0} : {1} files not processed because they did not match includes/excludes.",
                            targetFolder.FullName, notMatched.ToString());
                }

                // Now we recursively call this method on all sub folders in this
                // folder unless recursive attribute is off.
                foreach (InterOpStarTeam.StFolder stFolder in starteamFolder.SubFolders) {
                    FileInfo targetSubfolder = new FileInfo(stFolder.Path);
                    delistLocalFile(localFiles, targetSubfolder);

                    if (this.recursive) {
                        visit(stFolder, targetSubfolder);
                    }
                }
                if (_addUncontrolled) {
                    addUncontrolledItems(localFiles, starteamFolder);
                }
            } catch (IOException ex) {
                throw new BuildException(ex.Message, Location, ex);
            }
        }
コード例 #3
0
        /// <summary> 
        /// Implements base-class abstract function to perform the checkout operation on the files in each folder of the tree.
        /// </summary>
        /// <param name="starteamFolder">the StarTeam folder from which files to be checked out</param>
        /// <param name="targetFolder">the local mapping of the starteam folder</param>
        protected override void visit(InterOpStarTeam.StFolder starteamFolder, FileInfo targetFolder) {           
            int notProcessed = 0;
            int notMatched = 0;

            try {
                System.Collections.Hashtable localFiles = listLocalFiles(targetFolder);

                // If we have been told to create the working folders
                if (_createDirs) {
                    // Create if it doesn't exist
                    bool tmpBool;
                    if (File.Exists(targetFolder.FullName))
                        tmpBool = true;
                    else
                        tmpBool = Directory.Exists(targetFolder.FullName);
                    if (!tmpBool) {
                        Directory.CreateDirectory(targetFolder.FullName);
                    }
                }
                // For all Files in this folder, we need to check
                // if there have been modifications.
                foreach(InterOpStarTeam.StFile stFile in starteamFolder.getItems("File")) {
                    string filename = stFile.Name;
                    FileInfo localFile = new FileInfo(Path.Combine(targetFolder.FullName, filename));

                    delistLocalFile(localFiles, localFile);

                    // If the file doesn't pass the include/exclude tests, skip it.
                    if (!IsIncluded(filename)) {
                        Log(Level.Verbose, "Skipping '{0}'", localFile.ToString());
                        notMatched++;
                        continue;
                    }

                    // If forced is not set then we may save ourselves some work by
                    // looking at the status flag.
                    // Otherwise, we care nothing about these statuses.

                    if (!this.Forced) {
                        int fileStatus = (stFile.Status);

                        // We try to update the status once to give StarTeam
                        // another chance.
                        if (fileStatus == starTeamStatusStatics.merge || fileStatus == starTeamStatusStatics.UNKNOWN) {
                            stFile.updateStatus(true, true);
                            fileStatus = (stFile.Status);
                        }
                        if(fileStatus == starTeamStatusStatics.merge || fileStatus == starTeamStatusStatics.Modified) {
                            Log(Level.Info, "Not processing '{0}' as it is"
                                + " modified or needs merging and \"forced\""
                                + " attribute is not set.", stFile.toString());
                            continue;
                        }
                        if (fileStatus == starTeamStatusStatics.CURRENT) {
                            //count files not processed so we can inform later
                            notProcessed++;
                            continue;
                        }
                        //TODO merged files get processed. We may want to provide a flag to allow merges to be skipped as well
                        //this would help prevent accidental overwrites 
                    }

                    // <wisdom source="from the Ant">
                    // Check out anything else.
                    // Just a note: StarTeam has a status for NEW which implies
                    // that there is an item  on your local machine that is not
                    // in the repository.  These are the items that show up as
                    // NOT IN VIEW in the Starteam GUI.
                    // One would think that we would want to perhaps checkin the
                    // NEW items (not in all cases! - Steve Cohen 15 Dec 2001)
                    // Unfortunately, the sdk doesn't really work, and we can't
                    // actually see  anything with a status of NEW. That is why
                    // we can just check out  everything here without worrying
                    // about losing anything.
                    // </wisdom>

                    //may want to offer this to be surpressed but usually it is a good idea to have
                    //in the build log what changed for that build.

                    //debug to skip build files- remove this after include/exclude is added
                    if(localFile.FullName.IndexOf(".build") > 0)
                        continue;

                    Log(Level.Info, "Checking out '{0}'", localFile.ToString());

                    stFile.checkoutTo(localFile.FullName, _lockStatus, true, true, true);
                    _filesAffected++;
                }

                //if we are being verbose emit count of files not processed 
                if(this.Verbose) {
                    if(notProcessed > 0) 
                        Log(Level.Info, "{0} : {1} files not processed because they were current.",
                            targetFolder.FullName, notProcessed.ToString());
                    if(notMatched > 0) 
                        Log(Level.Info, "{0} : {1} files not processed because they did not match includes/excludes.",
                            targetFolder.FullName,notMatched.ToString());
                }

                // Now we recursively call this method on all sub folders in this
                // folder unless recursive attribute is off.
                foreach (InterOpStarTeam.StFolder stFolder in starteamFolder.SubFolders) {
                    FileInfo targetSubfolder = new FileInfo(stFolder.Path);
                    delistLocalFile(localFiles, targetSubfolder);
                    if (this.recursive) {
                        visit(stFolder, targetSubfolder);
                    }
                }

                if (_deleteUncontrolled) {
                    deleteUncontrolledItems(localFiles);
                }
            } catch (IOException e) {
                throw new BuildException(e.Message,Location,e);
            }
        }