Beispiel #1
0
        private void sendPack()
        {
            bool thin = options.Contains(OPTION_THIN_PACK);
            bool progress = !options.Contains(OPTION_NO_PROGRESS);
            bool sideband = options.Contains(OPTION_SIDE_BAND) || options.Contains(OPTION_SIDE_BAND_64K);

            ProgressMonitor pm = new NullProgressMonitor();
            Stream packOut = stream;

            if (sideband)
            {
                int bufsz = SideBandOutputStream.SMALL_BUF;
                if (options.Contains(OPTION_SIDE_BAND_64K))
                    bufsz = SideBandOutputStream.MAX_BUF;
                bufsz -= SideBandOutputStream.HDR_SIZE;

                packOut = new BufferedStream(new SideBandOutputStream(SideBandOutputStream.CH_DATA, pckOut), bufsz);

                if (progress)
                    pm = new SideBandProgressMonitor(pckOut);
            }

            PackWriter pw;
            pw = new PackWriter(db, pm, new NullProgressMonitor());
            pw.DeltaBaseAsOffset = options.Contains(OPTION_OFS_DELTA);
            pw.Thin = thin;
            pw.preparePack(wantAll, commonBase);
            if (options.Contains(OPTION_INCLUDE_TAG))
            {
                foreach (Ref r in refs.Values)
                {
                    RevObject o;
                    try
                    {
                        o = walk.parseAny(r.ObjectId);
                    }
                    catch (IOException)
                    {
                        continue;
                    }
                    if (o.has(WANT) || !(o is RevTag))
                        continue;
                    RevTag t = (RevTag) o;
                    if (!pw.willInclude(t) && pw.willInclude(t.getObject()))
                        pw.addObject(t);
                }
            }
            pw.writePack(packOut);

            if (sideband)
            {
                packOut.Flush();
                pckOut.End();
            }
            else
            {
                stream.Flush();
            }
        }
Beispiel #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;
                }
                bufsz -= SideBandOutputStream.HDR_SIZE;

                packOut = new BufferedStream(new SideBandOutputStream(SideBandOutputStream.CH_DATA, _pckOut), bufsz);

                if (progress)
                    pm = new SideBandProgressMonitor(_pckOut);
            }

            var pw = new PackWriter(_db, pm, new NullProgressMonitor())
                        {
                            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;
                    }
                    if (o.has(WANT) || !(o is RevTag)) continue;

                    var t = (RevTag)o;
                    if (!pw.willInclude(t) && pw.willInclude(t.getObject()))
                        pw.addObject(t);
                }
            }

            pw.writePack(packOut);

            if (sideband)
            {
                packOut.Flush();
                _pckOut.End();
            }
            else
            {
                _rawOut.Flush();
            }
        }