Commit Graph

981 Commits

Author SHA1 Message Date
Shawn Pearce 009507ca2e Merge "Exclude FindBugs warning about uninitialized read" 2010-11-01 17:24:20 -04:00
Shawn O. Pearce aa09599a3d Fix ugly diff showing insertion of new method
When adding a new method near the end of the sequence we want to
show the full method inserted, and not tear the prior method due
to the common trailing curly brace being consumed as part of the
common end region of the sequences.

Bug: 328895
Change-Id: I233bc40445fb5452863f5fb082bc3097433a8da6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-01 14:10:00 -07:00
Shawn O. Pearce d9b224aeb6 Delete DiffPerformanceTest
This test isn't that useful.  The better way to evaluate diff
algorithm performance is to run `jgit debug-diff-algorithms` over
real-world repositories, such as linux-2.6.git.  Whenever we modify
an algorithm we should manually verify that its runtime performance
doesn't get any worse than it already is.

Change-Id: I0beed3a5a8a537c958a5a6438a1283f97fa2097a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-01 14:09:51 -07:00
Shawn O. Pearce b88b693a3d Fix broken HistogramDiff
HistogramDiff failed on cases where the initial element for the LCS
was actually very common (e.g. has 20 occurrences), and the first
element of the inserted region after the LCS was also common but
had fewer occurrences (e.g. 10), while the LCS also contained a
unique element (1 occurrence).

This happens often in Java source code.  The initial element for
the LCS might be the empty line ("\n"), and the inserted but common
element might be "\t/**\n", with the LCS being a large span of
lines that contains unique method declarations.  Even though "/**"
occurs less often than the empty line its not a better LCS if the
LCS we already have contains a unique element.

The logic in HistogramDiff would normally have worked fine, except I
tried to optimize scanning of B by making tryLongestCommonSequence
return the end of the region when there are matching elements
found in A.  This allows us to skip over the current LCS region,
as it has already been examined, but caused us to fail to identify
an element that had a lower occurrence count within the region.

The solution used here is to trade space-for-time by keeping a
table of A positions to their occurrence counts.  This allows the
matching logic to always use the smallest count for this region,
even if the smallest count doesn't appear on the initial element.

The new unit test testEdit_LcsContainsUnique() verifies this new
behavior works as expected.

Bug: 328895
Change-Id: Id170783b891f645b6a8cf6f133c6682b8de40aaf
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-11-01 14:08:45 -07:00
Robin Stocker b70d8853f8 Exclude FindBugs warning about uninitialized read
This gets rid of the "Uninitialized read of blockIndex" warning.

Change-Id: Ieb31b5059d7b9a6adff2251baf179bda5f82e7a5
2010-11-01 00:01:47 +01:00
Shawn O. Pearce 33ae28b482 Correct typo in HistogramDiffIndex Javadoc
Change-Id: I8bd2e81fcc14aa86919c504f1d0001944dea50b2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-29 17:02:26 -07:00
Shawn Pearce b216c80255 Merge "Exclude FindBugs warnings about Cloneable" 2010-10-29 10:50:07 -04:00
Shawn Pearce a434172079 Merge "Remove two "Dead store to local variable" warnings" 2010-10-29 10:49:45 -04:00
Shawn Pearce 1572c9f4a7 Merge "Use entrySet() instead of keySet()" 2010-10-29 10:48:18 -04:00
Shawn Pearce 6bddae5775 Merge "Use readFully() instead of read()" 2010-10-29 10:47:26 -04:00
Shawn Pearce a8140e3c16 Merge "Use Character.valueOf instead of new Character" 2010-10-29 10:43:55 -04:00
Shawn Pearce 68f6c49ee2 Merge "Remove unnecessary null check" 2010-10-29 10:43:32 -04:00
Robin Stocker 8cbed3462e Make private final field static
It's used as a constant.

Change-Id: Ic267e8cb5b62228de15e134cd80725df592a0171
2010-10-29 15:27:10 +02:00
Robin Stocker d36c80fd04 Remove unnecessary null check
The field monitor is never null, it's a NullProgressMonitor when not
explicitly set.

Change-Id: I8ce703a32c28ce5c3455efeb7ed5f5c9a443cbef
2010-10-29 15:12:48 +02:00
Robin Stocker b52df1839a Use Character.valueOf instead of new Character
Otherwise a new Character is allocated each time instead of
using the cache.

