예제 #1
0
		public void Import()
		{
			m_stream = OpenOutput();

			try
			{
				bool printProgress = !Console.IsOutputRedirected;
				int totalCommits = m_player.Count;
				var progress = new ImportProgress(totalCommits);

				var stopWatch = new Stopwatch();
				stopWatch.Start();

				using (m_log.Indent())
				{
					int count = 0;
					Commit lastMainCommit = null;
					foreach (var commit in m_player.Play())
					{
						ImportCommit(commit);

						if (commit.Branch == "MAIN")
							lastMainCommit = commit;

						count++;
						if (printProgress)
							progress.Update(stopWatch.Elapsed, count);
					}

					if (printProgress)
						Console.Out.WriteLine();

					ImportTags();

					if (lastMainCommit != null && m_config.MarkerTag != null)
						ImportTag(m_config.MarkerTag, lastMainCommit);
				}

				m_log.WriteLine();
				m_log.WriteLine("Imported {0} commits", totalCommits);
				m_log.WriteLine("Imported {0} tags", m_tags.Count);
				m_log.WriteLine();
			}
			catch (IOException ioe)
			{
				// if the error is broken pipe, then catch the exception - we should get an error in
				// GitRepo.EndImport in the finally block below
				if ((ioe.HResult & 0xffff) == (int)WinError.BrokenPipe)
					m_brokenPipe = true;
				else
					throw;
			}
			finally
			{
				CloseOutput();
			}
		}
예제 #2
0
        public void Import()
        {
            m_stream = OpenOutput();

            try
            {
                bool printProgress = !Console.IsOutputRedirected;
                int  totalCommits  = m_player.Count;
                var  progress      = new ImportProgress(totalCommits);

                var stopWatch = new Stopwatch();
                stopWatch.Start();

                using (m_log.Indent())
                {
                    int    count          = 0;
                    Commit lastMainCommit = null;
                    foreach (var commit in m_player.Play())
                    {
                        ImportCommit(commit);

                        if (commit.Branch == "MAIN")
                        {
                            lastMainCommit = commit;
                        }

                        count++;
                        if (printProgress)
                        {
                            progress.Update(stopWatch.Elapsed, count);
                        }
                    }

                    if (printProgress)
                    {
                        Console.Out.WriteLine();
                    }

                    ImportTags();

                    if (lastMainCommit != null && m_config.MarkerTag != null)
                    {
                        ImportTag(m_config.MarkerTag, lastMainCommit);
                    }
                }

                m_log.WriteLine();
                m_log.WriteLine("Imported {0} commits", totalCommits);
                m_log.WriteLine("Imported {0} tags", m_tags.Count);
                m_log.WriteLine();
            }
            catch (IOException ioe)
            {
                // if the error is broken pipe, then catch the exception - we should get an error in
                // GitRepo.EndImport in the finally block below
                if ((ioe.HResult & 0xffff) == (int)WinError.BrokenPipe)
                {
                    m_brokenPipe = true;
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                CloseOutput();
            }
        }