summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
Commit message (Collapse)AuthorAgeFilesLines
* Add a public RevTag.parse() methodShawn O. Pearce2010-08-201-0/+20
| | | | | | | | | | Callers might have a canonical tag encoding on hand that they wish to convert into a clean structure for presentation purposes, and the object may not be available in a repository. (E.g. maybe its a "draft" tag being written in an editor.) Change-Id: I387a462afb70754aa7ee20891e6c0262438fdf32 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Add a public RevCommit.parse() methodShawn O. Pearce2010-08-201-0/+21
| | | | | | | | | | Callers might have a canonical commit encoding on hand that they wish to convert into a clean structure for presentation purposes, and the object may not be available in a repository. (E.g. maybe its a "draft" commit being written in an editor.) Change-Id: I21759cff337cbbb34dbdde91aec5aa4448a1ef37 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Make Tag class only for writingShawn O. Pearce2010-08-201-85/+48
| | | | | | | | | | The Tag class now only supports the creation of an annotated tag object. To read an annotated tag, applictions should use RevTag. This permits us to have exactly one implementation, and RevTag's is faster and more bug-free. Change-Id: Ib573f7e15f36855112815269385c21dea532e2cf Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Make Commit class only for writingShawn O. Pearce2010-08-205-72/+99
| | | | | | | | | | The Commit class now only supports the creation of a commit object. To read a commit, applictions should use RevCommit. This permits us to have exactly one implementation, and RevCommit's is faster and more bug-free. Change-Id: Ib573f7e15f36855112815269385c21dea532e2cf Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Fix ReadTreeTests to not rely on cached indexChristian Halstrick2010-08-202-1/+7
| | | | | | | | | | | ReadTreeTests relied on Repository.getIndex() which on platforms which coarse FileSystemTimers failed to detect index modifications. By explicitly reloading and writing the index this problem is solved. Change-Id: I0a98babfc2068a3b6b7d2257834988e1154f5b26 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Remove unnecessary ObjectId.copy() callsShawn O. Pearce2010-08-193-6/+6
| | | | | | | | | | | | | | | | | | | | When RevObject overrode equals() to provide only reference equality we used to need to convert a RevObject into an ObjectId by copy() just to use standard Java tools like JUnit assertEquals(), or to use contains() or get() on standard java.util collection types. Now that we have removed this override and made ObjectId's equals() final (preventing any of this mess in the future), some copy() calls are unnecessary. Anytime the value is being used as an input to a lookup routine, or to an equals, we can avoid the copy(). However we still want to use copy() anytime we are given an ObjectId that may exist long-term, where we don't want the high cost of the additional storage from a RevCommit extension. So we can't remove all uses of copy(), just some of them. Change-Id: Ief275dace435c0ddfa362ac8e5d93558bc7e9fc3 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Fix missing Configuration Change eventingMathias Kinzler2010-08-192-1/+83
| | | | | | | | | Configuration change events were not being triggered, now they are forwarded from the FileConfig up to the Repository's listeners. Change-Id: Ida94a59f5a2b7fa8ae0126e33c13343275483ee5 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Remove getter and setter for author in TagChris Aniszczyk2010-08-181-9/+10
| | | | | | | | | There was a duplicated getter and setter for tagger in Tag. There's no needed to have two getters and setters that represent the same things. The appropriate tests were updated also. Change-Id: If46dc00c4c0f31ea4234c6d3bda3c03e6ebbafac Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Add blob-data to utility method indexState()Christian Halstrick2010-08-183-66/+68
| | | | | | | | | | indexState() encodes the complete state of the index into one readable String. This helps to write tests against the index. indexState() is enhanced to optionally also contain the content of the files in the index. Change-Id: Ie988f93768d864f4cbd55809a786bd5759fc24a5 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* added resetIndex() to RepositoryTestCaseChristian Halstrick2010-08-182-23/+46
| | | | | | | | | | | | Added a utility method to set the reset an index to match exactly some content in the filesystem. This can be used by tests to prepare commits in the working-tree and set the index in one shot. [sp: Cleaned up formatting, added getEntryFile(), released inserter.] Change-Id: If38b1f7cacaaf769f51b14541c5da0c1e24568a5 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Merge "Backout RevObject's object-identity based equals implementation"Shawn Pearce2010-08-181-5/+5
|\
| * Backout RevObject's object-identity based equals implementationMatthias Sohn2010-08-151-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This restores the transitivity and symmetry properties of the equals methods on the AnyObjectId type hierarchy as defined in [1]. Following [2] we declare these equals methods final to ensure that semantics of equals are consistent across AnyObjectId's type hierarchy. [1] http://download-llnw.oracle.com/javase/6/docs/api/java/lang/Object.html#equals(java.lang.Object) [2] http://www.angelikalanger.com/Articles/JavaSolutions/SecretsOfEquals/Equals.html Bug: 321502 Change-Id: Ibace21fa268c4aa15da6c65d42eb705ab1aa24b3 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Set default file encoding used for JGit tests to UTF-8Matthias Sohn2010-08-161-0/+1
|/ | | | | | | | | | | | | | | This patch fixes the problem that JGit tests run from Maven fail on Mac OS X [1]. In Eclipse the tests succeed since we set Eclipse workspace encoding to UTF-8 via "Preferences > General > Workspace > Text file encoding", checked via JConsole that this setting changes the JVM system property of the test run. This change copies this setting to the Maven test environment so that we get consistent test results on all platforms. [1] http://kerneltrap.org/mailarchive/git/2009/2/6/4916414/thread Change-Id: Ia657d4037c518411f7bc3c75626dbafb1f4706a2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Hide Maven target directories from EclipseRobin Rosenberg2010-08-081-0/+11
| | | | | Change-Id: I64f12a35423a90ced9c9bc83f6869d8ed766dd35 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Merge branch 'rename-bug'Shawn O. Pearce2010-08-061-1/+4
|\ | | | | | | | | | | | | | | | | | | * rename-bug: Fix ArrayIndexOutOfBounds on non-square exact rename matrix Conflicts: org.eclipse.jgit/src/org/eclipse/jgit/diff/RenameDetector.java Change-Id: Ie0b8dd3e1ec174f79ba39dc4706bb0694cc8be29
| * Fix ArrayIndexOutOfBounds on non-square exact rename matrixShawn O. Pearce2010-08-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | If the exact rename matrix for a particular ObjectId isn't square we crashed with an ArrayIndexOutOfBoundsException because the matrix entries were encoded backwards. The encode function accepts the source (aka deleted) index first, not second. Add a unit test to cover this non-square case to ensure we don't have this regression in the future. Change-Id: I5b005e5093e1f00de2e3ec104e27ab6820203566 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | Merge changes I39bfefee,I47795987,I70d120fb,I58cc5e01,I96bee7b9Shawn O. Pearce2010-08-051-15/+31
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | * changes: Enable configuration of non-standard pack settings Pass PackConfig down to PackWriter when packing Simplify UploadPack use of options during writing Move PackWriter configuration to PackConfig Allow PackWriter callers to manage the thread pool
| * | Move PackWriter configuration to PackConfigShawn O. Pearce2010-07-281-15/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This refactoring permits applications to configure global per-process settings for all packing and easily pass it through to per-request PackWriters, ensuring that the process configuration overrides the repository specific settings. For example this might help in a daemon environment where the server wants to cap the resources used to serve a dynamic upload pack request, even though the repository's own pack.* settings might be configured to be more aggressive. This allows fast but less bandwidth efficient serving of clients, while still retaining good compression through a cron managed `git gc`. Change-Id: I58cc5e01b48924b1a99f79aa96c8150cdfc50846 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | | Merge "Add "all" parameter to the commit Command"Chris Aniszczyk2010-08-051-0/+34
|\ \ \
| * | | Add "all" parameter to the commit CommandStefan Lay2010-08-041-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the add parameter is set all modified and deleted files are staged prior to commit. Change-Id: Id23bc25730fcdd151386cd495a7cdc0935cbc00b Signed-off-by: Stefan Lay <stefan.lay@sap.com>
* | | | Merge "Add the parameter "update" to the Add command"Chris Aniszczyk2010-08-052-72/+173
|\| | |
| * | | Add the parameter "update" to the Add commandStefan Lay2010-08-042-72/+173
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change is mainly done for a subsequent commit which will introduce the "all" parameter to the Commit command. Bug: 318439 Change-Id: I85a8a76097d0197ef689a289288ba82addb92fc9 Signed-off-by: Stefan Lay <stefan.lay@sap.com>
* | | | Merge "add fsTick() to RepositoryTestCase"Chris Aniszczyk2010-08-052-32/+36
|\| | |
| * | | add fsTick() to RepositoryTestCaseChristian Halstrick2010-08-042-32/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An utility method which was in RacyGitTests has been moved to RepositoryTestCase. Also the javadoc has been improved. This method allows to wait long enough until the filesystem-timer has advanced. This is useful when it has to be guaranteed that two files modifications have different modification timestamps. Change-Id: I2ebd7cd7818feba6acffb3f835101d8fd281bd5a Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* | | | Merge "add more control to indexState() return-value"Chris Aniszczyk2010-08-052-52/+84
|\| | |
| * | | add more control to indexState() return-valueChristian Halstrick2010-08-042-52/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The indexState() method was enhanced to be more configurable. A bitmask controls which of the optional parts are reported. All data about the worktree is not reported anymore by this method which makes the interface more cleaner for users wanting to test only the state of the index. This was done because the previous version reported always so much additional data that it was hard to write good assertions against it. Change-Id: I9b481e97f8fcf3fcdbb785b801dc07bfa85dcc33 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Stefan Lay <stefan.lay@sap.com>
* | | | Allow to replace existing Change-IdStefan Lay2010-08-051-1/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is useful to be able to replace an existing Change-Id in the message, for example if the user decides not to amend the previous commit. Bug: 321188 Change-Id: I594e7f9efd0c57d794d2bd26d55ec45f4e6a47fd Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* | | | Rename getOldName,getNewName to getOldPath,getNewPathShawn O. Pearce2010-08-046-72/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TreeWalk calls this value "path", while "name" is the stuff after the last slash. FileHeader should do the same thing to be consistent. Rename getOldName to getOldPath and getNewName to getNewPath. Bug: 318526 Change-Id: Ib2e372ad4426402d37939b48d8f233154cc637da Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | | | Merge branch 'js/diff'Shawn O. Pearce2010-08-041-0/+15
|\ \ \ \ | | |_|/ | |/| | | | | | | | | | * js/diff: Fixed bug in scoring mechanism for rename detection
| * | | Fixed bug in scoring mechanism for rename detectionJeff Schumacher2010-08-041-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A bug in rename detection would cause file scores to be wrong. The bug was due to the way rename detection would judge the similarity between files. If file A has three lines containing 'foo', and file B has 5 lines containing 'foo', the rename detection phase should record that A and B have three lines in common (the minimum of the number of times that line appears in both files). Instead, it would choose the the number of times the line appeared in the destination file, in this case file B. I fixed the bug by having the SimilarityIndex instead choose the minimum number, as it should. I also added a test case to verify that the bug had been fixed. Change-Id: Ic75272a2d6e512a361f88eec91e1b8a7c2298d6b
* | | | Add gitignore support to IndexDiff and use TreeWalkJens Baumgart2010-08-041-6/+17
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | IndexDiff was re-implemented and now uses TreeWalk instead of GitIndex. Additionally, gitignore support and retrieval of untracked files was added. Change-Id: Ie6a8e04833c61d44c668c906b161202b200bb509 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* | | Fixed FileTreeIteratorWithTimeControlStefan Lay2010-07-301-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | getEntryLastModified returned wrong values for timestamps on boundaries. Change-Id: I0457ff030946fda7ecc70671bc65db02a8c206ee Signed-off-by: Stefan Lay <stefan.lay@sap.com>
* | | Remove use of SortedSet.floor()Shawn O. Pearce2010-07-281-3/+4
| | | | | | | | | | | | | | | | | | | | | Its only available in Java 6, and JGit still supports Java 5. Change-Id: I6c8fac06106ffe20ac8b4b595f34e027f2d29cc2 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | | Add tests for racy git / Index state encodingChristian Halstrick2010-07-283-0/+414
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to test racy git situations we have to be able to control the last-modification timestamps of the filesystem. Since we already access the modification timestamps of files through an abstraction (the WorkingTreeIterator) I add a new implementation of this iterator which allows to map timestamp-ranges to single constant timestamps. For users of this iterator it looks like all files in that range have been modified at exactly the same time. With the help of this iterator a test has been writting which checkes for racy git handling (smudging, unsmudging, dirty-detection). Additionally add a method to RepositoryTestCase which encodes the current index state in one String. This should include info about pathes, file/index modtime, smudgeState, clean-state. Make sure timestamps are presented in a way that it is easy to write assertions against this strings (no concrete milliseconds but t0,t1,...). These two topics depend circulary on each other: thats why they have been squashed in one commit. Change-Id: I115c3f2f20fca9b481830bdc6b9d1ade2c3abdcf Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* | | Teach NameConflictTreeWalk to report DF conflictsChristian Halstrick2010-07-281-0/+55
| |/ |/| | | | | | | | | | | | | | | Add a method isDirectoryFileConflict() to NameConflictTreeWalk which tells whether the current path is part of a directory/file conflict. Change-Id: Iffcc7090aaec743dd6f3fd1a333cac96c587ae5d Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | Break dissimilar file pairs during diffJeff Schumacher2010-07-271-0/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | File pairs that are very dissimilar during a diff were not being broken apart into their constituent ADD/DELETE pairs. The leads to sub-optimal rename detection. Take, for example, this situation: A file exists at src/a.txt containing "foo". A user renames src/a.txt to src/b.txt, then adds a new src/a.txt containing "bar". Even though the old a.txt and the new b.txt are identical, the rename detection algorithm would not detect it as a rename since it was already paired in a MODIFY. I added code to split all MODIFYs below a certain score into their constituent ADD/DELETE pairs. This allows situations like the one I described above to be more correctly handled. Change-Id: I22c04b70581f206bbc68c4cd1ee87a1f663b418e Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | Add methods which write MERGE_HEAD and MERGE_MSGChristian Halstrick2010-07-271-0/+108
| | | | | | | | | | | | | | | | | | | | Add methods to the Repository class which write into MERGE_HEAD and MERGE_MSG files. Since we have the read methods in the same class this seems to be the right place. Change-Id: I5dd65306ceb06e008fcc71b37ca3a649632ba462 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | Fix concurrent read / write issue in LockFile on WindowsJens Baumgart2010-07-275-13/+22
| | | | | | | | | | | | | | | | | | | | LockFile.commit fails if another thread concurrently reads the base file. The problem is fixed by retrying the rename operation if it fails. Change-Id: I6bb76ea7f2e6e90e3ddc45f9dd4d69bd1b6fa1eb Bug: 308506 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
* | Fix Javadoc warningsRobin Stocker2010-07-271-1/+1
| | | | | | | | | | | | | | | | There were some broken links, incorrect uses of @value, an invalid tag and an outdated comment. Change-Id: I22886bcc869a4b62bd606ebed40669f7b4723664 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | Merge branch 'delta'Shawn O. Pearce2010-07-2249-328/+1849
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * delta: (103 commits) Discard the uncompressed delta as soon as its compressed Honor pack.windowlimit to cap memory usage during packing Honor pack.threads and perform delta search in parallel Cache small deltas during packing Implement delta generation during packing debug-show-packdelta: Dump a pack delta to the console Initial pack format delta generator Add debugging toString() method to ObjectToPack Make ObjectToPack clearReuseAsIs signal available to subclasses Correctly classify the compressing objects phase Refactor ObjectToPack's delta depth setting Configure core.bigFileThreshold into PackWriter Add doNotDelta flag to ObjectToPack Add more configuration options to PackWriter Save object path hash codes during packing Add path hash code to ObjectWalk Add getObjectSize to ObjectReader Allow TemporaryBuffer.Heap to allocate smaller than 8 KiB Define a constant for 127 in DeltaEncoder Cap delta copy instructions at 64k ... Conflicts: org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Diff.java org.eclipse.jgit/resources/org/eclipse/jgit/JGitText.properties org.eclipse.jgit/src/org/eclipse/jgit/JGitText.java org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RewriteTreeFilter.java Change-Id: I7c7a05e443a48d32c836173a409ee7d340c70796
| * | Initial pack format delta generatorShawn O. Pearce2010-07-091-0/+228
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DeltaIndex is a simple pack style delta generator. The function works by creating a compact index of a source buffer's blocks, and then walking a sliding window along a desired result buffer, searching for the window in the index. When a match is found, the window is stretched to the longest possible length that is common with the source buffer, and a copy instruction is created. Rabin's polynomial hash function is used to compute the hash for a block, permitting efficient sliding of the window in single byte increments. The update function to slide one byte originated from David Mazieres' work in LBFS, and our implementation of the update step was certainly inspired by the initial work Geert Bosch proposed for C Git in http://marc.info/?l=git&m=114565424620771&w=2. To ensure the encoder runs in linear time with respect to the size of the two input buffers (source and result), the maximum number of blocks that can share the same position in the index's hashtable is capped at a constant number. This prevents bad inputs from causing the encoder to run in quadratic time, but comes with a penalty of creating a longer delta due to fewer considered copy positions. Strange hackery is used to cap the amount of memory used by the index to be no more than 12 bytes for every 16 bytes of source buffer, no matter what the JVM per-object overhead is. This permits an index to always be no larger than 1.75x the source buffer length, which is an important feature to support large windows of candidates to match against while packing. Here the strange hackery is nothing more than a manually managed chained hashtable, where pointers are array indexes into storage arrays rather than object references. Computation of the hash function for a single fixed sized block is done through an unrolled loop, where the first 4 iterations have been manually reduced down to eliminate unnecessary instructions. The pattern is derived from ObjectId.equals(byte[], int, byte[], int), where we have unrolled the loop required to compare two 20 byte arrays. Hours of testing with the Sun 1.6 JRE concluded that the non-obvious "foo[idx + 1]" style of reference is faster than "foo[idx++]", and so that is what we use here during hashing. Change-Id: If9fb2a1524361bc701405920560d8ae752221768 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
| * | Allow TemporaryBuffer.Heap to allocate smaller than 8 KiBShawn O. Pearce2010-07-091-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the heap limit was set to something smaller than 8 KiB, we were still allocating the full 8 KiB block size, and accepting up to the amount we allocated by. Instead actually put a hard cap on the limit. Change-Id: Id1da26fde2102e76510b1da4ede8493928a981cc Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
| * | amend commit: Support large loose objects as streamsShawn O. Pearce2010-07-061-0/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need to validate the stream state after the InflaterInputStream thinks the stream is done. Git expects a higher level of service from the Inflater than the InflaterInputStream usually gives, we need to ensure the embedded CRC is valid, and that there isn't trailing garbage at the end of the file. Change-Id: I1c9642a82dbd76b69e607dceccf8b85dc869a3c1 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
| * | amend commit: Refactor repository construction to builder classShawn O. Pearce2010-07-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During code review, Alex raised a few comments about commit 532421d98925 ("Refactor repository construction to builder class"). Due to the size of the related series we aren't going to go back and rebase in something this minor, so resolve them as a follow-up commit instead. Change-Id: Ied52f7a8f7252743353c58d20bfc3ec498933e00 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
| * | Use core.streamFileThreshold to set our streaming limitShawn O. Pearce2010-07-022-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We default this to 1 MiB for now, but we allow users to modify it through the Repository's configuration file to be a different value. A new repository listener is used to identify when the setting has been updated and trigger a reconfiguration of any active ObjectReaders. To prevent a horrible explosion we cap core.streamFileThreshold at no more than 1/4 of the maximum JVM heap size. We do this because we need at least 2 byte arrays equal in size to the stream threshold for the worst case delta inflation scenario, and our host application probably also needs some amount of the heap for their working set size. Change-Id: I103b3a541dc970bbf1a6d92917a12c5a1ee34d6c Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
| * | Support large delta packed objects as streamsShawn O. Pearce2010-07-022-0/+523
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Very large delta instruction streams, or deltas which use very large base objects, are now streamed through as large objects rather than being inflated into a byte array. This isn't the most efficient way to access delta encoded content, as we may need to rewind and reprocess the base object when there was a block moved within the file, but it will at least prevent the JVM from having its heap explode. When streaming a delta we have an inflater open for each level in the delta chain, to inflate the instruction set of the delta, as well as an inflater for the base level object. The base object is buffered, as is the top level delta requested by the application, but we do not buffer the intermediate delta streams. This keeps memory usage lower, so its closer to 1024 bytes per level in the chain, without having an adverse impact on raw throughput as the top-level buffer gets pushed down to the lowest stream that has the next region. Delta instructions transparently collapse here, if the top level does not copy a region from its base, the base won't materialize that part from its own base, etc. This allows us to avoid copying around a lot of segments which have been deleted from the final version. Change-Id: I724d45245cebb4bad2deeae7b896fc55b2dd49b3 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
| * | Support large whole packed objects as streamsShawn O. Pearce2010-07-011-0/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to the loose object support, whole packed objects can now be streamed back to the caller. The streaming is less efficient as we copy the data from the cached window array into the InflaterInputStream's internal buffer, then inflate it there before returning to the application. Like with unpacked objects, there is plenty of room for some optimization, especially for the copyTo method, where we don't necessarily need so much buffering to exist. Change-Id: Ie23be81289e37e24b91d17b0891e47b9da988008 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
| * | Replace PackedObjectLoader with ObjectLoader.SmallObjectShawn O. Pearce2010-07-012-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | The class is identical, but ObjectLoader.SmallObject is part of our public API for storage implementations to build on top of. Change-Id: I381a3953b14870b6d3d74a9c295769ace78869dc Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
| * | Support large loose objects as streamsShawn O. Pearce2010-07-011-0/+430
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Big loose objects can now be streamed if they are over the large object size threshold. This prevents the JVM heap from exploding with a very large byte array to hold the slurped file, and then again with its uncompressed copy. We may have slightly slowed down the simple case for small loose objects, as the loader no longer slurps the entire thing and decompresses in memory. To try and keep good performance for the very common small objects that are below 8 KiB in size, buffers are set to 8 KiB, causing the reader to slurp most of the file anyway. However the data has to be copied at least once, from the BufferedInputStream into the InflaterInputStream. New unit tests are supplied to get nearly 100% code coverage on the unpacked code paths, for both standard and pack style loose objects. We tested a fair chunk of the code elsewhere, but these new tests are better isolated to the specific branches in the code path. Change-Id: I87b764ab1b84225e9b5619a2a55fd8eaa640e1fe Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
| * | Move DirCache factory methods to RepositoryShawn O. Pearce2010-06-3012-77/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of creating the DirCache from a static factory method, use an instance method on Repository, permitting the implementation to override the method with a completely different type of DirCache reading and writing. This would better support a repository in the cloud strategy, or even just an in-memory unit test environment. Change-Id: I6399894b12d6480c4b3ac84d10775dfd1b8d13e7 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>