Change-Id: I648d0b012f66ba9dc46a37a390986f9c61e5a19c
2010-10-29 15:04:27 +02:00
Robin Stocker 96bea14c7b Use readFully() instead of read()
Fixes the "Method ignores results of InputStream.read()" warning.

This is the only place where read() was used instead of readFully()
and the return value was not checked. So it was either an oversight
or should be documented. This change assumes it was an oversight.

Change-Id: I859404a7d80449c538a552427787f3e57d7c92b4
2010-10-29 14:52:52 +02:00
Robin Stocker 3b44b22609 Use entrySet() instead of keySet()
The value was accessed every time in the loop body with get(),
so use the more efficient entrySet().

Change-Id: I91d90cbd0b0d03ca4a3db986c58b8d80d80f40a4
2010-10-29 14:41:39 +02:00
Robin Stocker 3f78650c9a Remove two "Dead store to local variable" warnings
Change-Id: I950de82db15c4610dc5a94f304279971daef971e
2010-10-29 14:37:42 +02:00
Robin Stocker 90c11cbaeb Exclude FindBugs warnings about Cloneable
This was already disabled in the Eclipse preferences for the project.
With this, Hudson should also ignore it.

Change-Id: I7a6b9a20451dc5ba9a61553248b5f4b6c6c7a78b
2010-10-29 14:26:33 +02:00
Shawn Pearce 7f939ba86e Merge "Fix Severe Bug in Merge Algorithm" 2010-10-28 15:54:36 -04:00
Christian Halstrick beeb1f6d08 Fix Severe Bug in Merge Algorithm
As described in Bug 328551 there was a bug that the merge algorithm
was not always reporting conflicts when the same line was deleted
and modified. This problem was introduced during commit
0c017188b4 when reported conflicts have
been checked for common pre- and suffixes.

This was fixed here by better determining whether after stripping
off common prefixes and suffixes from a conflicting region there
is still some conflicting part left.
I also added a unit test to test this situation.

Bug: 328551
Change-Id: Iec6c9055d00e5049938484a27ab98dda2577afc4
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-28 21:41:42 +02:00
Mathias Kinzler 7668a46282 PullCommand: support upstream configuration for local branches
When creating a local branch based on another local branch, the
upstream configuration contains "." as origin and the source branch
as "merge". The PullCommand should support this by skipping the
fetch step altogether and use the base branch to merge with.

Change-Id: I260a1771aeeffca5b0161d1494fd63c672ecc2a6
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2010-10-28 09:18:02 -07:00
Shawn Pearce 0544c9af41 Merge "Fix FQCN of moved classes in FindBugsExcludeFilter.xml" 2010-10-28 11:47:44 -04:00
Shawn Pearce 70b8a470e7 Merge "Make AbbreviatedObjectId serializable" 2010-10-28 11:47:06 -04:00
Shawn Pearce 2f7e2f82de Merge "Fix oddness check in MyersDiff for negative numbers" 2010-10-28 11:46:41 -04:00
Robin Stocker 80a4ea95e4 Make AbbreviatedObjectId serializable
AmbiguousObjectException contains an AbbreviatedObjectId and is
supposed to be serializable, so it should be serializable as well.

Change-Id: I8056e78aee20fdd3cb9600b52cd8ed988544293d
2010-10-28 17:40:15 +02:00
Robin Stocker a7a0e17b2b Fix FQCN of moved classes in FindBugsExcludeFilter.xml
FindBugs would generate warnings for these even though they should
be ignored.

Change-Id: Ieccadbf11fd55853541c04857d8e79a4db014cb4
2010-10-28 17:38:16 +02:00
Robin Stocker db35d91fa6 Fix oddness check in MyersDiff for negative numbers
It's probably not possible that these numbers are negative in the
algorithm, but it's cleaner this way and gets rid of three more
FindBugs warnings.

