Multiplexes data and progress messages. This stream is buffered at packet sizes, so the caller doesn't need to wrap it in yet another buffered stream.
Inheritance: Stream
Ejemplo n.º 1
0
		public void testWrite_CH_PROGRESS()
		{
			SideBandOutputStream o;
			o = new SideBandOutputStream(SideBandOutputStream.CH_PROGRESS, SideBandOutputStream.SMALL_BUF, rawOut);
			byte[] b = new byte[] { (byte)'a', (byte)'b', (byte)'c' };
			o.Write(b, 0, b.Length);
			o.Flush();
			assertBuffer("0008\x02" + "abc");
		}
Ejemplo n.º 2
0
        private void SendPack()
        {
            bool thin     = _options.Contains(OptionThinPack);
            bool progress = !_options.Contains(OptionNoProgress);
            bool sideband = _options.Contains(OptionSideBand) || _options.Contains(OptionSideBand64K);

            ProgressMonitor pm       = NullProgressMonitor.Instance;
            Stream          _packOut = _rawOut;

            if (sideband)
            {
                int bufsz = SideBandOutputStream.SMALL_BUF;
                if (_options.Contains(OptionSideBand64K))
                {
                    bufsz = SideBandOutputStream.MAX_BUF;
                }

                _packOut = new SideBandOutputStream(SideBandOutputStream.CH_DATA, bufsz, _rawOut);

                if (progress)
                {
                    pm = new SideBandProgressMonitor(new SideBandOutputStream(SideBandOutputStream.CH_PROGRESS, bufsz, _rawOut));
                }
            }

            var pw = new PackWriter(_db, pm, NullProgressMonitor.Instance)
            {
                DeltaBaseAsOffset = _options.Contains(OptionOfsDelta),
                Thin = thin
            };

            pw.preparePack(_wantAll, _commonBase);
            if (_options.Contains(OptionIncludeTag))
            {
                foreach (Ref r in _refs.Values)
                {
                    RevObject o;
                    try
                    {
                        o = _walk.parseAny(r.ObjectId);
                    }
                    catch (IOException)
                    {
                        continue;
                    }
                    RevTag t = (o as RevTag);
                    if (o.has(WANT) || (t == null))
                    {
                        continue;
                    }

                    if (!pw.willInclude(t) && pw.willInclude(t.getObject()))
                    {
                        pw.addObject(t);
                    }
                }
            }

            pw.writePack(_packOut);

            if (sideband)
            {
                _packOut.Flush();
                _pckOut.End();
            }
            else
            {
                _rawOut.Flush();
            }
        }
Ejemplo n.º 3
0
		public void testWrite_Large()
		{
			const int buflen = SideBandOutputStream.MAX_BUF - SideBandOutputStream.HDR_SIZE;
			byte[] buf = new byte[buflen];
			for (int i = 0; i < buf.Length; i++)
				buf[i] = (byte)i;

			SideBandOutputStream o;
			o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, SideBandOutputStream.MAX_BUF, rawOut);
			o.Write(buf, 0, buf.Length);
			o.Flush();
			byte[] act = rawOut.ToArray();
			string explen = NB.DecimalToBase(buf.Length + SideBandOutputStream.HDR_SIZE, 16);
			Assert.AreEqual(SideBandOutputStream.HDR_SIZE + buf.Length, act.Length);
			Assert.AreEqual(Charset.forName("UTF-8").GetString(act, 0, 4), explen);
			Assert.AreEqual(1, act[4]);
			for (int i = 0, j = SideBandOutputStream.HDR_SIZE; i < buf.Length; i++, j++)
				Assert.AreEqual(buf[i], act[j]);
		}
Ejemplo n.º 4
0
		public void testWrite_SmallBlocks3()
		{
			SideBandOutputStream o;
			o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, 7, rawOut);
			o.WriteByte((byte)'a');
			o.Write(new byte[] { (byte)'b', (byte)'c' }, 0, 2);
			o.Flush();
			assertBuffer("0007\x01" + "ab0006\x01" + "c");
		}
Ejemplo n.º 5
0
		public void testWrite_SmallBlocks1()
		{
			SideBandOutputStream o;
			o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, 6, rawOut);
			o.WriteByte((byte)'a');
			o.WriteByte((byte)'b');
			o.WriteByte((byte)'c');
			o.Flush();
			assertBuffer("0006\x01" + "a0006\x01" + "b0006\x01" + "c");
		}
Ejemplo n.º 6
0
		public void testWrite_Small()
		{
			SideBandOutputStream o;
			o = new SideBandOutputStream(SideBandOutputStream.CH_DATA, SideBandOutputStream.SMALL_BUF, rawOut);
			o.WriteByte((byte)'a');
			o.WriteByte((byte)'b');
			o.WriteByte((byte)'c');
			o.Flush();
			assertBuffer("0008\x01" + "abc");
		}
Ejemplo n.º 7
0
        private void SendPack()
        {
            bool thin = _options.Contains(OptionThinPack);
            bool progress = !_options.Contains(OptionNoProgress);
            bool sideband = _options.Contains(OptionSideBand) || _options.Contains(OptionSideBand64K);

            ProgressMonitor pm = NullProgressMonitor.Instance;
            Stream _packOut = _rawOut;

            if (sideband)
            {
                int bufsz = SideBandOutputStream.SMALL_BUF;
                if (_options.Contains(OptionSideBand64K))
                {
                    bufsz = SideBandOutputStream.MAX_BUF;
                }

                _packOut = new SideBandOutputStream(SideBandOutputStream.CH_DATA, bufsz, _rawOut);

                if (progress)
                    pm = new SideBandProgressMonitor(new SideBandOutputStream(SideBandOutputStream.CH_PROGRESS, bufsz, _rawOut));
            }

            var pw = new PackWriter(_db, pm, NullProgressMonitor.Instance)
                        {
                            DeltaBaseAsOffset = _options.Contains(OptionOfsDelta),
                            Thin = thin
                        };

            pw.preparePack(_wantAll, _commonBase);
            if (_options.Contains(OptionIncludeTag))
            {
                foreach (Ref r in _refs.Values)
                {
                    RevObject o;
                    try
                    {
                        o = _walk.parseAny(r.ObjectId);
                    }
                    catch (IOException)
                    {
                        continue;
                    }
                    RevTag t = (o as RevTag);
                    if (o.has(WANT) || (t == null)) continue;

                    if (!pw.willInclude(t) && pw.willInclude(t.getObject()))
                        pw.addObject(t);
                }
            }

            pw.writePack(_packOut);

            if (sideband)
            {
                _packOut.Flush();
                _pckOut.End();
            }
            else
            {
                _rawOut.Flush();
            }
        }
Ejemplo n.º 8
0
 public void testWrite_CH_ERROR()
 {
     SideBandOutputStream o;
     o = new SideBandOutputStream(SideBandOutputStream.CH_ERROR, pckOut);
     byte[] b = new byte[] { (byte)'a', (byte)'b', (byte)'c' };
     o.Write(b, 0, b.Length);
     assertBuffer("0008\x03" + "abc");
 }