]> source.dussan.org Git - jgit.git/log
jgit.git
14 years agoFix TreeWalk bug comparing DirCache and WorkingTree with ANY_DIFF 90/1490/2
Shawn O. Pearce [Wed, 1 Sep 2010 19:31:37 +0000 (12:31 -0700)]
Fix TreeWalk bug comparing DirCache and WorkingTree with ANY_DIFF

When comparing a DirCache and a WorkingTree using ANY_DIFF we
sometimes didn't recursive into a subtree of both sides gave us
zeroId() back for the identity of a subtree.  This happens when the
DirCache doesn't have a valid cache tree for the subtree, as then
it uses zeroId() for the ObjectId of the subtree, which then appears
to be equal to the zeroId() of the WorkingTreeIterator's subtree.

We work around this by adding a hasId() method that returns true
only if this iterator has a valid ObjectId.  The idEquals method
on TreeWalk than only performs a compare between two iterators if
both iterators have a valid id.

Change-Id: I695f7fafbeb452e8c0703a05c02921fae0822d3f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agolog, diff: Add --src-prefix, --dst-prefix, --no-prefix 89/1489/2
Shawn O. Pearce [Wed, 1 Sep 2010 16:34:43 +0000 (09:34 -0700)]
log, diff: Add --src-prefix, --dst-prefix, --no-prefix

Change-Id: I0c7154a51143d56362f12ee4fa93133778d3a9eb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMove rename detection, path following into DiffFormatter 88/1488/2
Shawn O. Pearce [Wed, 1 Sep 2010 16:23:18 +0000 (09:23 -0700)]
Move rename detection, path following into DiffFormatter

Applications just want a quick way to configure our diff
implementation, and then just want to use it without a lot of fuss.

Move all of the rename detection logic and path following logic
out of our pgm package and into DiffFormatter itself, making it
much easier for a GUI to take advantage of the features without
duplicating a lot of code.

Change-Id: I4b54e987bb6dc804fb270cbc495fe4cae26c7b0e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMerge "Fix RepositoryState.MERGING"
Chris Aniszczyk [Thu, 2 Sep 2010 16:10:09 +0000 (12:10 -0400)]
Merge "Fix RepositoryState.MERGING"

14 years agoFix RepositoryState.MERGING 09/1509/1
Jens Baumgart [Thu, 2 Sep 2010 16:01:47 +0000 (18:01 +0200)]
Fix RepositoryState.MERGING

canResetHead now returns true.
Resetting mixed / hard works in EGit in merging state.

Change-Id: I1512145bbd831bb9734528ce8b71b1701e3e6aa9
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
14 years agoMerge "Add reset() to AbstractTreeIterator API"
Chris Aniszczyk [Thu, 2 Sep 2010 15:30:31 +0000 (11:30 -0400)]
Merge "Add reset() to AbstractTreeIterator API"

14 years agoMerge "Improve DiffFormatter text file access"
Chris Aniszczyk [Thu, 2 Sep 2010 15:29:58 +0000 (11:29 -0400)]
Merge "Improve DiffFormatter text file access"

14 years agoMerge "Correct diff header formatting"
Chris Aniszczyk [Thu, 2 Sep 2010 15:28:33 +0000 (11:28 -0400)]
Merge "Correct diff header formatting"

14 years agoMerge "Remove duplicated code in DiffFormatter"
Chris Aniszczyk [Thu, 2 Sep 2010 15:20:43 +0000 (11:20 -0400)]
Merge "Remove duplicated code in DiffFormatter"

14 years agoMerge "Adding sorting to LongList"
Christian Halstrick [Thu, 2 Sep 2010 11:53:15 +0000 (07:53 -0400)]
Merge "Adding sorting to LongList"

14 years agoMerge "Use int[] rather than IntList for RawText hashes"
Christian Halstrick [Thu, 2 Sep 2010 11:46:50 +0000 (07:46 -0400)]
Merge "Use int[] rather than IntList for RawText hashes"

14 years agoAdding sorting to LongList 00/1500/1
Shawn O. Pearce [Thu, 2 Sep 2010 06:07:08 +0000 (23:07 -0700)]
Adding sorting to LongList

Sorting the array can be useful when its being used as a map of pairs
that are appended into the array and then later merge-joined against
another array of similar semantics.

Change-Id: I2e346ef5c99ed1347ec0345b44cda0bc29d03e90
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMerge "Add toString and improve Javadoc of NotIgnoredFilter"
Chris Aniszczyk [Thu, 2 Sep 2010 00:39:40 +0000 (20:39 -0400)]
Merge "Add toString and improve Javadoc of NotIgnoredFilter"

14 years agoUse int[] rather than IntList for RawText hashes 98/1498/1
Shawn O. Pearce [Wed, 1 Sep 2010 23:54:20 +0000 (16:54 -0700)]
Use int[] rather than IntList for RawText hashes

We know exactly how many lines we need by the time we compute our
per-line hashes, as we have already built the lines IntList to give
us the starting position of each line in the buffer.  Using that
we can properly size the array, and don't need the dynamic growing
feature of IntList.  So drop the indirection and just use a fixed
size array.

Change-Id: I5c8c592514692a8abff51e5928aedcf71e100365
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoRefactor Git API exceptions to a new package 77/1477/2
Chris Aniszczyk [Tue, 31 Aug 2010 20:46:58 +0000 (15:46 -0500)]
Refactor Git API exceptions to a new package

Create a new 'org.eclipse.jgit.api.errors' package to contain
exceptions related to using the Git porcelain API.

Change-Id: Iac1781bd74fbd520dffac9d347616c3334994470
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoAdd toString and improve Javadoc of NotIgnoredFilter 95/1495/1
Shawn O. Pearce [Wed, 1 Sep 2010 22:22:48 +0000 (15:22 -0700)]
Add toString and improve Javadoc of NotIgnoredFilter

Today while debugging some TreeWalk related code I noticed this
filter did not have a toString(), making it harder to see what the
filter graph was at a glance in the debugger.  Add a toString()
for debugging to match other TreeFilters, and clean up the Javadoc
slightly so its a bit more clear about the purpose of the filter.

