예제 #1
0
        public void testObjectMovedWithinPack()
        {
            // Create an object and pack it.
            //
            Core.Repository eden = createBareRepository();
            RevObject       o1   = WriteBlob(eden, "o1");

            FileInfo[] out1 = Pack(eden, o1);
            Assert.AreEqual(o1.Name, Parse(o1).Name);

            // Force close the old pack.
            //
            WhackCache();

            // Now overwrite the old pack in place. This method of creating a
            // different pack under the same file name is partially broken. We
            // should also have a different file name because the list of objects
            // within the pack has been modified.
            //
            RevObject o2 = WriteBlob(eden, "o2");
            var       pw = new PackWriter(eden, NullProgressMonitor.Instance);

            pw.addObject(o2);
            pw.addObject(o1);
            Write(out1, pw);

            // Try the old name, then the new name. The old name should cause the
            // pack to reload when it opens and the index and pack mismatch.
            //
            Assert.AreEqual(o1.Name, Parse(o1).Name);
            Assert.AreEqual(o2.Name, Parse(o2).Name);
        }
예제 #2
0
        private FileInfo[] Pack(Core.Repository src, params RevObject[] list)
        {
            var pw = new PackWriter(src, NullProgressMonitor.Instance);

            foreach (RevObject o in list)
            {
                pw.addObject(o);
            }

            ObjectId name     = pw.computeName();
            FileInfo packFile = FullPackFileName(name);
            FileInfo idxFile  = FullIndexFileName(name);
            var      files    = new[] { packFile, idxFile };

            Write(files, pw);
            return(files);
        }
예제 #3
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();
            }
        }
예제 #4
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();
            }
        }
예제 #5
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();
            }
        }
예제 #6
0
        private FileInfo[] Pack(Core.Repository src, params RevObject[] list)
        {
            var pw = new PackWriter(src, NullProgressMonitor.Instance);
            foreach (RevObject o in list)
            {
                pw.addObject(o);
            }

            ObjectId name = pw.computeName();
			FileInfo packFile = FullPackFileName(name);
            FileInfo idxFile = FullIndexFileName(name);
            var files = new[] { packFile, idxFile };
            Write(files, pw);
            return files;
        }
예제 #7
0
        public void testObjectMovedWithinPack()
        {
            // Create an object and pack it.
            //
            Core.Repository eden = createBareRepository();
            RevObject o1 = WriteBlob(eden, "o1");
            FileInfo[] out1 = Pack(eden, o1);
            Assert.AreEqual(o1.Name, Parse(o1).Name);

            // Force close the old pack.
            //
            WhackCache();

            // Now overwrite the old pack in place. This method of creating a
            // different pack under the same file name is partially broken. We
            // should also have a different file name because the list of objects
            // within the pack has been modified.
            //
            RevObject o2 = WriteBlob(eden, "o2");
            var pw = new PackWriter(eden, NullProgressMonitor.Instance);
            pw.addObject(o2);
            pw.addObject(o1);
            Write(out1, pw);

            // Try the old name, then the new name. The old name should cause the
            // pack to reload when it opens and the index and pack mismatch.
            //
            Assert.AreEqual(o1.Name, Parse(o1).Name);
            Assert.AreEqual(o2.Name, Parse(o2).Name);
        }