Commit Graph

981 Commits

Author SHA1 Message Date
Shawn O. Pearce 3f3b6bfdb3 Remove dead RawText(RawTextComparator) constructor
Since the introduction of HashedSequence we no longer need to supply
the RawTextComparator at the time of constructing a RawText.  Drop the
definition from the constructor, because it doesn't make sense as part
of our public API.

Change-Id: Iaab34611d60eee4a2036830142b089b2dae81842
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-13 20:48:51 -07:00
Shawn O. Pearce 8ea558bd82 Fix RawTextComparator reduceCommonStartEnd at empty lines
When an empty line was inserted at the beginning of the common end
part of a RawText the comparator incorrectly considered it to be
common, which meant the DiffAlgorithm would later not even have it be
part of the region it examines.  This would cause JGit to skip a line
of insertion, which later confused Gerrit Code Review when it tried to
match up the pre and post RawText files for a difference that had this
type of insertion.

Define two new unit tests to check for this insertion of a blank line
condition and correct for it by removing the LF from the common region
when the condition is detected.

Change-Id: I2108570eb2929803b9a56f9fb9c400c758e7156b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-13 20:48:51 -07:00
Shawn O. Pearce abac15e45e Correct spelling of tests in HistogramDiffTest
Change-Id: I003b601f384ff1213da6750dd13846367a511d0b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-13 20:48:51 -07:00
Shawn O. Pearce 529b2017df Fix three-word command names
Command names like MakeCacheTree weren't coming up with hyphens between
every word, so they read "debug-make-cachetree" rather than the
expected "debug-make-cache-tree".  On each lowercase character reset
the lastWasDash flag so the next uppercase will insert a hyphen before
the next word.

Change-Id: I539fabb339e60896165619c307dec71e3317b0d8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-14 00:14:14 +02:00
Matthias Sohn f8eb7e16aa Generate correct version for jgit source bundle
The maven 2 build for jgit source bundle didn't create a correct
OSGi version string, instead of
    org.eclipse.jgit.source_0.10.0.<timestamp>
the generated OSGi version was
    org.eclipse.jgit.source_0.10.0.SNAPSHOT
This caused trouble when trying to install it from p2 repository.

Bug: 327616
Change-Id: Ic27c763ae9a4bcbb5bd6ed9562cd98bb4da3386b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-13 15:33:46 +02:00
Christian Halstrick fb1e500adc Rename method to ResolveMerger.setWorkingTreeIterator()
renamed an ugly methodname

Change-Id: I26bda06ef64b8644fd3a555dc55dff43cdb56a71
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-13 11:30:41 +02:00
Mathias Kinzler 5c135a5856 DeleteBranchCommand does not clean up upstream configuration
It wrongly uses the full name of the branch to remove the
configuration entries but must use the shortened one.

Change-Id: Ie386a128a6c6beccc20bafd15c2e36254c5f560d
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-10-12 12:22:40 -07:00
Shawn Pearce 4ac3d9814c Merge "Update Tag to use TagCommand API" 2010-10-12 15:05:55 -04:00
Christian Halstrick 285d08d8b7 Fix NPE when calling CreateBranch without explict startpoint
When creating a branch with CreateBranchCommand.call() without
specifying an explicit startPoint HEAD should be used as startPoint.
There was a bug leading to an NPE in such a case.

Change-Id: Ic0a5dc1f33a0987d66c09996c8012c45785500ff
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-12 19:18:53 +02:00
Christian Halstrick be93452842 Remove wrong comment in MergeCommand
There was a wrong javadoc comment telling that MergeCommand
only supports fast-forward merges. This has been fixed.

Change-Id: I7edea779a83528beee34a1753026288c384881ce
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-12 19:18:51 +02:00
Christian Halstrick 0a8d54c286 Remove AmbiguousObjectException from BranchCreateCommand.call()
We wanted to wrap all LowLevel JGit excpetions into a
JGitInternalException so that users of this high-level interface
don't have to explicitly catch all of them. This
was forgotten on BranchCreateCommand.call() and I added
it.