While we are mucking about with some of this code, simplify
the logic of include so its shorter and thus faster to read.
The pattern now more closely matches that of SkipWorkTreeFilter.

Change-Id: Iad433a1fa6b395dc1acb455aca268b9ce2f1d41b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoIndexDiff honors Index entries' "skipWorkTree" flag. 47/1447/5
Marc Strapetz [Wed, 1 Sep 2010 14:02:18 +0000 (16:02 +0200)]
IndexDiff honors Index entries' "skipWorkTree" flag.

Change-Id: I428d11412130b64fc46d7052011f5dff3d653802
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMerge "Avoid double quotes in Git Config"
Shawn Pearce [Wed, 1 Sep 2010 22:02:44 +0000 (18:02 -0400)]
Merge "Avoid double quotes in Git Config"

14 years agoMerge "Add FS.detect() for detection of file system abstraction."
Shawn Pearce [Wed, 1 Sep 2010 21:59:54 +0000 (17:59 -0400)]
Merge "Add FS.detect() for detection of file system abstraction."

14 years agoAdd reset() to AbstractTreeIterator API 87/1487/1
Shawn O. Pearce [Wed, 1 Sep 2010 16:20:33 +0000 (09:20 -0700)]
Add reset() to AbstractTreeIterator API

This allows callers to force the iterator back to its starting point,
so it can be traversed again.  The default way to do this is to use
back(1) until first() is true, but this isn't very efficient for any
iterator.  All current implementations have better ways to implement
reset without needing to seek backwards.

Change-Id: Ia26e6c852fdac8a0e9c80ac72c8cca9d897463f4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoImprove DiffFormatter text file access 86/1486/1
Shawn O. Pearce [Wed, 1 Sep 2010 03:09:14 +0000 (20:09 -0700)]
Improve DiffFormatter text file access

When we are asked to create a difference between two files the caller
really wants to see that output.  Instead of punting because a file
is too big to process, consider it to be binary.  This reduces the
accuracy of our output display, but makes it a lot more likely that
the formatter can still generate something semi-useful.

We set our default binary threshold to 50 MiB, which is the same
threshold that PackWriter uses before punting and deciding a file
is too big to delta compress.  Anything under this size we try to
load and process, anything over that size (or that won't allocate
in the heap) gets tagged as binary.

Change-Id: I69553c9ef96db7f2058c6210657f1181ce882335
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoCorrect diff header formatting 85/1485/1
Shawn O. Pearce [Wed, 1 Sep 2010 02:28:15 +0000 (19:28 -0700)]
Correct diff header formatting

When adding or deleting a file, we shouldn't ever prefix /dev/null
with the a/ or b/ prefixes.  Doing so is a mistake and confuses a
patch parser which handles /dev/null magically, while a/dev/null is
a file called null in the dev directory of the project.

Also when adding or deleting the "diff --git" line has the "real"
path on both sides, so we should see the following when adding the
file called foo:

  diff --git a/foo b/foo
  --- /dev/null
  +++ b/foo

The --- and +++ lines do not appear in a pure rename or copy delta,
C Git diff seems to omit these, so we now omit them as well.  We also
omit the index line when the ObjectIds are exactly equal.

Change-Id: Ic46892dea935ee8bdee29088aab96307d7ec6d3d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoRemove duplicated code in DiffFormatter 84/1484/1
Shawn O. Pearce [Wed, 1 Sep 2010 01:40:10 +0000 (18:40 -0700)]
Remove duplicated code in DiffFormatter

Instead of trying to stream out the header, we can drop a redundant
code path by formatting the header into a temporary buffer and then
streaming out the actual line differences later.

Its a small amount of unnecessary work to buffer the file header,
but these are typically very tiny so the cost to format and reparse
is relatively low.

Change-Id: Id14a527a74ee0bd7e07f46fdec760c22b02d5bdf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMove DiffFormatter default initialization to fields 83/1483/1
Shawn O. Pearce [Wed, 1 Sep 2010 03:27:25 +0000 (20:27 -0700)]
Move DiffFormatter default initialization to fields

Other fields in this class are initialized in their declaration, make
the code consistent with itself and use only one style.

Change-Id: I49a007e97ba52faa6b89f7e4b1eec85dccac0fa4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoCorrect Javadoc of DiffFormatter class 82/1482/1
Shawn O. Pearce [Wed, 1 Sep 2010 03:24:37 +0000 (20:24 -0700)]
Correct Javadoc of DiffFormatter class

This class does a lot more than just reflow a patch script, it now is
the primary means of creating a diff output.

Change-Id: I74467c9a53dc270ef8c84e7c75f388414ec8ba8f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agodiff: Fix bad metaVar reference in --abbrev option 81/1481/1
Shawn O. Pearce [Wed, 1 Sep 2010 17:00:47 +0000 (10:00 -0700)]
diff: Fix bad metaVar reference in --abbrev option

Change-Id: If92545b731ff80bff071aee9bbd852bbd187c7c5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd FS.detect() for detection of file system abstraction. 80/1480/1
Marc Strapetz [Wed, 1 Sep 2010 15:14:16 +0000 (17:14 +0200)]
Add FS.detect() for detection of file system abstraction.

To give the user more control on which file system abstraction
should be used on Windows, FS.detect() may be configured
to assume a Cygwin installation or nor.

14 years agoAvoid double quotes in Git Config 52/1452/5
Mathias Kinzler [Wed, 1 Sep 2010 07:13:19 +0000 (09:13 +0200)]
Avoid double quotes in Git Config

Currently, if a branch is created that has special chars ('#' in the bug),
Config will surround the subsection name with double quotes during
it's toText method which will result in an invalid file after saving the
Config.

Bug: 318249
Change-Id: I0a642f52def42d936869e4aaaeb6999567901001
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
14 years agoExtend DirCache test case to check "intent to add" flag. 75/1475/1
Marc Strapetz [Tue, 31 Aug 2010 19:54:30 +0000 (21:54 +0200)]
Extend DirCache test case to check "intent to add" flag.