Change-Id: Ifbce4e2c787fb9a7cd309c605e8d86211ef8a352
2010-10-28 17:37:21 +02:00
Robin Stocker 258f516abe Fix FindBugs and Eclipse warnings in org.eclipse.jgit.ui
Change-Id: Ie6b3ff7d470cc9b7044fd6288cbf86dcc58220eb
2010-10-28 16:37:49 +02:00
Shawn O. Pearce 79ca8a2d19 Merge "Call ProgressMonitor.update() from main thread" 2010-10-27 11:37:55 -04:00
Shawn O. Pearce bdf535de4f Call ProgressMonitor.update() from main thread
Don't permit transient worker threads to access the underlying output
stream of a ProgressMonitor, as they might get marked as the stream's
writer thread.  Instead proxy update events from the workers back onto
the application's real work thread.  This ensures that the stream only
sees a single thread, and its the thread that will remain alive for
the entire life cycle of the operation.

This fixes IOException("Write end dead") during local repository fetch
when threaded delta search is enabled.  One of the transient delta
search threads became the designated writer for the pipe, and when it
terminated the reader end thought the writer was dead, even though the
main writer thread was still executing in PackWriter.

Bug: 326557
Change-Id: I01d1b20a3d7be1c0b480c7fb5c9773c161fe5c15
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-27 08:37:31 -07:00
Christian Halstrick 2c38e5d461 Prevent endless loop of events fired by RefsDirectory
RefsDirectory fires a RefsChangedEvent when it detect that one
ref changed (new, modified, deleted). But there was a potential
of wrong events beeing fired leading to a endless loop in EGit.
Problem is that when calling getRefs(ALL) we don't want to report
additional refs and by that we remove the additional refs from
the list of "refs reported upwards last time". We fire an
RefsChangedEvent because we think that the special refs are not
there anymore.
I fixed this by removing eventing for the additional refs. Another
alternative would be to always scan also for additional refs and
put them in the list of refs. But getRefs(ALL) would then remove
the additional refs again. I didn't do that for performance reasons
and also because I am not sure whether we want evnting for
additional refs.

Change-Id: Icb9398b55a8c6bbf03e38f6670feb67754ce91e0
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-27 10:52:42 +02:00
Lluis Sanchez 07cae6e6c1 Optimize DirCacheCheckout
When checking out a tree, files that are identical to the file in
the current index and working directory don't need to be updated.

Change-Id: I9e025a53facd42410796eae821baaeff684a25c5
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2010-10-26 13:27:40 -05:00
Christian Halstrick e10808e658 Add option to select diff algorithm for diff command
The diff command in the pgm package was enhanced to allow
choosing the diff algorithm (currently myers or histogram)

Change-Id: I72083e78fb5c92868eb5d8ec512277d212a39349
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-26 18:07:49 +02:00
Shawn Pearce 8472aa0319 Merge "[findbugs] Respect exclude filter in maven build" 2010-10-25 11:06:15 -04:00
Christian Halstrick c234860765 Merge "Allow setting a filter in IndexDiff" 2010-10-25 08:37:59 -04:00
Jens Baumgart 6f3b089188 Allow setting a filter in IndexDiff
IndexDiff now allows to set an additional filter. This can be used
e.g. for restricting the tree walk to a given set of files.

Change-Id: I642de17e74b997fa0c5878c90631f6640ed70bdd
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
2010-10-25 13:00:13 +02:00
Christian Halstrick a4f7992dfb Add support for special symref FETCH_HEAD and MERGE_HEAD
The RefDirectory class was not returning FETCH_HEAD and
MERGE_HEAD when trying to get all refs via getRefs(RefDatabase.ALL).
This fix adds constants for FETCH_HEAD and ORIG_HEAD and adds a
new getter getAdditionalRefs() to get these additional refs.
To be compatible with c git the getRefs(ALL) method will not return
FETCH_HEAD, MERGE_HEAD and ORIG_HEAD.

Change-Id: Ie114ca92e9d5e7d61d892f4413ade65acdc08c32
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-25 00:36:16 +02:00
Matthias Sohn 8067197049 [findbugs] Fix illegal format specifier
For integral arguments the precision is not applicable, would cause a
runtime exception when executed, see
http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html#syntax

Change-Id: I4738c64c1153a8d4ef5430e15d0fe54f0a37949f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-23 23:56:06 +02:00
Matthias Sohn f6a15f049b [findbugs] Respect exclude filter in maven build
Change-Id: Ic29310dc14f120ebdb49d33cbf4bd6d380ae1393
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-23 23:31:21 +02:00
Matthias Sohn ffc010fda4 [findbugs] Static comparator made final
Fixing FindBugs warning MS_SHOULD_BE_FINAL.