Change-Id: Ie140e99574fb004137c66e80fb92eb6c6d0fa5e1
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-12 19:18:50 +02:00
Shawn O. Pearce e82cadc0dc Delete PatienceDiff
HistogramDiff outperforms it for any case where PatienceDiff needs to
fallback to another algorithm.  Consequently it's not worth keeping
around, because we would always want a fallback enabled.

Change-Id: I39b99cb1db4b3be74a764dd3d68cd4c9ecd91481
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-11 17:05:18 -05:00
Shawn O. Pearce 6048f34c58 Use HistogramDiff by default in DiffFormatter
Its behavior is similar to PatienceDiff, and runs nearly as fast,
often beating the performance of MyersDiff.

Change-Id: I43c3faefa8109f1a68ef57522bec9cf27b5df252
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-11 14:37:00 -07:00
Shawn O. Pearce 14da6e0b9d debug-diff-algorithms: Real world performance test implementations
When working on a difference algorithm's implementation, its generally
more important to care about how it behaves on real-world inputs than
it does on fake inputs created for unit test cases.  Run each
implementation against a number of real-world repositories, looking at
changes between files in each commit.  This gives a better picture of
how a particular algorithm performs.

This test suite run against JGit and linux-2.6 with the current
available algorithms shows HistogramDiff always out-performs
MyersDiff, and by a wide margin on the linux-2.6 sources.  As
HistogramDiff has similar output properties as PatienceDiff, the
resulting edits are probably also more human-readable.  These test
results show that HistogramDiff is a good choice for the default
implementation, and also show that PatienceDiff isn't worth keeping.

  jgit: start at baa83ae
            2686 files,          760 commits
    N=         3 min lines,     3016 max lines
  Algorithm                     Time(ns) (  Time(ns) on   Time(ns) on )
                                         (          N=3        N=3016 )
  ---------------------------------------------------------------------
  histogram_myers              314652100 (         3900        298100 )
  histogram                    315973000 (         3800        302100 )
  patience                     774724900 (         4500        347900 )
  patience_histogram_myers     786332800 (         3700        351200 )
  myers                        819359300 (         4100        379100 )
  patience_myers               843416700 (         3800        348000 )

  linux-2.6.git: start at 85a3318
            4001 files,         2680 commits
    N=         2 min lines,    39098 max lines
  Algorithm                     Time(ns) (  Time(ns) on   Time(ns) on )
                                         (          N=2       N=39098 )
  ---------------------------------------------------------------------
  histogram_myers             1229870000 (         5900       2642700 )
  histogram                   1235654100 (         6000       2695400 )
  patience                    3856546000 (         5900       2627700 )
  patience_histogram_myers    3866728100 (         7000       2624000 )
  patience_myers              4004875300 (         8000       2651700 )
  myers                       9794679000 (         7200       2716200 )

Change-Id: I2502684d31f7851e720356820d04d8cf767f7229
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-11 16:20:00 -05:00
Chris Aniszczyk 7429a9a5aa Merge "Define LowLevelDiffAlgorithm to bypass re-hashing" 2010-10-11 17:18:05 -04:00
Chris Aniszczyk 033ab7f6f0 Merge changes I50dcec81,Ieab28bb3
* changes:
  Fix empty block corner case in PatienceDiff
  Fix infinite loop in PatienceDiff
2010-10-11 15:00:51 -04:00
Shawn O. Pearce 4522b07d0f Fix corrupted large deltas
Large objects stored as deltas get unpacked by JGit into a loose
object, so they are cheaper to access later on.  This unpacking was
broken because TeeInputStream copied the wrong length into the loose
object, sometimes copying too many bytes into the result.  This
created a loose object that did not have the correct content, and
whose length did not match the length denoted in the object header.