14 years agoPartial support for index file format "3". 46/1446/4
Marc Strapetz [Tue, 31 Aug 2010 11:26:29 +0000 (13:26 +0200)]
Partial support for index file format "3".

Extended flags are processed and available via DirCacheEntry's
new isSkipWorkTree() and isIntentToAdd() methods.  "resolve-undo"
information is completely ignored since its an optional extension.

Change-Id: Ie6e9c6784c9f265ca3c013c6dc0e6bd29d3b7233

14 years agoMerge "DirCacheEntry: UPDATE_NEEDED should be in-core flag."
Shawn Pearce [Tue, 31 Aug 2010 18:29:03 +0000 (14:29 -0400)]
Merge "DirCacheEntry: UPDATE_NEEDED should be in-core flag."

14 years agoAdd test for RawParseUtils.formatBase10 73/1473/1
Shawn O. Pearce [Tue, 31 Aug 2010 18:26:26 +0000 (11:26 -0700)]
Add test for RawParseUtils.formatBase10

Change-Id: I3ad3533d03990c9e84186e53b9d755784b2a3758
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoFix RawParseUtils.formatBase10 to work with negative values 66/1466/2
Marc Strapetz [Tue, 31 Aug 2010 11:19:48 +0000 (13:19 +0200)]
Fix RawParseUtils.formatBase10 to work with negative values

Change-Id: Iffa220de76c5e180796fa46c4d67f52a1b3b2e35
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoRemove deprecated PersonIdent constructor 72/1472/1
Chris Aniszczyk [Tue, 31 Aug 2010 16:55:27 +0000 (11:55 -0500)]
Remove deprecated PersonIdent constructor

Change-Id: I3831de1b6df25a52df30d367f0216573e6ee6b53
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoImprove MergeAlgorithm to produce smaller conflicts 70/1470/1
Christian Halstrick [Tue, 31 Aug 2010 15:14:07 +0000 (17:14 +0200)]
Improve MergeAlgorithm to produce smaller conflicts

The merge algorithm was reporting conflicts which where to big.

Example: The common base was "ABC", the "ours" version contained
"AB1C" (the addition of "1" after pos 2) and the "theirs" version also
contained "AB1C". We have two potentially conflicting edits in the
same region which happen to bring in exactly the same content. This
should not be a conflict - but was previously reported as
"AB<<<1===1>>>C".

This is fixed by checking every conflicting chunk whether the
conflicting regions have a common prefix or suffix and by removing
this regions from the conflict.

Change-Id: I4dc169b8ef7a66ec6b307e9a956feef906c9e15e
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoDirCacheEntry: UPDATE_NEEDED should be in-core flag. 65/1465/1
Marc Strapetz [Tue, 31 Aug 2010 09:25:16 +0000 (11:25 +0200)]
DirCacheEntry: UPDATE_NEEDED should be in-core flag.

In correspondance to CGit, UPDATE_NEEDED flag should not be
written to disk. Furthermore, it currently intersects CGit's
CE_EXTENDED flag.

14 years agoFix build of JGit source bundle and feature 63/1463/2
Matthias Sohn [Tue, 31 Aug 2010 00:35:08 +0000 (02:35 +0200)]
Fix build of JGit source bundle and feature

Add local changes I missed to push with [1] which broke the JGit
build.

[1] http://egit.eclipse.org/r/#change,1442

Change-Id: I300bfa84c5d8b5128026869b694ef5da7b0d3a4a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years agoLet Resolve be the default Merge strategy 62/1462/1
Christian Halstrick [Mon, 23 Aug 2010 15:07:03 +0000 (17:07 +0200)]
Let Resolve be the default Merge strategy

the merge command should use by default the "resolve" merge strategy.

Change-Id: I6c6973a3397cca12bd8a6bd950d04b1766a08b4c
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoAdded merge strategy RESOLVE 26/1226/7
Christian Halstrick [Thu, 12 Aug 2010 13:19:18 +0000 (15:19 +0200)]
Added merge strategy RESOLVE

This adds the first merge strategy to JGit which does real
content-merges if necessary. The new merge strategy "resolve" takes as
input three commits: a common base, ours and theirs. It will simply takeover
changes on files which are only touched in ours or theirs. For files
touched in ours and theirs it will try to merge the two contents
knowing taking into account the specified common base.

Rename detection has not been introduced for now.

Change-Id: I49a5ebcdcf4f540f606092c0f1dc66c965dc66ba
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
14 years agoMerge "Add one more test to ReadTreeTest"
Chris Aniszczyk [Mon, 30 Aug 2010 20:59:15 +0000 (16:59 -0400)]
Merge "Add one more test to ReadTreeTest"

14 years agoWait for JIT optimization before measuring diff performance 49/1449/4
Matthias Sohn [Sun, 29 Aug 2010 21:41:10 +0000 (23:41 +0200)]
Wait for JIT optimization before measuring diff performance

On Mac OS X MyerDiffPerformanceTest was failing since during the
first few tests the JIT compiler is running in parallel slowing down
the tests. When setting the JVM option -Xbatch forcing the JIT to do
its work prior to running the code this effect can be avoided. Instead
we chose to run some tests without recording prior to the recorded
tests since relying on -X JVM parameters isn't portable across JVMs.

Use 10k * powers of 2 as sample size instead of odd numbers used
before and also improve formatting of performance readings.

Bug: 323766
Change-Id: I9a46d73f81a785f399d3cf5a90c8c0516526e048
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoGenerate source plugin and source feature for jgit 42/1442/3
Matthias Sohn [Fri, 27 Aug 2010 23:18:20 +0000 (01:18 +0200)]
Generate source plugin and source feature for jgit

Change-Id: Ibc5a302078bfc01d9ee45a4c0ab0b79b2abd185a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoImprove LargeObjectException reporting 60/1460/1
Shawn O. Pearce [Mon, 30 Aug 2010 18:53:25 +0000 (11:53 -0700)]
Improve LargeObjectException reporting

Use 3 different types of LargeObjectException for the 3 major ways
that we can fail to load an object.  For each of these use a unique
string translation which describes the root cause better than just
the ObjectId.name() does.

