Ejemplo n.º 1
0
        private void DiffByLabel(IVSSItem ssItem)
        {
            bool startLogging = false;
            bool stopLogging  = false;

            string user = User != null?User.ToLower(CultureInfo.InvariantCulture)
                              : null;

            foreach (IVSSVersion version in ssItem.get_Versions(VersionFlags))
            {
                // VSS returns the versions in descending order, meaning the
                // most recent versions appear first.
                if (ToLabel == null || version.Action.StartsWith(string.Format("Labeled '{0}'", ToLabel)))
                {
                    startLogging = true;
                }
                if (FromLabel != null && version.Action.StartsWith(string.Format("Labeled '{0}'", FromLabel)))
                {
                    stopLogging = true;
                }
                if (startLogging && !stopLogging)
                {
                    // if user was specified, then skip changes that were not
                    // performed by that user
                    if (user != null && version.Username.ToLower(CultureInfo.InvariantCulture) != user)
                    {
                        continue;
                    }

                    LogChange(version);
                }
            }
        }
Ejemplo n.º 2
0
        private void DiffByDate(IVSSItem ssItem)
        {
            bool startLogging = false;
            bool stopLogging  = false;

            string user = User != null?User.ToLower(CultureInfo.InvariantCulture)
                              : null;

            foreach (IVSSVersion version in ssItem.get_Versions(VersionFlags))
            {
                // VSS returns the versions in descending order, meaning the
                // most recent versions appear first.
                if (ToDate == DateTime.MinValue || version.Date <= ToDate)
                {
                    startLogging = true;
                }
                if (FromDate != DateTime.MinValue && FromDate > version.Date)
                {
                    stopLogging = true;
                }
                if (startLogging && !stopLogging)
                {
                    // if user was specified, then skip changes that were not
                    // performed by that user
                    if (user != null && version.Username.ToLower(CultureInfo.InvariantCulture) != user)
                    {
                        continue;
                    }

                    LogChange(version);
                }
            }
        }
Ejemplo n.º 3
0
    static void Main(string[] args)
    {
        //Environment.CurrentDirectory = @"c:\Program Files (x86)\Microsoft Visual SourceSafe Upgrade";
        IVSSDatabase db = new VSSDatabase();

        db.Open(@"ThePath\srcsafe.ini", "Admin", "ThePassword");
        IVSSItem rootFolder = db.get_VSSItem("$/", false);
        var      versions   = new List <VersionInfo>();

        foreach (IVSSVersion item in rootFolder.get_Versions((int)Microsoft.VisualStudio.SourceSafe.Interop.VSSFlags.VSSFLAG_RECURSYES))
        {
            versions.Add(new VersionInfo()
            {
                ItemName          = item.VSSItem.Name,
                ItemFullPath      = item.VSSItem.Spec,
                ItemVersionDate   = item.Date,
                ItemVersionNumber = item.VersionNumber
            });
        }
        // echo all
        var versionInfo = versions.OrderByDescending(i => i.ItemVersionDate).First();

        Console.WriteLine("{0} {1}", versionInfo.ItemFullPath, versionInfo.ItemVersionDate);
        Console.ReadLine();
    }