Change-Id: I3ce1fd9f3dc5bd195249c7872b3bec49570424a2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-10 18:50:46 -07:00
Shawn O. Pearce 1bd24a23f9 Define LowLevelDiffAlgorithm to bypass re-hashing
When passing to a fallback algorithm, we can avoid creating a new copy
of the hash codes for each sequence by passing in the hashed sequences
directly.  This makes it cheaper to switch from HistogramDiff down to
MyersDiff in a single pass.

Change-Id: Ibf2e81be57c083862eeb134279aed676653bf9b5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-10 14:39:29 -07:00
Shawn O. Pearce 4fc50df97d Fix empty block corner case in PatienceDiff
There is a corner case where we get an EMPTY region during recursion,
but we didn't expect to receive that.  Its harmless to ignore the
region since the region is empty and has no content, so do so rather
than throwing an exception

Change-Id: I50dcec81ecba763072bb739adfab5879fb48b23a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-10 14:39:29 -07:00
Shawn O. Pearce 7a0c126d5f Fix infinite loop in PatienceDiff
Certain inputs caused an infinite loop because the prior match data
couldn't be used as expected.  Rather than incrementing the match
pointer before looking at an element, do it after, so the loop breaks
when we wrap around to the starting point.

Change-Id: Ieab28bb3485a914eeddc68aa38c256f255dd778c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-10 14:39:29 -07:00
Chris Aniszczyk 782dbfc60f Update Push to use latest API
Change-Id: I57ea8634a46472f40046f4ec69de505abbf5f6cf
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-10-10 15:55:03 -05:00
Chris Aniszczyk ae22630bd8 Merge "Cleanup RefUpdateTest" 2010-10-10 16:41:08 -04:00
Mathias Kinzler 7bdef4583b Add "Branch" command
The need for branching becomes more pressing with pull
support: we need to make sure the upstream configuration entries
are written correctly when creating and renaming branches
(and of course are cleaned up when deleting them).
This adds support for listing, adding, deleting and renaming
branches including the more common options.

Bug: 326938
Change-Id: I00bcc19476e835d6fd78fd188acde64946c1505c
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-10-10 15:38:49 -05:00
Shawn O. Pearce 1739af643e Cleanup RefUpdateTest
Application code, including unit tests for storage implementations,
should not extend RevCommit outside of the scope of using it for a
RevWalk.  Its a lot of overhead and unlikely to work long-term.

Instead for the one test that matters, use a custom subclass of the
ObjectId type.  This lets us measure exactly what we are looking for,
which is that the subclass isn't retained.

A lot of other tests were unnecessarily wrapping an object with a
RevCommit and storing that back into the RefUpdate.  This is just
retesting what the earlier no-cache test was doing, and complicated
the test considerably.  Drop that code and just rely on the value that
was configured by the helper method.

Change-Id: I5b31813484eaa306e9bc4de9622dd5bd4846b16d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-08 22:41:18 -07:00
Christian Halstrick be2ddff6a7 Add support for single-slash URI
In bug 323571 it is mentioned that if you call
'toURI().toURL().toString()' on a java.io.File you cannot pass
that string to jgit as an URIish. Problem is that the passed
URI looks like 'file:/C:/a/b.txt' and that we where expecting
double slashes after scheme':'. This fix adds support for this
single-slash file URLs.

Bug: 323571
Change-Id: I866a76a4fcd0c3b58e0d26a104fc4564e7ba5999
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-08 23:57:52 +02:00
Chris Aniszczyk 467f3de0f5 Merge "Update build to use tycho 0.10.0" 2010-10-08 09:59:31 -04:00
Mathias Kinzler db55d13f5f Add "Pull" command
This is the minimal implementation of a "Pull" command. It does not
have any parameters besides the generic progress monitor and timeout.
It works on the currently checked-out branch and assumes that the
configuration contains the keys "branch.<branch name>.remote" and
"branch.<branch name>.merge" to determine the remote configuration
for the fetch and the remote branch name for the merge.