Change-Id: I810c98d5691b74af9fc6cbd46fc9879e35a7bdca
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoIndexPack: Use byte limited form of getCachedBytes 59/1459/1
Shawn O. Pearce [Mon, 30 Aug 2010 18:01:33 +0000 (11:01 -0700)]
IndexPack: Use byte limited form of getCachedBytes

Currently our algorithm requires that we have the delta base as
a contiguous byte array... but getCachedBytes() might not work
if the object is considered to be large by its underlying loader.
Use the limited form to obtain the object as a byte array instead.

Change-Id: I33f12a8811cb6a4a67396174733f209db8119b42
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoUndo translation of protocol string 'unpack error' 58/1458/1
Shawn O. Pearce [Mon, 30 Aug 2010 17:58:19 +0000 (10:58 -0700)]
Undo translation of protocol string 'unpack error'

This string is part of the network protocol, and isn't meant to
be translated into another language.  Clients actually scan for
the string "unpack error " off the wire and react magically to
this information.  If it were translated, they would instead have
a protocol exception, which isn't very useful when there is already
an error occurring.

Change-Id: Ia5dc8d36ba65ad2552f683bb637e80b77a7d92f0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd one more test to ReadTreeTest 50/1450/1
Christian Halstrick [Mon, 30 Aug 2010 07:07:59 +0000 (09:07 +0200)]
Add one more test to ReadTreeTest

Add an explicit test case to check that we don't
overwrite dirty files in case Head & Index are
equal.

Change-Id: I6266d0a449e55369d2d0a048694dca5565c5fcf3
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoMerge "Buffer very large delta streams to reduce explosion of CPU work"
Shawn O. Pearce [Sun, 29 Aug 2010 00:31:24 +0000 (20:31 -0400)]
Merge "Buffer very large delta streams to reduce explosion of CPU work"

14 years agoRevert "Hide Maven target directories from Eclipse" 44/1444/2
Robin Rosenberg [Sat, 28 Aug 2010 07:45:23 +0000 (09:45 +0200)]
Revert "Hide Maven target directories from Eclipse"

This reverts commit db4c516f673e4c274e55adc27a95891c52a5aba8 since
it breaks compatibility with Eclipse 3.5 which can no longer import
the projects

Bug: 323390
Change-Id: I3cc91364a6747cfcb4c611a9be5258f81562f726

14 years agoBuffer very large delta streams to reduce explosion of CPU work 41/1441/1
Shawn O. Pearce [Fri, 27 Aug 2010 20:28:14 +0000 (13:28 -0700)]
Buffer very large delta streams to reduce explosion of CPU work

Large delta streams are unpacked incrementally, but because a delta
can seek to a random position in the base to perform a copy we may
need to inflate the base repeatedly just to complete one delta.
So work around it by copying the base to a temporary file, and then
we can read from that temporary file using random seeks instead.
Its far more efficient because we now only need to inflate the
base once.

This is still really ugly because we have to dump to a temporary
file, but at least the code can successfully process a large
file without throwing OutOfMemoryError.  If speed is an
issue, the user will need to increase the JVM heap and ensure
core.streamFileThreshold is set to a higher value, so we don't use
this code path as often.

Unfortunately we lose the "optimization" of skipping over portions
of a delta base that we don't actually need in the final result.
This is going to cause us to inflate and write to disk useless
regions that were deleted and do not appear in the final result.
We could later improve on our code by trying to flatten delta
instruction streams before we touch the bottom base object, and
then only store the portions of the base we really need for the
final result and that appear out-of-order.  Since that is some
pretty complex code I'm punting on it for now and just doing this
simple whole-object buffering.

Because the process umask might be permitting other users to read
files we create, we put the temporary buffers into $GIT_DIR/objects.
We can reasonably assume that if a reader can read our temporary
buffer file in that directory, they can also read the base pack
file we are pulling it from and therefore its not a security breach
to expose the inflated content in a file.  This requires a reader
to have write access to the repository, but only if the file is
really big.  I'd rather err on the side of caution here and refuse
to read a very big file into /tmp than to possibly expose a secured
content because the Java 5 JVM won't let us create a protected
temporary file that only the current user can access.

Change-Id: I66fb80b08cbcaf0f65f2db0462c546a495a160dd
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd TagCommand 93/1293/11
Chris Aniszczyk [Thu, 12 Aug 2010 16:25:31 +0000 (11:25 -0500)]
Add TagCommand

A tag command is added to the Git porcelain API. Tests were
also added to stress test the tag command.

Change-Id: Iab282a918eb51b0e9c55f628a3396ff01c9eb9eb
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years agoImplement a Dircache checkout (needed for merge) 25/825/18
Christian Halstrick [Fri, 11 Jun 2010 05:33:16 +0000 (07:33 +0200)]
Implement a Dircache checkout (needed for merge)

Implementation of a checkout (or 'git read-tree') operation which
works together with DirCache. This implementation does similar things
as WorkDirCheckout which main problem is that it works with deprecated
GitIndex. Since GitIndex doesn't support multiple stages of a file
which is required in merge situations this new implementation is
required to enable merge support.

Change-Id: I13f0f23ad60d98e5168118a7e7e7308e066ecf9c
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoAdd getBaseCommit() to Merger 56/1356/3
Christian Halstrick [Fri, 20 Aug 2010 15:17:01 +0000 (17:17 +0200)]
Add getBaseCommit() to Merger

The Merger was was only exposing the merge base as an
AbstractTreeIterator. Since we need the merge base as
RevCommit to generate the merge result I expose it here.

Change-Id: Ibe846370a35ac9bdb0c97ce2e36b2287577fbcad
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoIncrease heap size for jgit tests 35/1435/2
Matthias Sohn [Thu, 26 Aug 2010 22:26:25 +0000 (00:26 +0200)]
Increase heap size for jgit tests

Otherwise PackFileTest.testDelta_LargeObjectChain() reproducibly
fails with OutOfMemoryError on Mac OS X 10.6.4.