Change-Id: Ic69e6f6425e0a8950ce809eb3894f48a33e860aa
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-23 22:25:29 +02:00
Chris Aniszczyk 241ab22735 Add FindBugs and CPD to the build.
We need to use findbugs-maven-plugin:2.3.2-SNAPSHOT
since otherwise build fails with maven-3.0 [1], [2].
We should switch to the release version as soon
as this becomes available.

[1] http://www.sonatype.com/people/2010/10/maven-3-0-has-landed/
[2] http://jira.codehaus.org/browse/MFINDBUGS-122

Bug: 327799
Change-Id: I1c57f81cf6f0450e56411881488c4ee754e458e3
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-23 12:26:00 +02:00
Shawn O. Pearce d00420ae6e Make ObjectDirectory getPacks() work the first time
If an object hasn't been accessed yet the pack list for a repository
may not have been scanned from disk.  If an application (e.g. the dumb
transport servlet support code) asks for the pack list for an
ObjectDirectory, we should load it immediately.

Change-Id: I93d7b1bca422d905948e8e83b2afa83c8894a68b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-20 00:51:44 +02:00
Shawn O. Pearce e51e06946f Update CachedObjectDirectory when inserting objects
If an ObjectInserter is created from a CachedObjectDirectory, we need
to ensure the cache is updated whenever a new loose object is actually
added to the loose objects directory, otherwise a future read from an
ObjectReader on the CachedObjectDirectory might not be able to open
the newly created object.

We mostly had the infrastructure in place to implement this due to the
injection of unpacked large deltas, but we didn't have a way to pass
the ObjectId from ObjectDirectoryInserter to CachedObjectDirectory,
because the inserter was using the underlying ObjectDirectory and not
the CachedObjectDirectory.  Redirecting to CachedObjectDirectory
ensures the cache is updated.

Change-Id: I1f7bdfacc7ad77ebdb885f655e549cc570652225
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-17 23:10:47 -07:00
Shawn O. Pearce f5e5b98c3a IndexPack: Make translated progress messages non-static
These messages may need to change depending on the current
thread's configured locale, and thus cannot be static.

Change-Id: I96751a63852ec9c4bf6c47edadcf8752700543df
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-17 22:21:38 -07:00
Matthias Sohn dc5027dcef Merge "Allow pgm Main to be extended" 2010-10-17 18:21:49 -04:00
Christian Halstrick 609c6dc358 Fix possible NPE in DirCacheCheckout
There was a chance that we hit a NPE which doing a checkout
with DirCacheCheckout when there is no HEAD (e.g. initial
checkout). This is fixed here.

Change-Id: Ie3b8cae21dcd90ba8352823ea94a700f8ee9221a
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2010-10-18 00:19:13 +02:00
Shawn O. Pearce 0b51a45688 Allow pgm Main to be extended
3rd party packages that use repository types other than FileRepository
may wish to extend our pgm package and implement their own resolution
scheme for repository "names" that are passed in by the --git-dir
command line option.  Make that possible by allowing the package to
extend the Main class and override the lookup.

This is primarily useful when developing new storage implementations
and trying to experiment with the results, without linking all of it
into the core JGit package.

Change-Id: Id30e168da16341e5da43365688a63aa30c7b7e2c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-16 21:47:10 -07:00
Christian Halstrick 9b4876cedf Add Cherry-Pick command
Implemented the initial version of a cherry-pick command.
A correct error handling is missing (what happens if the
checkout fails, the cherry-pick leads to conflicts etc).
But straightforward cherry-picks works.

Change-Id: I235c0eb3a7a2d5bdfe40400f1deed06f29d746e1
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2010-10-15 16:38:34 +02:00
Shawn O. Pearce 4c7e100910 Add getString utility functions to RawText
These routines can be useful when debugging, because we can add an
expression to the Eclipse "Expressions" panel to show the text that
appears on a line.  Gerrit Code Review also uses these in its own
subclass of RawText in order to format patch files, so pulling it up
to be part of core JGit may help other applications too.

Change-Id: I20a6b112e3403ecfc1c2715ae75dcecc1a85b167
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2010-10-13 20:50:44 -07:00