Bug: 303404
Change-Id: I7fe09029996d0cfc09a7d8f097b5d6af1488fa93
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-10-08 08:57:28 -05:00
Christian Halstrick 2160c09dd4 Refactored URI parsing to detect wrong URIs
There where quite some bugs regarding wrong URI parsing. In order
to solve them the parsing has to be refactored. We now have
specialized regexps for 'scheme://host/...', scp URIs and local
file names. Now we can detect problems while parsing 'git://host:/abc' which
was previously not possible.

Bug: 315571
Bug: 292897
Bug: 307017
Bug: 323571
Bug: 317388
Change-Id: If72576576ebb6b9d9dc8b7e51ddd87c9909e8b62
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-08 11:12:09 +02:00
Christian Halstrick 2136095203 Fixed URI regexp regarding user/password part
The regular expression which should handle the
user/password part in an URI was potentially
processing too many chars. This led to problems
when user/pwd and port was specified

Change-Id: I87db02494c4b367283e1d00437b1c06d2c8fdd28
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-08 11:08:12 +02:00
Matthias Sohn dac4386a6d Update build to use tycho 0.10.0
Change-Id: Ib3328379841fa79641fe1cd70cd87ee057eefb1a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-08 11:00:51 +02:00
Christian Halstrick cee08c3027 Fix URIish tests to contain a hostname for git protocol
URIs for the git protocol have to have a hostname.
(see http://www.kernel.org/pub/software/scm/git/docs
/git-clone.html#_git_urls_a_id_urls_a) Some tests tested
URIs like git:/abc.git which is not allowed. Fixed this.

Change-Id: Ia3b8b681ad6592f03b090a874a6e91068a8301fe
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-08 06:44:20 +02:00
Christian Halstrick a1b0ca1807 Introduce commented constants for the segments of an URI regex
The regular expressions used to parse URI's are constructed by
concatenating different segments to a big String. Introduce
String constants for these segements and document them.

Change-Id: If8b9dbaaf57ca333ac0b6c9610c3d3a515c540f9
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-08 06:44:16 +02:00
Matthias Sohn 784d388c49 Externalize strings in TransportHttp
Some strings were not externalized. Also use them in HTTP tests to
ensure that they will also succeed when message bundles are
translated.

Change-Id: Id02717176557e7d57e676e1339cd89f2be88d330
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-08 01:03:17 +03:00
Matthias Sohn 2b98a878b4 Fix HTTP tests
Since 858b2c92 we have a HTTP authentication implementation hence
we now get different exception messages when required authentication
headers are not available. This broke the HTTP tests.

Change-Id: Ie08c1ec37e497c2a6f70a75f7c59f0805812a5cc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-07 23:40:40 +03:00
Chris Aniszczyk 7a6efe1dfc Merge "Support HTTP basic and digest authentication" 2010-10-07 12:25:15 -04:00
Christian Halstrick 0a2b4c1455 Split URI regex strings differently
The strings used to construct the regex to parse
URIs are split differently. This makes it easier
to introduce meaningful String constants later on.

Change-Id: I9355fd42e57e0983204465c5d6fe5b6b93655074
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-06 14:10:24 -05:00
Chris Aniszczyk 47e9e165b8 Add pull operation related constants
Change-Id: Idb7526800e80e17624ec05fb10bbc19e7f744f49
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-10-06 11:46:13 -05:00
Chris Aniszczyk 98a41bd4d0 Add PushCommand API
Change-Id: Iff144a51fdc9a1112a21492c390a873a2b293bc9
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-10-05 13:15:24 -05:00
Shawn O. Pearce 7ba31474a3 Increase core.streamFileThreshold default to 50 MiB
Projects like org.eclipse.mdt contain large XML files about 6 MiB
in size.  So does the Android project platform/frameworks/base.
Doing a clone of either project with JGit takes forever to checkout
the files into the working directory, because delta decompression
tends to be very expensive as we need to constantly reposition the
base stream for each copy instruction.  This can be made worse by
a very bad ordering of offsets, possibly due to an XML editor that
doesn't preserve the order of elements in the file very well.

Increasing the threshold to the same limit PackWriter uses when
doing delta compression (50 MiB) permits a default configured
JGit to decompress these XML file objects using the faster
random-access arrays, rather than re-seeking through an inflate
stream, significantly reducing checkout time after a clone.

Since this new limit may be dangerously close to the JVM maximum
heap size, every allocation attempt is now wrapped in a try/catch
so that JGit can degrade by switching to the large object stream
mode when the allocation is refused.  It will run slower, but the
operation will still complete.

The large stream mode will run very well for big objects that aren't
delta compressed, and is acceptable for delta compressed objects that
are using only forward referencing copy instructions.  Copies using
prior offsets are still going to be horrible, and there is nothing
we can do about it except increase core.streamFileThreshold.

We might in the future want to consider changing the way the delta
generators work in JGit and native C Git to avoid prior offsets once
an object reaches a certain size, even if that causes the delta
instruction stream to be slightly larger.  Unfortunately native
C Git won't want to do that until its also able to stream objects
rather than malloc them as contiguous blocks.

Change-Id: Ief7a3896afce15073e80d3691bed90c6a3897307
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-10-04 14:04:47 -05:00
Chris Aniszczyk b0bfa8044a Merge "Update Fetch to use FetchCommand API" 2010-10-01 12:02:25 -04:00
Chris Aniszczyk 44b4f458a8 Merge "Add reflog message to TagCommand" 2010-09-29 10:09:43 -04:00
Robin Rosenberg afedfc2530 Comment the use of System.gc in LocalDiskRepositoryTestCase
Change-Id: Ic5e9bda4275006ef3bf6ea6255ddf1c0eecc3770
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-09-28 23:27:20 +02:00
Robin Rosenberg 96f45e35f3 Shut up findbugs/protect the shutdownHook in LocalDiskRepositoryTestcase
Singleton references should be protected from multiple threads. As far as we
know this cannot happen as JUnit is used today since we currently don't run
tests in parallel, but now this code will not prevent anyone.

Change-Id: I29109344d2e8025fa2a3ccaf7c2c16469544ce05
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-09-28 23:27:04 +02:00
Shawn O. Pearce 858b2c92e8 Support HTTP basic and digest authentication
Natively support the HTTP basic and digest authentication methods
by setting the Authorization header without going through the JREs
java.net.Authenticator API.  The Authenticator API is difficult to
work with in a multi-threaded server environment, where its using
a singleton for the entire JVM.  Instead compute the Authorization
header from the URIish user and pass, if available.

Change-Id: Ibf83fea57cfb17964020d6aeb3363982be944f87
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-09-28 08:42:47 +02:00
Chris Aniszczyk e5c217bcf3 Merge "Use only a single instance for NLS translation bundles" 2010-09-27 17:59:36 -04:00
Chris Aniszczyk 6b6c8dd01b Update Fetch to use FetchCommand API
Change-Id: I06ddc74f1ef658f4876e2bbcc3eaad3475a5371e
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-09-27 10:16:22 -05:00
Chris Aniszczyk 153c796bce Merge "Update FetchCommand with dry run and thin options" 2010-09-27 10:07:49 -04:00
Robin Rosenberg 65ed25b34e Return the documented value from DirCacheCheckout.checkout
Change-Id: I34d773b18e6a1ee05774d7b9471f9915c48aa63e
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-09-27 10:51:07 +02:00
Christian Halstrick 82d75f31d4 Merge "Extend merge support for bare repositories" 2010-09-27 04:46:06 -04:00
Robin Rosenberg be9d096986 Use only a single instance for NLS translation bundles
As findbugs pointed out, there was a small risk for creating multiple instances of
translation bundles. If that happens, drop the second instance.

Change-Id: I3aacda86251d511f6bbc2ed7481d561449ce3b6c
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2010-09-26 09:46:35 +02:00