Change-Id: I6a55ff9ba181102606a0d99ffd52392a1615a422
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years agoRemove unused import 33/1433/1
Matthias Sohn [Thu, 26 Aug 2010 21:53:41 +0000 (23:53 +0200)]
Remove unused import

Change-Id: I22f5751720576475e5e1e04110268f6f7fb376b1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
14 years agoMerge "Fix parsing of multiple authors in PersonIdent."
Shawn Pearce [Thu, 26 Aug 2010 19:00:58 +0000 (15:00 -0400)]
Merge "Fix parsing of multiple authors in PersonIdent."

14 years agoMerge "Use JUnit4 for tests"
Shawn Pearce [Thu, 26 Aug 2010 18:50:05 +0000 (14:50 -0400)]
Merge "Use JUnit4 for tests"

14 years agoRun formatter on edited lines via save action 31/1431/1
Chris Aniszczyk [Thu, 26 Aug 2010 17:31:34 +0000 (12:31 -0500)]
Run formatter on edited lines via save action

Updates the project level settings to run the formatter
on save on only on the edited lines.

Change-Id: I26dd69d0c95e6d73f9fdf7031f3c1dbf3becbb79
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoUse JUnit4 for tests 30/1430/1
Chris Aniszczyk [Thu, 26 Aug 2010 17:26:38 +0000 (12:26 -0500)]
Use JUnit4 for tests

We should use JUnit4 for tests. This patch updates
the MANIFEST.MF and respective launch configurations.

Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoFix parsing of multiple authors in PersonIdent. 24/1324/5
Marc Strapetz [Thu, 19 Aug 2010 13:34:44 +0000 (15:34 +0200)]
Fix parsing of multiple authors in PersonIdent.

PersonIdent should be parsable for an invalid commit which
contains multiple authors, like "A <a@a.org>, B <b@b.org>".
PersonIdent(String) constructor now delegates to
RawParseUtils.parsePersonIdent().

Change-Id: Ie9798d36d9ecfcc0094ca795f5a44b003136eaf7

14 years agoIncrease temporary buffer for unit test 28/1428/1
Shawn O. Pearce [Thu, 26 Aug 2010 00:53:00 +0000 (17:53 -0700)]
Increase temporary buffer for unit test

Because we are using the large stream size, we have to be
above the STREAM_THRESHOLD constant, which I just increased.

Change-Id: I6f10ec8558d9f751d4b547fcae05af94f1c8866b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoIncrease the default streaming threshold to 15 MiB 27/1427/1
Shawn O. Pearce [Thu, 26 Aug 2010 00:05:31 +0000 (17:05 -0700)]
Increase the default streaming threshold to 15 MiB

Applying deltas in the large streaming mode is horrifically slow.
Trying to pack icu4c is impossible because a single 11 MiB file
sits on top of a 15 MiB file though a 10 deep delta chain, which
results in this very slow inflate process.

Upping the default limit to 15 MiB lets us process this large in a
reasonable time, but its still sufficiently low enough to prevent
exploding the heap of a very large process like Eclipse or Gerrit
Code Review.

We have to revisit the streaming delta application process and do
something much smarter, like flatten the delta chain before we apply
it to the base.  But even that is ugly, I've seen a 155 MiB delta
sitting on top of a 450 MiB file to produce a 300 MiB result object.
If the chain is deep, we may have trouble flatting it down.

Change-Id: If5a0dcbf9d14ea683d75546f104b09bb8cd8fdbb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoFix reuse from pack file for REF_DELTA types 26/1426/1
Shawn O. Pearce [Wed, 25 Aug 2010 23:46:43 +0000 (16:46 -0700)]
Fix reuse from pack file for REF_DELTA types

We miscomputed the CRC32 checksum for a REF_DELTA type of object, by
not including the full 20 byte ObjectId of the delta base in the CRC
code we use when the delta is too large to go through our two faster
small reuse code paths.  This resulted in a corruption error during
packing, where the PackFile erroneously suspected the data was wrong
on the local filesystem and aborted writing, because the CRC didn't
match what we had read from the index.

Change-Id: I7d12cdaeaf2c83ddc11223ce0108d9bd6886e025
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoCleanup and correct resolve Javadoc 10/1410/2
Shawn O. Pearce [Wed, 25 Aug 2010 01:18:24 +0000 (18:18 -0700)]
Cleanup and correct resolve Javadoc

We didn't fully cover what we support and what we don't.  It was
also a bit hard to follow the syntaxes supported.  Clean that up
by documenting it.

Change-Id: I7b96fa6cbefcc2364a51f336712ad361ae42df2d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoSupport parsing commit:path style blob references 09/1409/2
Shawn O. Pearce [Wed, 25 Aug 2010 00:52:26 +0000 (17:52 -0700)]
Support parsing commit:path style blob references

We can now resolve expressions that reference a path within a
commit, designating a specific revision of a specific tree or
file in the project.

Change-Id: Ie6a8be629d264d72209db894bd680c5900035cc0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoSupport parsing git describe style output 08/1408/2
Shawn O. Pearce [Wed, 25 Aug 2010 00:35:52 +0000 (17:35 -0700)]
Support parsing git describe style output

We now match on the -gABBREV style output created by git describe
when its describing a non-tagged commit, and resolve that back to
the full ObjectId using the abbreviation resolution feature that
we already support.

Change-Id: Ib3033f9483d9e1c66c8bb721ff48d4485bcdaef1
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoRename T0008_testparserev to RepositoryResolveTest 07/1407/2
Shawn O. Pearce [Tue, 24 Aug 2010 23:45:53 +0000 (16:45 -0700)]
Rename T0008_testparserev to RepositoryResolveTest

Calling it by the old numerical numbering system makes it really
hard to find the test that tests Repository.resolve(String).

Change-Id: I92d0ecbc8d66ce21bfed08888eeedf1300ffa594
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoThrow AmbiguousObjectException during resolve if its ambiguous 03/1403/3
Shawn O. Pearce [Tue, 24 Aug 2010 23:26:40 +0000 (16:26 -0700)]
Throw AmbiguousObjectException during resolve if its ambiguous