Ejemplo n.º 4
0
        private static void BuildRevisionList(IVSSItem item)
        {
            IVSSVersions versions = item.get_Versions(0);

            foreach (IVSSVersion version in versions)
            {
                try
                {
                    if (version.VSSItem.Deleted)
                    {
                        if (version == versions[versions.Count - 1])
                        {
                            AddRevision(version, true);
                        }
                    }

                    /*if (item.Type == (int) VSSItemType.VSSITEM_PROJECT)
                     * {
                     *  if (projList.Exists(proj => string.Compare(proj.Spec, item.Spec, true) == 0))
                     *  {
                     *      //migrateLog.Debug(item.Spec + " already exists!");
                     *      continue;
                     *  }
                     *  projList.Add(item);
                     * }*/

                    AddRevision(version, false);
                }
                catch (COMException ex)
                {
                    switch ((uint)ex.ErrorCode)
                    {
                    case 0x80040000:     //version is corrupted and unavailable
                        searchLog.WarnFormat(
                            "Skipping version due to corruption {0} in file {1} [cannot read resource]",
                            version.VersionNumber, item.Spec);
                        continue;

                    case 0x8004D68F:     //file not found
                        searchLog.WarnFormat("Skipping version due to corruption {0} in file {1} [file not found]",
                                             version.VersionNumber, item.Spec);
                        continue;

                    default:
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        protected void ItemDiff(IVSSItem ssItem)
        {
            if (this.Verbose)
            {
                Log(Level.Info, "Processing item " + ssItem.Name);
            }
            bool addVersion = true;

            foreach (IVSSVersion version in ssItem.get_Versions(0))
            {
                // VSS returns the versions in descending order, meaning the
                // most recent versions appear first.
                string action = version.Action;

                // We found our version so stop adding versions to our list
                if (action.StartsWith("Labeled '" + _label + "'"))
                {
                    addVersion = false;
                    //This is a bit annoying, it would be more efficient to break
                    //out of the loop here but VSS throws an exception !%?!
                    //http://tinyurl.com/nmct
                    //break;
                }
                if (addVersion)
                {
                    // Only add versions that have been added, created or checked in.  Ignore label actions.
                    if ((action.StartsWith("Add")) || (action.StartsWith("Create")) || (action.StartsWith("Check")))
                    {
                        if (this.Verbose)
                        {
                            Log(Level.Info, "Adding: " + version.VSSItem.Name);
                        }

                        // Build our XML Element with hopefully useful information.
                        XmlElement   node   = _outputDoc.CreateElement("item");
                        XmlAttribute attrib = _outputDoc.CreateAttribute("name");
                        attrib.Value = version.VSSItem.Name;
                        node.Attributes.Append(attrib);

                        attrib       = _outputDoc.CreateAttribute("path");
                        attrib.Value = version.VSSItem.Spec;
                        node.Attributes.Append(attrib);

                        attrib       = _outputDoc.CreateAttribute("action");
                        attrib.Value = action;
                        node.Attributes.Append(attrib);

                        attrib       = _outputDoc.CreateAttribute("date");
                        attrib.Value = version.Date.ToString();
                        node.Attributes.Append(attrib);

                        attrib       = _outputDoc.CreateAttribute("version");
                        attrib.Value = version.VersionNumber.ToString();
                        node.Attributes.Append(attrib);

                        attrib       = _outputDoc.CreateAttribute("user");
                        attrib.Value = version.Username;
                        node.Attributes.Append(attrib);

                        attrib       = _outputDoc.CreateAttribute("comment");
                        attrib.Value = version.Comment;
                        node.Attributes.Append(attrib);

                        _outputDoc.ChildNodes.Item(0).AppendChild(node);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void DiffByLabel(IVSSItem ssItem)
        {
            bool startLogging = false;
            bool stopLogging = false;

            string user = User != null ? User.ToLower(CultureInfo.InvariantCulture) : null;

            foreach (IVSSVersion version in ssItem.get_Versions(VersionFlags))
            {
                // VSS returns the versions in descending order, meaning the
                // most recent versions appear first.
                if (ToLabel == null || version.Action.StartsWith(string.Format("Labeled '{0}'", ToLabel)))
                {
                    startLogging = true;
                }
                if (FromLabel != null && version.Action.StartsWith(string.Format("Labeled '{0}'", FromLabel)))
                {
                    stopLogging = true;
                }
                if (startLogging && !stopLogging)
                {
                    // if user was specified, then skip changes that were not 
                    // performed by that user
                    if (user != null && version.Username.ToLower(CultureInfo.InvariantCulture) != user)
                    {
                        continue;
                    }

                    LogChange(version);
                }
            }
        }
Ejemplo n.º 7
0
        private void DiffByDate(IVSSItem ssItem)
        {
            bool startLogging = false;
            bool stopLogging = false;

            string user = User != null ? User.ToLower(CultureInfo.InvariantCulture) : null;

            foreach (IVSSVersion version in ssItem.get_Versions(VersionFlags))
            {
                // VSS returns the versions in descending order, meaning the
                // most recent versions appear first.
                if (ToDate == DateTime.MinValue || version.Date <= ToDate)
                {
                    startLogging = true;
                }
                if (FromDate != DateTime.MinValue && FromDate > version.Date)
                {
                    stopLogging = true;
                }
                if (startLogging && !stopLogging)
                {
                    // if user was specified, then skip changes that were not 
                    // performed by that user
                    if (user != null && version.Username.ToLower(CultureInfo.InvariantCulture) != user)
                    {
                        continue;
                    }

                    LogChange(version);
                }
            }
        }
Ejemplo n.º 8
0
        private  void ItemDiff(IVSSItem ssItem)
        {
            Log.LogMessage(MessageImportance.Low, "Processing item " + ssItem.Name);

            bool addVersion = true;
            int labeledVersion = 0;
            foreach (IVSSVersion version in ssItem.get_Versions(0))
            {
                // VSS returns the versions in descending order, meaning the
                // most recent versions appear first.
                string action = version.Action;

                // We found our version so stop adding versions to our list
                if (action.StartsWith("Labeled '" + _label + "'", StringComparison.InvariantCultureIgnoreCase))
                {
                    labeledVersion = version.VersionNumber;
                    addVersion = false;
                    //This is a bit annoying, it would be more efficient to break
                    //out of the loop here but VSS throws an exception !%?!
                    //http://tinyurl.com/nmct
                    //break;
                }
                if (addVersion == true)
                {
                    // Only add versions that have been added,created or checked in.  Ignore label actions.
                    if ((action.StartsWith("Add")) || (action.StartsWith("Create")) || (action.StartsWith("Check")))
                    {
                        Log.LogMessage(MessageImportance.Low, "Adding: " + version.VSSItem.Name);

                        // Build our XML Element with hopefully useful information.
                        XmlElement node = _outputDoc.CreateElement("item");
                        XmlAttribute attrib = _outputDoc.CreateAttribute("name");
                        attrib.Value = version.VSSItem.Name;
                        node.Attributes.Append(attrib);

                        attrib = _outputDoc.CreateAttribute("path");
                        attrib.Value = version.VSSItem.Spec;
                        node.Attributes.Append(attrib);

                        attrib = _outputDoc.CreateAttribute("action");
                        attrib.Value = action;
                        node.Attributes.Append(attrib);

                        attrib = _outputDoc.CreateAttribute("date");
                        attrib.Value = version.Date.ToString();
                        node.Attributes.Append(attrib);

                        attrib = _outputDoc.CreateAttribute("version");
                        attrib.Value = version.VersionNumber.ToString();
                        node.Attributes.Append(attrib);

                        attrib = _outputDoc.CreateAttribute("user");
                        attrib.Value = version.Username;
                        node.Attributes.Append(attrib);

                        attrib = _outputDoc.CreateAttribute("comment");
                        attrib.Value = version.Comment;
                        node.Attributes.Append(attrib);

                        _outputDoc.ChildNodes.Item(0).AppendChild(node);
                    }
                }
            }
        }