Its wrong to return null if we are resolving an abbreviation and we
have proven it matches more than one object.  We know how to resolve
it if we had more nybbles, as there are two or more objects with the
same prefix.  Declare that to the caller quite clearly by giving them
an AmbiguousObjectException.

Change-Id: I01bb48e587e6d001b93da8575c2c81af3eda5a32
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoComplete an abbreviation when formatting a patch 02/1402/3
Shawn O. Pearce [Tue, 24 Aug 2010 22:50:36 +0000 (15:50 -0700)]
Complete an abbreviation when formatting a patch

If we are given a DiffEntry header that already has abbreviated
ObjectIds on it, we may still be able to resolve those locally and
output the difference.  Try to do that through the new resolve API
on ObjectReader.

Change-Id: I0766aa5444b7b8fff73620290f8c9f54adc0be96
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoUse limited getCachedBytes in RevWalk 01/1401/3
Shawn O. Pearce [Tue, 24 Aug 2010 19:50:59 +0000 (12:50 -0700)]
Use limited getCachedBytes in RevWalk

Parsing is rewritten to use the size limited form of getCachedBytes,
thus freeing the revwalk infrastructure from needing to care about
a large object vs. a small object when it gets an ObjectLoader.

Right now we hardcode our upper bound for a commit or annotated
tag to be 15 MiB.  I don't know of any that is more than 1 MiB in
the wild, so going 15x that should give us some reasonable headroom.

Change-Id: If296c211d8b257d76e44908504e71dd9ba70ffa8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoUse limited getCachedBytes code to reduce duplication 00/1400/3
Shawn O. Pearce [Tue, 24 Aug 2010 21:01:55 +0000 (14:01 -0700)]
Use limited getCachedBytes code to reduce duplication

Rather than duplicating this block everywhere, reuse the limited size
form of getCachedBytes to acquire the content of an object.

Change-Id: I2e26a823e6fd0964d8f8dbfaa0fc2e8834c179c1
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoAdd brute force byte array loading to ObjectLoader 99/1399/3
Shawn O. Pearce [Tue, 24 Aug 2010 19:46:56 +0000 (12:46 -0700)]
Add brute force byte array loading to ObjectLoader

Some algorithms are coded in a way that requires us to provide them
the entire object contents as a contiguous byte array.  The parsers
in RevCommit and RevTag, or our RawText objects are really good
examples of these.

Instead of duplicating this logic everywhere, lets put it into the
base ObjectLoader type.  That way the caller only needs to give us
their upper size bound, and we'll do the rest of the heavy work to
figure out if the object still fits within that bound, and get them
an array that has the complete contents.

Change-Id: Id95a7f79d2b97e39f6949370ccca2f2c9cfb1a0f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoMerge "Add ObjectId to the LargeObjectException"
Chris Aniszczyk [Wed, 25 Aug 2010 23:54:32 +0000 (19:54 -0400)]
Merge "Add ObjectId to the LargeObjectException"

14 years agoAdd ObjectId to the LargeObjectException 98/1398/3
Shawn O. Pearce [Tue, 24 Aug 2010 23:11:41 +0000 (16:11 -0700)]
Add ObjectId to the LargeObjectException

A chunk of code that throws LargeObjectException may or may not have
the specific ObjectId on hand when its thrown.  If it does, we want
to cache it in the exception, and put that in the message.  If it is
missing we want to be able to set it later from a higher level stack
frame that does have the object handy.

Change-Id: Ife25546158868bdfa886037e4493ef8235ebe4b9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
14 years agoMerge "Don't copy more than the object size"
Chris Aniszczyk [Wed, 25 Aug 2010 23:52:36 +0000 (19:52 -0400)]
Merge "Don't copy more than the object size"

14 years agoMerge "Use the ObjectStream size during copyTo"
Chris Aniszczyk [Wed, 25 Aug 2010 23:50:43 +0000 (19:50 -0400)]
Merge "Use the ObjectStream size during copyTo"

14 years agoFixed typo in DirCache documentation 18/1418/1
Benjamin Muskalla [Wed, 25 Aug 2010 13:52:18 +0000 (15:52 +0200)]
Fixed typo in DirCache documentation

Change-Id: Ifc2e9047a45d57829fce59c66618e5de9120a5bb
Signed-off-by: Benjamin Muskalla <bmuskalla@eclipsesource.com>
14 years agoDon't copy more than the object size 97/1397/2
Shawn O. Pearce [Tue, 24 Aug 2010 19:59:10 +0000 (12:59 -0700)]
Don't copy more than the object size

If the loader's stream is broken and returns to us more content
than it originally declared as the size of the object, don't
copy that onto the output stream.  Instead throw EOFException
and abort fast.  This way we don't follow an infinite stream,
but instead will at least stop when the size was reached.

Change-Id: I7ec0c470c875f03b1f12a74a9b4d2f6e73b659bb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoUse the ObjectStream size during copyTo 96/1396/2
Shawn O. Pearce [Tue, 24 Aug 2010 19:56:47 +0000 (12:56 -0700)]
Use the ObjectStream size during copyTo

If the stream is a delta decompression stream, getting the size
can be expensive.  Its cheaper to get it from the stream itself
rather than from the object loader.

Change-Id: Ia7f0af98681f6d56ea419a48c6fa8eea09274b28
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoFix ObjectDirectory abbreviation resolution to notice new packs 06/1406/1
Shawn O. Pearce [Wed, 25 Aug 2010 00:20:50 +0000 (17:20 -0700)]
Fix ObjectDirectory abbreviation resolution to notice new packs

If we can't resolve an abbreviation, it might be because there is
a new pack file we haven't picked up yet.  Try scanning the packs
again and recheck each pack if there were differences from the last
scan we did.

Because of this, we don't have to open a pack during the test where
we generate a pack on the fly.  We'll miss on the first loop during
which the PackList is the NO_PACKS magic initialization constant,
and pick up the newly created index during this retry logic.

Change-Id: I7b97efb29a695ee60c90818be380f7ea23ad13a3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoFully implement SHA-1 abbreviations 89/1389/1
Shawn O. Pearce [Mon, 23 Aug 2010 22:53:11 +0000 (15:53 -0700)]
Fully implement SHA-1 abbreviations

ObjectReader implementations are now responsible for creating the
unique abbreviation of an ObjectId, or for resolving an abbreviation
back to its full form.  In this latter case the reader can offer up
multiple candidates to the caller, who may be able to disambiguate
them based on context.

Repository.resolve() doesn't take multiple candidates into account
right now, but it could in the future by looking for a remaining
^0 or ^{commit} suffix and take an expansion if there is only one
commit that matches the input abbreviation.  It could also use
the distance from an annotated tag to resolve "tag-NNN-gcommit"
style strings that are often output by `git describe`.

Change-Id: Icd3250adc8177ae05278b858933afdca0cbbdb56
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoDelete deprecated ObjectWriter 87/1387/1
Shawn O. Pearce [Mon, 23 Aug 2010 17:59:30 +0000 (10:59 -0700)]
Delete deprecated ObjectWriter

ObjectWriter is a deprecated API that people shouldn't be using.
So get rid of it in favor of the ObjectInserter API.

Change-Id: I6218bcb26b6b9ffb64e3e470dba5dca2e0a62fd4
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd openEntryStream to WorkingTreeIterator 86/1386/1
Shawn O. Pearce [Mon, 23 Aug 2010 17:30:58 +0000 (10:30 -0700)]
Add openEntryStream to WorkingTreeIterator

This makes it easier for abstract tools like AddCommand to open the
file from the working tree, without knowing internal details about
how the tree is managed.

Change-Id: Ie64a552f07895d67506fbffb3ecf1c1be8a7b407
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd setLength(long) to DirCacheEntry 85/1385/1
Shawn O. Pearce [Mon, 23 Aug 2010 17:29:50 +0000 (10:29 -0700)]
Add setLength(long) to DirCacheEntry

Applications should favor the long style interface, especially when
their source input is a long type, e.g. coming from java.io.File.
This way when the index format is later changed to support a
larger file size than 2 GiB we can handle it by just changing the
entry code, and not need to fix a lot of applications.

Change-Id: I332563caeb110014e2d544dc33050ce67ae9e897
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoMove commit and tag formatting to CommitBuilder, TagBuilder 84/1384/1
Shawn O. Pearce [Mon, 23 Aug 2010 17:13:25 +0000 (10:13 -0700)]
Move commit and tag formatting to CommitBuilder, TagBuilder

These objects should be responsible for their own formatting,
rather than delegating it to some obtuse type called ObjectInserter.

While we are at it, simplify the way we insert these into a database.
Passing in the type and calling format in application code turned
out to be a huge mistake in terms of ease-of-use of the insert API.

Change-Id: Id5bb95ee56aa2a002243e9b7853b84ec8df1d7bf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoRename Commit, Tag to CommitBuilder, TagBuilder 83/1383/1
Shawn O. Pearce [Mon, 23 Aug 2010 16:46:14 +0000 (09:46 -0700)]
Rename Commit, Tag to CommitBuilder, TagBuilder

Since these types no longer support reading, calling them a Builder
is a better description of what they do.  They help the caller to
build a commit or a tag object.

Change-Id: I53cae5a800a66ea1721b0fe5e702599df31da05d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd documentation explaining how to read Commit and Tag 82/1382/1
Shawn O. Pearce [Mon, 23 Aug 2010 16:40:41 +0000 (09:40 -0700)]
Add documentation explaining how to read Commit and Tag

Since we stopped supporting these types for reading, but their
name is a natural candidate for someone to try and use in code,
explain where they should be looking instead.

Change-Id: I091a1b0ef71b842016020f938ba3161431aab9c9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoImproved creation of JGitInternalException 70/1370/1
Christian Halstrick [Mon, 23 Aug 2010 07:48:17 +0000 (09:48 +0200)]
Improved creation of JGitInternalException

There where 3 cases where a JGitInternalExcption was created
without specifying the root cause. This has been fixed.

Change-Id: I2ee08d04732371cd9e30874b1437b61217770b6a
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
14 years agoPerform automatic CRLF to LF conversion during WorkingTreeIterator 79/1179/7
Marc Strapetz [Thu, 29 Jul 2010 14:21:37 +0000 (16:21 +0200)]
Perform automatic CRLF to LF conversion during WorkingTreeIterator

WorkingTreeIterator now optionally performs CRLF to LF conversion for
text files.  A basic framework is left in place to support enabling
(or disabling) this feature based on gitattributes, and also to
support the more generic smudge/clean filter system.  As there is
no gitattribute support yet in JGit this is left unimplemented,
but the mightNeedCleaning(), isBinary() and filterClean() methods
will provide reasonable places to plug that into in the future.

[sp: All bugs inside of WorkingTreeIterator are my fault, I wrote
     most of it while cherry-picking this patch and building it on
     top of Marc's original work.]

CQ: 4419
Bug: 301775
Change-Id: I0ca35cfbfe3f503729cbfc1d5034ad4abcd1097e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoExpose pack fetch/push connections for subclassing 46/1246/3
Shawn O. Pearce [Wed, 4 Aug 2010 00:40:01 +0000 (17:40 -0700)]
Expose pack fetch/push connections for subclassing

These classes need to be visible if an application wants to define
its own native pack based protocol embedded within another layer,
much like we already support for smart HTTP.

Change-Id: I7e2ac3ad01d15b94d340128a395fe0b2f560ff35
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAllow ObjectReuseAsIs to have more control over write ordering 24/1224/4
Shawn O. Pearce [Tue, 3 Aug 2010 00:00:35 +0000 (17:00 -0700)]
Allow ObjectReuseAsIs to have more control over write ordering

The reuse system used by an object database may be able to benefit
from knowing what objects are coming next, and even improve data
throughput by delaying (or moving up) objects that are stored near
each other in the source database.

Pushing the iteration down into the reuse code makes it possible
for a smarter implementation to aggregate reuse.  But for the
standard pack file format on disk we don't bother, its quite
efficient already.

Change-Id: I64f0048ca7071a8b44950d6c2a5dfbca3be6bba6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAllow ObjectToPack subclasses to use up to 4 bits of flags 23/1223/4
Shawn O. Pearce [Mon, 2 Aug 2010 19:26:01 +0000 (12:26 -0700)]
Allow ObjectToPack subclasses to use up to 4 bits of flags

Some instances may benefit from having access to memory efficient
storage for some small values, like single flag bits.  Give up a
portion of our delta depth field to make 4 bits available to any
subclass that wants it.

This still gives us room for delta chains of 1,048,576 objects,
and that is just insane.  Unpacking 1 million objects to get to
something is longer than most users are willing to wait for data
from Git.

Change-Id: If17ea598dc0ddbde63d69a6fcec0668106569125
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoImplement async/batch lookup of object data 22/1222/4
Shawn O. Pearce [Sun, 1 Aug 2010 03:08:10 +0000 (20:08 -0700)]
Implement async/batch lookup of object data

An ObjectReader implementation may be very slow for a single object,
but yet support bulk queries efficiently by batching multiple small
requests into a single larger request.  This easily happens when the
reader is built on top of a database that is stored on another host,
as the network round-trip time starts to dominate the operation cost.

RevWalk, ObjectWalk, UploadPack and PackWriter are the first major
users of this new bulk interface, with the goal being to support an
efficient way to pack a repository for a fetch/clone client when the
source repository is stored in a high-latency storage system.

Processing the want/have lists is now done in bulk, to remove
the high costs associated with common ancestor negotiation.

PackWriter already performs object reuse selection in bulk, but it
now can also do the object size lookup and object counting phases
with higher efficiency.  Actual object reuse, deltification, and
final output are still doing sequential lookups, making them a bit
more expensive to perform.

Change-Id: I4c966f84917482598012074c370b9831451404ee
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoOffer ObjectReaders advice about a RevWalk 21/1221/3
Shawn O. Pearce [Fri, 30 Jul 2010 02:52:36 +0000 (19:52 -0700)]
Offer ObjectReaders advice about a RevWalk

By giving the reader information about the roots of a revision
traversal, some readers may be able to prefetch information from
their backing store using background threads in order to reduce
data access latency.  However this isn't typically necessary so
the default reader implementation doesn't react to the advice.

Change-Id: I72c6cbd05cff7d8506826015f50d9f57d5cda77e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAllow object reuse selection to occur in parallel 20/1220/3
Shawn O. Pearce [Sat, 31 Jul 2010 01:12:23 +0000 (18:12 -0700)]
Allow object reuse selection to occur in parallel

ObjectReader implementations may wish to use multiple threads in
order to evaluate object reuse faster.  Let the reader make that
decision by passing the iteration down into the reader.

Because the work is pushed into the reader, it may need to locate a
given ObjectToPack given its ObjectId.  This can easily occur if the
reader has sent a list of ObjectIds to the object database and gets
back information keyed only by ObjectId, without the ObjectToPack
handle.  Expose lookup using the PackWriter's own internal map,
so the reader doesn't need to build a redundant copy to track the
assocation of ObjectId back to ObjectToPack.

Change-Id: I0c536405a55034881fb5db92a2d2a99534faed34
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoFlush the pack header as soon as its ready 19/1219/3
Shawn O. Pearce [Mon, 2 Aug 2010 17:17:21 +0000 (10:17 -0700)]
Flush the pack header as soon as its ready

When the output stream is deeply buffered (e.g. 1 MiB or more in
an HTTP servlet on some containers) trying to kick out the header
earlier will prevent the client from stalling hard while the first
1 MiB is received and it can process the pack header.  Forcing a
flush here lets the client see the header and start its progress
monitor for "Receiving objects: (1/N)" so the user knows there
is still activity occurring, even though the buffering may cause
there to be some lag as the buffer fills up on the sending side.

Change-Id: I3edf39e8f703fe87a738dc236d426b194db85e3a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoExport the ObjectId on MissingObjectException 18/1218/3
Shawn O. Pearce [Sat, 31 Jul 2010 00:50:58 +0000 (17:50 -0700)]
Export the ObjectId on MissingObjectException

Callers catching a MissingObjectException may need programmatic
access to the ObjectId that wasn't available in the repository.

Change-Id: I2be0380251ebe7e4921fa74e246724e48ad88b0e
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoExpose OBJ_ANY in ObjectReader 17/1217/3
Shawn O. Pearce [Fri, 30 Jul 2010 23:43:34 +0000 (16:43 -0700)]
Expose OBJ_ANY in ObjectReader

Storage implementations or application code using an ObjectReader
may want to access this constant without being inside of a subclass
of the reader.

Change-Id: I6c871a03d5846b9bb899de4d14a265e8b204d8e0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoExpose getType in ObjectToPack 16/1216/3
Shawn O. Pearce [Thu, 29 Jul 2010 23:59:40 +0000 (16:59 -0700)]
Expose getType in ObjectToPack

Storage implementations may find this useful when implementing the
ObjectReuseAsIs interface on their ObjectReader.  Expose it so we
don't force them to create a redundant copy of the information.

Change-Id: I802ec8113c00884fccde5d0e92b9849716316f62
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd copyTo(ByteBuffer) to AnyObjectId 15/1215/3
Shawn O. Pearce [Fri, 30 Jul 2010 15:51:11 +0000 (08:51 -0700)]
Add copyTo(ByteBuffer) to AnyObjectId

Change-Id: I3572f6113db883002f9c3a5ecc1bcc8370105c98
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
14 years agoAdd copyTo(byte[], int) to AnyObjectId 14/1214/3
Shawn O. Pearce [Fri, 30 Jul 2010 02:41:59 +0000 (19:41 -0700)]
Add copyTo(byte[], int) to AnyObjectId

This permits formatting in hex into an existing byte array
supplied by the caller, and mirrors our copyRawTo method
with the same parameter signature.

Change-Id: Ia078d83e338b09b903bfd2d04284e5283f885a19
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>