* Re: [PATCH] Have git-revert, git-cherry-pick cleanup ./.msg upon successful completion.
From: Shawn O. Pearce @ 2007-05-08 1:35 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Gerrit Pape, git, Alex Riesen
In-Reply-To: <7vps5efnv8.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
> "Shawn O. Pearce" <spearce@spearce.org> writes:
>
> > What about this change instead? We make cherry-pick/revert
> > use the same temporary file as merge, which is under .git/
> > (something Alex mentioned he wanted). I think the use of ".msg"
> > in cherry-pick/revert has always just been a bug, and not a feature,
> > so I'm really not against changing things around like this.
>
> While I would not say this is not an improvement, this makes
> MERGE_MSG even less about merges and pushes us away from a
> sensible "git whatnow".
I think that ship has already sailed. Look at builtin-revert.c
on:
333 const char *target = git_path("MERGE_MSG");
We're already using MERGE_MSG to prep the message for a conflicted
cherry-pick or revert that the user needs to resolve by hand. I
think we do the same thing in git-rebase, don't we?
Gerrit's patch to try and use COMMIT_MSG feels wrong to me, as
git-commit overwrites that file with what it gets from its "input".
I agree my patch steps us further from a "git whatnow", but we're
already in deep with MERGE_MSG. We might as well keep that existing
convention that it can be used to prep the commit message for the
next git-commit invocation, and record other data somehow for the
"git whatnow" case.
--
Shawn.
^ permalink raw reply
* Re: [PATCH 0/6] gitweb: Add combined diff support
From: Junio C Hamano @ 2007-05-08 1:31 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
In-Reply-To: <11784930091585-git-send-email-jnareb@gmail.com>
I've minimally tried this on my private machine. Looks pretty
nice for simple merges, but I think we would want --cc not -c
most of the time.
Pushed out in 'next'. Thanks.
^ permalink raw reply
* Re: [PATCH/RFC] diff: Make numstat machine friendly also for renames
From: Junio C Hamano @ 2007-05-08 1:10 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
In-Reply-To: <11785850223782-git-send-email-jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> Instead of saving human readable rename information in the 'name'
> field when diffstat info is generated, do it when writing --stat
> output. Change --numstat output to be machine friendly.
>
> This makes result of git-diff --numstat more suitable for machines
> also when renames are involved, by using format similar to the one for
> renames in the raw diff format, instead of the format more suited for
> humans.
>
> The numstat format for rename is now
>
> added deleted TAB path for "src" TAB path for "dst" LF
>
> or if -z option is used
>
> added deleted TAB path for "src" NUL NUL path for "dst" NUL
Why two NULs?
There are already a handful in-tree users of --numstat, and also
a few tests scripts. I think you would need to adjust them.
> The goal of this change is to make it possible to generate HTML
> diffstat against first parent for merge commits in gitweb. The current
> notation for renames, which looks for example like below:
>
> t/{t6030-bisect-run.sh => t6030-bisect-porcelain.sh}
I do not have much objection against teaching --numstat to show
the preimage pathnames. I do not disagree with "the goal" of
showing "git diff --stat -M $commit^1 $commit" even for merge
commit.
But I do not see the connection between the two. Why aren't you
parsing --summary?
Have you actually _tested_ your patch?
> @@ -949,11 +955,19 @@ static void show_numstat(struct diffstat_t* data,
> printf("-\t-\t");
> else
> printf("%d\t%d\t", file->added, file->deleted);
> - if (options->line_termination && !file->is_renamed &&
> + if (options->line_termination &&
> quote_c_style(file->name, NULL, NULL, 0))
> quote_c_style(file->name, NULL, stdout, 0);
> else
> fputs(file->name, stdout);
> + if (file->is_renamed) {
> + printf("%s", options->line_termination ? "\t" : "\0\0");
I know you marked it as RFC; but it is impolite to request
comments from other people on a patch that does not do what you
intended to do, without marking "this is untested". It would
waste people's time.
^ permalink raw reply
* git rebase chokes on directory -> symlink -> directory
From: H. Peter Anvin @ 2007-05-08 1:08 UTC (permalink / raw)
To: Git Mailing List
The following tree:
http://git.kernel.org/?p=linux/kernel/git/hpa/linux-2.6-newsetup.git;a=summary
... has one commit which changes arch/x86_64/boot from a directory to a
symlink, and another one which changes it back. Apparently as a result,
git rebase dies horribly; on the first change it requires manual fixup,
but it crashes on the second, with or without -m.
The specific task attempted is to rebase the main branch of that tree
onto the current Linus tree, a989705c4cf6e6c1a339c95f9daf658b4ba88ca8.
-hpa
^ permalink raw reply
* [PATCH/RFC] diff: Make numstat machine friendly also for renames
From: Jakub Narebski @ 2007-05-08 0:43 UTC (permalink / raw)
To: git; +Cc: Jakub Narebski
Instead of saving human readable rename information in the 'name'
field when diffstat info is generated, do it when writing --stat
output. Change --numstat output to be machine friendly.
This makes result of git-diff --numstat more suitable for machines
also when renames are involved, by using format similar to the one for
renames in the raw diff format, instead of the format more suited for
humans.
The numstat format for rename is now
added deleted TAB path for "src" TAB path for "dst" LF
or if -z option is used
added deleted TAB path for "src" NUL NUL path for "dst" NUL
When -z option is not used, ", TAB, LF, and backslash characters in
pathnames are represented as \", \t, \n, and \\, respectively. If any
character needs to be quoted then pathnames are enclosed in double
quotes.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This change increases memory footprint a bit, as struct diffstat_file
is wider by sizeof(char *) wide field, which is NULL except for
renames.
I have thought about storing it using one pointer to fragment of
memory of the form "dst name \0 src name \0", but this trades a little
memory for CPU time.
The goal of this change is to make it possible to generate HTML
diffstat against first parent for merge commits in gitweb. The current
notation for renames, which looks for example like below:
t/{t6030-bisect-run.sh => t6030-bisect-porcelain.sh}
is not easy to parse by machines (note that filename may contain
"=>"), but easy to understand _usually_ by humans.
P.S. By the way, what is the difference between quote_one and
quote_c_style, i.e. when one calls one and when the other?
diff.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
index 7bbe759..568c59b 100644
--- a/diff.c
+++ b/diff.c
@@ -703,6 +703,7 @@ struct diffstat_t {
int alloc;
struct diffstat_file {
char *name;
+ char *from_name;
unsigned is_unmerged:1;
unsigned is_binary:1;
unsigned is_renamed:1;
@@ -722,12 +723,13 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,
diffstat->alloc * sizeof(x));
}
diffstat->files[diffstat->nr++] = x;
+ x->name = xstrdup(name_a);
if (name_b) {
- x->name = pprint_rename(name_a, name_b);
+ x->from_name = xstrdup(name_b);
x->is_renamed = 1;
}
else
- x->name = xstrdup(name_a);
+ x->from_name = NULL;
return x;
}
@@ -805,7 +807,7 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
struct diffstat_file *file = data->files[i];
int change = file->added + file->deleted;
- if (!file->is_renamed) { /* renames are already quoted by pprint_rename */
+ if (!file->is_renamed) { /* renames are quoted by pprint_rename */
len = quote_c_style(file->name, NULL, NULL, 0);
if (len) {
char *qname = xmalloc(len + 1);
@@ -813,6 +815,10 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
free(file->name);
file->name = qname;
}
+ } else {
+ char *qname = pprint_rename(file->name, file->from_name);
+ free(file->name);
+ file->name = qname;
}
len = strlen(file->name);
@@ -949,11 +955,19 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options)
printf("-\t-\t");
else
printf("%d\t%d\t", file->added, file->deleted);
- if (options->line_termination && !file->is_renamed &&
+ if (options->line_termination &&
quote_c_style(file->name, NULL, NULL, 0))
quote_c_style(file->name, NULL, stdout, 0);
else
fputs(file->name, stdout);
+ if (file->is_renamed) {
+ printf("%s", options->line_termination ? "\t" : "\0\0");
+ if (options->line_termination &&
+ quote_c_style(file->from_name, NULL, NULL, 0))
+ quote_c_style(file->from_name, NULL, stdout, 0);
+ else
+ fputs(file->from_name, stdout);
+ }
putchar(options->line_termination);
}
}
--
1.5.1.3
^ permalink raw reply related
* Re: FFmpeg considering GIT
From: Randal L. Schwartz @ 2007-05-07 23:21 UTC (permalink / raw)
To: Gábor Farkas
Cc: Jan Hudec, Paul Mackerras, Linus Torvalds, Karl Hasselstr?m,
Junio C Hamano, Carl Worth, Michael Niedermayer, Git Mailing List
In-Reply-To: <463FA3C5.70101@nekomancer.net>
>>>>> "Gábor" == Gábor Farkas <gabor@nekomancer.net> writes:
Gábor> GTK does not work natively on OSX (it only works using the X11 server ).
But "Tk" works fine. I don't fire up X11, except rarely. And gitk works fine.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
^ permalink raw reply
* gitweb css - pixels?!
From: Chris Riddoch @ 2007-05-07 23:13 UTC (permalink / raw)
To: git
Hi, folks.
I've been gradually converting my ~/src directory full of tarballs
I've found interesting enough to download to a ~/repos/ directory
containing bare git repositories of the projects. I was thinking it
might be worth my while to set up gitweb so I can peruse my collection
of projects.
I noticed myself squinting, on my 1400x1050 laptop screen, at the 10
and 12-*pixel* font settings gitweb's CSS specifies before thinking to
myself that I should bring this to the list's attention.
I'm no CSS guru, or I'd just provide a patch. It seems that *all* the
measurements specified in the CSS file are in pixels, not ems or
percentages. There's got to be a better way. I can't be the only
person who would rather use my nice screen to render attractive,
readable fonts rather than to render the smallest possible fonts?
--
epistemological humility
Chris Riddoch
^ permalink raw reply
* Re: [FAQ?] Rationale for git's way to manage the index
From: Daniel Barkalow @ 2007-05-07 22:23 UTC (permalink / raw)
To: Guilhem Bonnefille; +Cc: git
In-Reply-To: <8b65902a0705070440t40889af0p1fb8dbf7e2a072e4@mail.gmail.com>
On Mon, 7 May 2007, Guilhem Bonnefille wrote:
> Hi,
>
> As a newbie, I'm agree with Matthieu: the Git's index is surprising
> for people coming from CVS/SVN (mindless?) world. So a good
> documentation about this, even in tutorials, is really important.
I think that the confusing thing isn't really the index, but the fact that
git, by default, will make commits where the content in the commit is
different from the content in the working directory. (In fact, you can use
git-hash-object --stdin and git-update-index --cacheinfo to do a commit
which shares no content at all with any present or past state of the
working directory!)
In other version control systems, you have to use some option or argument
to make that kind of non-matching commit (and you're generally limited in
how your commits can fail to match the working directory). I think the
confusion is that git requires an option to say that you want the commit
to match the working directory, as opposed to creating a non-matching
commit, which is generally the more advanced and more unusual case.
I think this is why people mostly get to understand the index by way of
using it to resolve a conflicted merge: in that case, you have to make the
index match the working directory before committing, and the index tracks
your progress in reaching this state, which is the intuitive use of the
index in normal situations.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Re: FFmpeg considering GIT
From: Gábor Farkas @ 2007-05-07 22:10 UTC (permalink / raw)
To: Jan Hudec
Cc: Paul Mackerras, Linus Torvalds, Karl Hasselstr?m, Junio C Hamano,
Carl Worth, Michael Niedermayer, Git Mailing List
In-Reply-To: <20070507175222.GA13927@efreet.light.src>
Jan Hudec wrote:
> On Mon, May 07, 2007 at 22:13:44 +1000, Paul Mackerras wrote:
>> I have thought about rewriting it in a different language, but I
>> haven't found anything that really appeals. I don't want to go to
>> C/GTK or C/Qt since that would make it hard to port to Windows and
>
> C/Gtk would be perfectly portable. As would C++/Gtk, Python/Gtk and Perl/Gtk.
> C++/Qt4 would be perfectly portable as well, so choose whichever you find
> easier to work with. For C/C++ they are on par, for Python/Perl/Ruby I think
> Gtk has better bindings.
>
>> MacOS AFAIK.
GTK does not work natively on OSX (it only works using the X11 server ).
QT works fine.
gabor
^ permalink raw reply
* Re: [PATCH] Use GIT_OBJECT_DIR for temporary files of pack-objects
From: Dana How @ 2007-05-07 21:59 UTC (permalink / raw)
To: Alex Riesen; +Cc: git, Junio C Hamano, danahow
In-Reply-To: <20070507213347.GB3436@steel.home>
On 5/7/07, Alex Riesen <raa.lkml@gmail.com> wrote:
> Dana How, Mon, May 07, 2007 19:51:24 +0200:
> > On 5/7/07, Alex Riesen <raa.lkml@gmail.com> wrote:
> > >I'm not sure about fsck cleaning up after crashed/killed pack-objects:
> > >not sure I _can_ detect if the temp files really are just leftovers.
> >
> > It looks like you create temp file in objects , not objects/pack .
> >
> > So a rule could be : packs left in the former are crashed/killed,
> > and packs in the latter are complete?
>
> How do you know for sure that they are _left_ already?
Ah, e.g. you're packing and fsck'ing at the same time?
Then you can't know. Never mind...
> > You should also look at $PACKTMP in git-repack.sh .
> > In it $GIT_DIR should probably be $GIT_OBJECT_DIRECTORY ?
>
> I think it should, but it is already not the working directory, so my
> original complaint does not apply
OK, if I have to further change my --max-pack-size patchset
which touches git-repack.sh, I'll roll this in.
Thanks,
--
Dana L. How danahow@gmail.com +1 650 804 5991 cell
^ permalink raw reply
* Eclipse support status (was: Re: [EGIT 00/10] This weeks Eclipse patches)
From: Grzegorz Kulewski @ 2007-05-07 21:35 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: spearce, git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
On Mon, 7 May 2007, Robin Rosenberg wrote:
> A random collection of improvements to the Eclipse
> plugin.
Hi,
I wanted to ask about current status of Git-Eclipse support. Is this
plugin able to actually do anything or not? What works and what does not?
Can it be used by developers using Git? Or maybe git-svn or git-cvsserver
are better?
If it it not usable at the moment do you have any idea when it may be
usable? I know several developers really waiting for such support even
early or beta quality.
Thanks,
Grzegorz Kulewski
^ permalink raw reply
* Re: [PATCH] Use GIT_OBJECT_DIR for temporary files of pack-objects
From: Alex Riesen @ 2007-05-07 21:33 UTC (permalink / raw)
To: Dana How; +Cc: git, Junio C Hamano
In-Reply-To: <56b7f5510705071051l75d701d7r94b7c4629cc425f@mail.gmail.com>
Dana How, Mon, May 07, 2007 19:51:24 +0200:
> On 5/7/07, Alex Riesen <raa.lkml@gmail.com> wrote:
> >I'm not sure about fsck cleaning up after crashed/killed pack-objects:
> >not sure I _can_ detect if the temp files really are just leftovers.
>
> It looks like you create temp file in objects , not objects/pack .
>
> So a rule could be : packs left in the former are crashed/killed,
> and packs in the latter are complete?
How do you know for sure that they are _left_ already?
> You should also look at $PACKTMP in git-repack.sh .
> In it $GIT_DIR should probably be $GIT_OBJECT_DIRECTORY ?
I think it should, but it is already not the working directory, so my
original complaint does not apply
^ permalink raw reply
* [EGIT PATCH 10/10] Enable a tooltip in the history view
From: Robin Rosenberg @ 2007-05-07 21:30 UTC (permalink / raw)
To: spearce; +Cc: git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
This tooltip show the comment in full rather than the first line only.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/egit/ui/GitHistoryPage.java | 27 +++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
index 57fefcc..e5d92fe 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
@@ -48,9 +48,11 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -136,6 +138,31 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
});
+ tree.addMouseMoveListener(new MouseMoveListener() {
+ TreeItem lastItem;
+ public void mouseMove(MouseEvent e) {
+ TreeItem item = tree.getItem(new Point(e.x,e.y));
+ if (item != null && item!=lastItem) {
+ IFileRevision rev = (IFileRevision) item.getData();
+ String commitStr=null;
+ if (appliedPatches!=null) {
+ String id = rev.getContentIdentifier();
+ if (!id.equals("Workspace")) {
+ StGitPatch patch = (StGitPatch) appliedPatches.get(new ObjectId(id));
+ if (patch!=null)
+ commitStr = "Patch: "+patch.getName();
+ } else {
+ commitStr = "Workspace:";
+ }
+ }
+ if (commitStr == null)
+ commitStr = "Commit: "+rev.getContentIdentifier();
+ tree.setToolTipText(commitStr+"\nAuthor:\t"+rev.getAuthor()+"\nDate:\t"+new Date(rev.getTimestamp())+"\n\n"+rev.getComment());
+ }
+ lastItem = item;
+ }
+ });
+
tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// update the current
^ permalink raw reply related
* [EGIT PATCH 09/10] Run history refresh in background
From: Robin Rosenberg @ 2007-05-07 21:30 UTC (permalink / raw)
To: spearce; +Cc: git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
Don't wait in the UI for history refresh. If a history is being
computed when a new refresh is requested, abort the first one and
start a new history computation.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../egit/core/internal/mapping/GitFileHistory.java | 40 ++++++++-----
.../internal/mapping/GitFileHistoryProvider.java | 2 -
.../src/org/spearce/egit/ui/GitHistoryPage.java | 73 +++++++++++++++++------
.../src/org/spearce/jgit/lib/Walker.java | 4 +
.../tst/org/spearce/jgit/lib/T0007_WalkerTest.java | 4 +
5 files changed, 86 insertions(+), 37 deletions(-)
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
index 4df98e6..9cf9107 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
@@ -27,6 +27,7 @@ import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.history.IFileHistoryProvider;
import org.eclipse.team.core.history.IFileRevision;
@@ -52,7 +53,7 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
private IFileRevision[] revisions;
- public GitFileHistory(IResource resource, int flags) {
+ public GitFileHistory(IResource resource, int flags, IProgressMonitor monitor) {
this.resource = resource;
this.flags = flags;
String prefix = getRepositoryMapping().getSubset();
@@ -61,6 +62,15 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
relativeResourceName = new String[prefixSegments.length + resourceSegments.length];
System.arraycopy(prefixSegments, 0, relativeResourceName, 0, prefixSegments.length);
System.arraycopy(resourceSegments, 0, relativeResourceName, prefixSegments.length, resourceSegments.length);
+ if ((flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0) {
+ findSingleRevision(monitor);
+ } else {
+ try {
+ findRevisions(monitor);
+ } catch (IOException e) {
+ throw new Error(e);
+ }
+ }
}
public IFileRevision[] getContributors(IFileRevision revision) {
@@ -111,28 +121,24 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
static class EclipseWalker extends Walker {
IResource resource;
-
- EclipseWalker(Repository repository, Commit start, String[] relativeResourceName,boolean leafIsBlob,IResource resource,boolean followMainOnly, ObjectId lastActiveDiffId) {
+ private final IProgressMonitor monitor;
+
+ EclipseWalker(Repository repository, Commit start, String[] relativeResourceName,boolean leafIsBlob,IResource resource,boolean followMainOnly, ObjectId lastActiveDiffId, IProgressMonitor monitor) {
super(repository, start, relativeResourceName, leafIsBlob, followMainOnly, lastActiveDiffId);
this.resource = resource;
+ this.monitor = monitor;
}
protected void collect(Collection ret,Commit commit, int count) {
ret.add(new GitFileRevision(commit, resource, count));
}
-
+
+ public boolean isCancelled() {
+ return monitor.isCanceled();
+ }
};
public IFileRevision[] getFileRevisions() {
- if (revisions == null)
- if ((flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0)
- findSingleRevision();
- else
- try {
- findRevisions();
- } catch (IOException e) {
- throw new Error(e);
- }
return revisions;
}
@@ -143,8 +149,9 @@ static class EclipseWalker extends Walker {
* return the revision prior to the topmost patch, be it another patch or a
* normal Git Commit. This is the revision in HEAD^. Otherwise we return the
* revision in HEAD.
+ * @param monitor
*/
- private void findSingleRevision() {
+ private void findSingleRevision(IProgressMonitor monitor) {
try {
Repository repository = getRepository();
ObjectId id = repository.resolve("HEAD");
@@ -177,7 +184,7 @@ static class EclipseWalker extends Walker {
}
}
- private void findRevisions() throws IOException {
+ private void findRevisions(IProgressMonitor monitor) throws IOException {
RepositoryProvider provider = RepositoryProvider.getProvider(resource
.getProject());
if (provider instanceof GitProvider) {
@@ -203,7 +210,8 @@ static class EclipseWalker extends Walker {
resource.getType() == IResource.FILE,
resource,
(flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0,
- activeDiffLeafId);
+ activeDiffLeafId,
+ monitor);
Collection githistory = walker.collectHistory();
if (githistory.size() >0) {
if (resource.getType()==IResource.FILE) {
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistoryProvider.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistoryProvider.java
index 2d1050f..7ff1ef5 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistoryProvider.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistoryProvider.java
@@ -31,7 +31,7 @@ public class GitFileHistoryProvider extends FileHistoryProvider implements
public IFileHistory getFileHistoryFor(IResource resource, int flags,
IProgressMonitor monitor) {
// TODO: implement flags
- return new GitFileHistory(resource, flags); // TODO: implement flags
+ return new GitFileHistory(resource, flags, monitor); // TODO: implement flags
}
public IFileRevision getWorkspaceFileRevision(IResource resource) {
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
index ec200e2..57fefcc 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
@@ -29,6 +29,10 @@ import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
@@ -322,21 +326,22 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
private Map appliedPatches;
- class GitHistoryContentProvider implements ITreeContentProvider,
- ILazyTreeContentProvider {
+ class HistoryRefreshJob extends Job {
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput == null)
- return;
- System.out.println("inputChanged(" + viewer + "," + oldInput + ","
- + newInput);
+ public HistoryRefreshJob(String name) {
+ super(name);
+ }
+
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor = new NullProgressMonitor();
+ monitor.beginTask("UpdateHistory", IProgressMonitor.UNKNOWN);
IProject project = ((IResource) getInput()).getProject();
RepositoryProvider provider = RepositoryProvider
.getProvider(project);
RepositoryMapping repositoryMapping = ((GitProvider)provider).getData().getRepositoryMapping(project);
+ Map newappliedPatches = null;
try {
- appliedPatches = null;
- appliedPatches = repositoryMapping.getRepository().getAppliedPatches();
+ newappliedPatches = repositoryMapping.getRepository().getAppliedPatches();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -345,18 +350,48 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
.getFileHistoryProvider();
IFileHistory fileHistoryFor = fileHistoryProvider
.getFileHistoryFor((IResource) getInput(),
- IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, null/* monitor */);
+ IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, monitor);
fileRevisions = fileHistoryFor.getFileRevisions();
- tree.removeAll();
- tree.setItemCount(fileRevisions.length);
- tree.setData(fileRevisions);
- tree.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
- System.out.println("inputchanged, invoking refresh");
- viewer.refresh();
+
+ final Map fnewappliedPatches = newappliedPatches;
+ tree.getDisplay().asyncExec(new Runnable() {
+
+ public void run() {
+ tree.removeAll();
+ tree.setItemCount(fileRevisions.length);
+ tree.setData(fileRevisions);
+ tree.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
+ System.out.println("inputchanged, invoking refresh");
+ viewer.refresh();
+ appliedPatches = fnewappliedPatches;
+ done(Status.OK_STATUS);
+ }
+
+ });
+ return Status.OK_STATUS;
+ }
+
+ }
+
+ HistoryRefreshJob historyRefreshJob = new HistoryRefreshJob("Git history refresh");
+
+ class GitHistoryContentProvider implements ITreeContentProvider,
+ ILazyTreeContentProvider {
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (newInput == null)
+ return;
+ System.out.println(new Date()+"inputChanged(" + viewer + "," + oldInput + ","
+ + newInput);
+ if (historyRefreshJob.cancel()) {
+ System.out.println("rescheduling");
+ historyRefreshJob.schedule();
+ } else {
+ System.out.println("failed to cancel?");
+ }
}
public void dispose() {
- // TODO Auto-generated method stub
}
public Object[] getElements(Object inputElement) {
@@ -380,12 +415,12 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
}
public void updateChildCount(Object element, int currentChildCount) {
- viewer.setChildCount(element, fileRevisions.length);
+ viewer.setChildCount(element, fileRevisions!=null ? fileRevisions.length : 0);
}
public void updateElement(Object parent, int index) {
System.out.println("updateElement("+parent+","+index);
- viewer.replace(parent, index, fileRevisions[index]);
+ viewer.replace(parent, index, fileRevisions!=null ? fileRevisions[index] : null);
}
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
index 86c8a1e..3c33274 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
@@ -17,6 +17,8 @@ public abstract class Walker {
private ObjectId activeDiffLeafId;
private final Commit start;
+ protected abstract boolean isCancelled();
+
protected abstract void collect(Collection ret,Commit commit, int count);
protected Walker(Repository repostory, Commit start, String[] relativeResourceName,boolean leafIsBlob,boolean followMainOnly, ObjectId activeDiffLeafId) {
@@ -126,7 +128,7 @@ public abstract class Walker {
current = null;
if (count>=0)
count++;
- } while (current != null);
+ } while (current != null && !isCancelled());
return ret;
}
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java
index 82f0623..a41d707 100644
--- a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java
@@ -42,6 +42,10 @@ public class T0007_WalkerTest extends SpeedTestBase {
System.out.println("Got: "+count+" "+commit.getCommitId());
ret.add(commit);
}
+
+ protected boolean isCancelled() {
+ return false;
+ }
};
Commit[] history = (Commit[])walker.collectHistory().toArray(new Commit[0]);
^ permalink raw reply related
* [EGIT PATCH 08/10] Use ObjectId[] instead of List for parents
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
To: spearce; +Cc: git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
This is more convenient to work with and slightly
faster and memory conserving, although the first
aspect is the most important thing.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../egit/core/internal/mapping/GitFileHistory.java | 23 ++++++++------
.../src/org/spearce/egit/ui/GitHistoryPage.java | 7 ++--
.../internal/actions/GitCompareRevisionAction.java | 2 +
.../src/org/spearce/jgit/lib/Commit.java | 38 ++++++++++++++++++-----
.../src/org/spearce/jgit/lib/ObjectWriter.java | 7 ++--
.../src/org/spearce/jgit/lib/Walker.java | 11 +++----
org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java | 8 ++--
.../spearce/jgit/lib/T0005_ShallowSpeedTest.java | 15 ++++-----
.../org/spearce/jgit/lib/T0006_DeepSpeedTest.java | 7 ++--
9 files changed, 68 insertions(+), 50 deletions(-)
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
index 71b29ce..4df98e6 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
@@ -65,13 +65,13 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
public IFileRevision[] getContributors(IFileRevision revision) {
GitFileRevision grevision = (GitFileRevision) revision;
- List parents = grevision.getCommit().getParentIds();
- IFileRevision[] ret = new IFileRevision[parents.size()];
+ ObjectId[] parents = grevision.getCommit().getParentIds();
+ IFileRevision[] ret = new IFileRevision[parents.length];
Repository repository = getRepository();
- for (int i = 0; i < parents.size(); ++i) {
+ for (int i = 0; i < parents.length; ++i) {
try {
ret[i] = new GitFileRevision(repository
- .mapCommit((ObjectId) parents.get(i)), grevision
+ .mapCommit(parents[i]), grevision
.getResource(), -1);
} catch (IOException e) {
e.printStackTrace();
@@ -150,9 +150,9 @@ static class EclipseWalker extends Walker {
ObjectId id = repository.resolve("HEAD");
Commit current = repository.mapCommit(id);
if (repository.isStGitMode()) {
- List parentIds = current.getParentIds();
- if (parentIds != null && parentIds.size() > 0)
- current = repository.mapCommit((ObjectId) parentIds.get(0));
+ ObjectId[] parentIds = current.getParentIds();
+ if (parentIds != null && parentIds.length > 0)
+ current = repository.mapCommit(parentIds[0]);
else {
revisions = new IFileRevision[0];
return;
@@ -264,9 +264,12 @@ static class EclipseWalker extends Walker {
List ret = new ArrayList(4);
for (int i = 0; i < revisions.length; ++i) {
Commit ref = ((GitFileRevision) revisions[i]).getCommit();
- List parentIds = ref.getParentIds();
- if (parentIds.contains(targetCommitId)) {
- ret.add(revisions[i]);
+ ObjectId[] parentIds = ref.getParentIds();
+ for (int j = 0; j < parentIds.length; ++j) {
+ if (parentIds[j].equals(targetCommitId)) {
+ ret.add(revisions[i]);
+ break;
+ }
}
}
return (IFileRevision[]) ret.toArray(new IFileRevision[ret.size()]);
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
index 4b437a6..ec200e2 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
@@ -18,7 +18,6 @@ package org.spearce.egit.ui;
import java.io.IOException;
import java.util.Date;
-import java.util.List;
import java.util.Map;
import org.eclipse.compare.CompareConfiguration;
@@ -151,9 +150,9 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
RepositoryMapping repositoryMapping = provider.getData().getRepositoryMapping(project);
try {
if (selection2.length == 1 && hintShowDiffNow) {
- List parentIds = ((GitFileRevision)selection2[0]).getCommit().getParentIds();
- if (parentIds.size() > 0) {
- ObjectId parentId = (ObjectId)parentIds.get(0);
+ ObjectId[] parentIds = ((GitFileRevision)selection2[0]).getCommit().getParentIds();
+ if (parentIds.length > 0) {
+ ObjectId parentId = parentIds[0];
Commit parent = repositoryMapping.getRepository().mapCommit(parentId);
IFileRevision previous = new GitFileRevision(parent,
((GitFileRevision)selection2[0]).getResource(),
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/GitCompareRevisionAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/GitCompareRevisionAction.java
index d5780a5..6177e01 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/GitCompareRevisionAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/GitCompareRevisionAction.java
@@ -194,7 +194,7 @@ public class GitCompareRevisionAction extends BaseSelectionListenerAction {
IFileRevision rev2=(IFileRevision)selection.toArray()[1];
System.out.println("Compare "+rev1.getContentIdentifier()+" with "+rev2.getContentIdentifier());
if (rev1 instanceof GitFileRevision && rev2 instanceof GitFileRevision) {
- ObjectId pid = (ObjectId) ((GitFileRevision)rev1).getCommit().getParentIds().get(0);
+ ObjectId pid = ((GitFileRevision)rev1).getCommit().getParentIds()[0];
if (pid.equals(((GitFileRevision)rev2).getCommit().getCommitId())) {
this.setText("Show commit diff");
} else {
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
index f5cc6ec..d2cf3af 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Commit.java
@@ -20,21 +20,21 @@ import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
import org.spearce.jgit.errors.CorruptObjectException;
import org.spearce.jgit.errors.MissingObjectException;
public class Commit implements Treeish {
+ private static final ObjectId[] EMPTY_OBJECTID_LIST = new ObjectId[0];
+
private final Repository objdb;
private ObjectId commitId;
private ObjectId treeId;
- private List parentIds;
-
+ private ObjectId[] parentIds;
+
private PersonIdent author;
private PersonIdent committer;
@@ -49,22 +49,42 @@ public class Commit implements Treeish {
public Commit(final Repository db) {
objdb = db;
- parentIds = new ArrayList(2);
+ parentIds = EMPTY_OBJECTID_LIST;
}
public Commit(final Repository db, final ObjectId id, final byte[] raw) {
objdb = db;
commitId = id;
treeId = ObjectId.fromString(raw, 5);
- parentIds = new ArrayList(2);
+ parentIds = new ObjectId[1];
+ int np=0;
int rawPtr = 46;
for (;;) {
if (raw[rawPtr] != 'p')
break;
- parentIds.add(ObjectId.fromString(raw, rawPtr + 7));
+ if (np == 0) {
+ parentIds[np++] = ObjectId.fromString(raw, rawPtr + 7);
+ } else if (np == 1) {
+ parentIds = new ObjectId[] { parentIds[0], ObjectId.fromString(raw, rawPtr + 7) };
+ } else {
+ if (parentIds.length < np) {
+ ObjectId[] old = parentIds;
+ parentIds = new ObjectId[parentIds.length+32];
+ for (int i=0; i<np; ++i)
+ parentIds[i] = old[i];
+ }
+ parentIds[np++] = ObjectId.fromString(raw, rawPtr + 7);
+ }
rawPtr += 48;
}
-
+ if (np != parentIds.length) {
+ ObjectId[] old = parentIds;
+ parentIds = new ObjectId[np];
+ for (int i=0; i<np; ++i)
+ parentIds[i] = old[i];
+ } else
+ if (np == 0)
+ parentIds = EMPTY_OBJECTID_LIST;
this.raw = raw;
}
@@ -121,7 +141,7 @@ public class Commit implements Treeish {
committer = c;
}
- public List getParentIds() {
+ public ObjectId[] getParentIds() {
return parentIds;
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
index f9f2bde..b947a80 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectWriter.java
@@ -25,7 +25,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.security.MessageDigest;
-import java.util.Iterator;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;
@@ -121,11 +120,11 @@ public class ObjectWriter {
c.getTreeId().copyTo(os);
os.write('\n');
- final Iterator i = c.getParentIds().iterator();
- while (i.hasNext()) {
+ ObjectId[] ps = c.getParentIds();
+ for (int i=0; i<ps.length; ++i) {
os.write(hparent);
os.write(' ');
- ((ObjectId) i.next()).copyTo(os);
+ ps[i].copyTo(os);
os.write('\n');
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
index 2928e1d..86c8a1e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
@@ -8,7 +8,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
public abstract class Walker {
private String[] relativeResourceName;
@@ -98,10 +97,10 @@ public abstract class Walker {
// TODO: we may need to list more revisions when traversing
// branches
- List parents = current.getParentIds();
+ ObjectId[] parents = current.getParentIds();
if (!followMainOnly) {
- for (int i = 1; i < parents.size(); ++i) {
- ObjectId mergeParentId = (ObjectId) parents.get(i);
+ for (int i = 1; i < parents.length; ++i) {
+ ObjectId mergeParentId = parents[i];
Commit mergeParent;
try {
mergeParent = repository.mapCommit(mergeParentId);
@@ -115,8 +114,8 @@ public abstract class Walker {
}
}
}
- if (parents.size() > 0) {
- ObjectId parentId = (ObjectId) parents.get(0);
+ if (parents.length > 0) {
+ ObjectId parentId = parents[0];
try {
current = repository.mapCommit(parentId);
} catch (IOException e) {
diff --git a/org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java b/org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java
index 8ba9182..73bf556 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/pgm/Log.java
@@ -2,9 +2,8 @@ package org.spearce.jgit.pgm;
import java.io.File;
import java.io.IOException;
-import java.util.Iterator;
-
import org.spearce.jgit.lib.Commit;
+import org.spearce.jgit.lib.ObjectId;
import org.spearce.jgit.lib.Repository;
public class Log {
@@ -13,8 +12,9 @@ public class Log {
Commit commit = db.mapCommit(args[0]);
System.out.println("commit " + commit.getCommitId());
System.out.println("tree " + commit.getTreeId());
- for (Iterator ci = commit.getParentIds().iterator(); ci.hasNext();) {
- System.out.println("parent " + ci.next());
+ ObjectId[] ps=commit.getParentIds();
+ for (int ci=0; ci<ps.length; ++ci) {
+ System.out.println("parent " + ps[ci]);
}
System.out.println("author " + commit.getAuthor());
System.out.println();
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0005_ShallowSpeedTest.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0005_ShallowSpeedTest.java
index 36e74ae..b598a13 100644
--- a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0005_ShallowSpeedTest.java
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0005_ShallowSpeedTest.java
@@ -18,7 +18,6 @@ package org.spearce.jgit.lib;
import java.io.File;
import java.io.IOException;
-import java.util.List;
import junit.textui.TestRunner;
@@ -35,9 +34,9 @@ public class T0005_ShallowSpeedTest extends SpeedTestBase {
int n = 1;
do {
// System.out.println("commit="+commit.getCommitId());
- List parent = commit.getParentIds();
- if (parent.size() > 0) {
- ObjectId parentId = (ObjectId) parent.get(0);
+ ObjectId[] parents = commit.getParentIds();
+ if (parents.length > 0) {
+ ObjectId parentId = parents[0];
commit = db.mapCommit(parentId);
commit.getCommitId().toString();
++n;
@@ -52,13 +51,13 @@ public class T0005_ShallowSpeedTest extends SpeedTestBase {
System.out.println("jgit="+time);
// ~0.750s (hot cache), ok
/*
-native=1748
-jgit=774
+native=1795
+jgit=722
*/
// native git seems to run SLOWER than jgit here, at roughly half the speed
// creating the git process is not the issue here, btw.
- long factor10 = (nativeTime*110/time+50)/100;
- assertEquals(2, factor10);
+ long factor10 = (nativeTime*150/time+50)/100;
+ assertEquals(3, factor10);
}
public static void main(String[] args) {
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0006_DeepSpeedTest.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0006_DeepSpeedTest.java
index b4ae4b8..244792c 100644
--- a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0006_DeepSpeedTest.java
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0006_DeepSpeedTest.java
@@ -18,7 +18,6 @@ package org.spearce.jgit.lib;
import java.io.File;
import java.io.IOException;
-import java.util.List;
import junit.textui.TestRunner;
@@ -35,9 +34,9 @@ public class T0006_DeepSpeedTest extends SpeedTestBase {
int n = 1;
do {
// System.out.println("commit="+commit.getCommitId());
- List parent = commit.getParentIds();
- if (parent.size() > 0) {
- ObjectId parentId = (ObjectId) parent.get(0);
+ ObjectId[] parents = commit.getParentIds();
+ if (parents.length > 0) {
+ ObjectId parentId = parents[0];
commit = db.mapCommit(parentId);
TreeEntry m = commit.getTree().findBlobMember("net/netfilter/nf_queue.c");
if (m != null)
^ permalink raw reply related
* [EGIT PATCH 07/10] Cache pack index fully
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
To: spearce; +Cc: git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
Navigating the pack index for every lookup takes time, mostly
because it takes resources from the memory mapping for getting
the actual objects.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../jgit/lib/DeltaRefPackedObjectLoader.java | 3
.../src/org/spearce/jgit/lib/ObjectId.java | 17 ++
.../src/org/spearce/jgit/lib/ObjectIdMap.java | 145 ++++++++++++++++++++
.../src/org/spearce/jgit/lib/PackFile.java | 87 ++++++------
.../src/org/spearce/jgit/lib/Repository.java | 17 +-
.../tst/org/spearce/jgit/lib/ObjectIdMapTest.java | 170 +++++++++++++++++++++++
.../tst/org/spearce/jgit/lib/T0004_PackReader.java | 2
7 files changed, 377 insertions(+), 64 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/DeltaRefPackedObjectLoader.java b/org.spearce.jgit/src/org/spearce/jgit/lib/DeltaRefPackedObjectLoader.java
index 2719738..90c01ea 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/DeltaRefPackedObjectLoader.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/DeltaRefPackedObjectLoader.java
@@ -15,8 +15,7 @@ class DeltaRefPackedObjectLoader extends DeltaPackedObjectLoader {
}
protected ObjectLoader getBaseLoader() throws IOException {
- final ObjectLoader or = pack.get(deltaBase,
- new byte[Constants.OBJECT_ID_LENGTH]);
+ final ObjectLoader or = pack.get(deltaBase);
if (or == null)
throw new MissingObjectException(deltaBase, "delta base");
return or;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
index fea0d91..f99c303 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
@@ -83,10 +83,20 @@ public class ObjectId implements Comparable {
return new ObjectId(id);
}
- private static int compare(final byte[] a, final byte[] b) {
- if (a==b)
- return 0;
+ public int compareTo(byte[] b, long pos) {
for (int k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
+ final int ak = id[k] & 0xff;
+ final int bk = b[k + (int)pos] & 0xff;
+ if (ak < bk)
+ return -1;
+ else if (ak > bk)
+ return 1;
+ }
+ return 0;
+ }
+
+ private static int compare(final byte[] a, final byte[] b) {
+ for (int k = 0 ; k < Constants.OBJECT_ID_LENGTH; k++) {
final int ak = a[k] & 0xff;
final int bk = b[k] & 0xff;
if (ak < bk)
@@ -218,4 +228,5 @@ public class ObjectId implements Comparable {
}
return new String(s,0);
}
+
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java
new file mode 100644
index 0000000..c397a0d
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectIdMap.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2006 Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ */
+package org.spearce.jgit.lib;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/** Very much like a map, but specialized
+ * to partition the data on the first byte
+ * of the key. This is MUCH faster. See test
+ * class for how these numbers were derived.
+ *
+ * TreeMap= 2968
+ * HashMap= 1689
+ * Partitioned TreeMap=1499
+ * Partitioned HashMap=1782
+ *
+ * Inspiration from Git pack file format which uses this technique.
+ *
+ */
+public class ObjectIdMap implements Map {
+
+ Map[] level0 = new Map[256];
+
+ public ObjectIdMap() {
+ this(new TreeMap());
+ }
+
+ public ObjectIdMap(Map sample) {
+ try {
+ Method m=sample.getClass().getMethod("clone", null);
+ for (int i=0; i<256; ++i) {
+ level0[i] = (Map)m.invoke(sample, null);
+ }
+ } catch (IllegalAccessException e) {
+ throw new IllegalArgumentException(e);
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException(e);
+ } catch (InvocationTargetException e) {
+ throw new IllegalArgumentException(e);
+ } catch (SecurityException e) {
+ throw new IllegalArgumentException(e);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public void clear() {
+ for (int i=0; i<256; ++i)
+ level0[i].clear();
+ }
+
+ public boolean containsKey(Object key) {
+ return submap(key).containsKey(key);
+ }
+
+ private final Map submap(Object key) {
+ return level0[((ObjectId)key).getFirstByte()];
+ }
+
+ public boolean containsValue(Object value) {
+ for (int i=0; i<256; ++i)
+ if (level0[i].containsValue(value))
+ return true;
+ return false;
+ }
+
+ public Set entrySet() {
+ Set ret = new HashSet();
+ for (int i=0; i<256; ++i)
+ ret.addAll(level0[i].entrySet());
+ return ret;
+ }
+
+ public Object get(Object key) {
+ return submap(key).get(key);
+ }
+
+ public boolean isEmpty() {
+ for (int i=0; i<256; ++i)
+ if (!level0[i].isEmpty())
+ return false;
+ return true;
+ }
+
+ public Set keySet() {
+ Set ret = new HashSet();
+ for (int i=0; i<256; ++i)
+ ret.addAll(level0[i].keySet());
+ return ret;
+ }
+
+ public Object put(Object key, Object value) {
+ return submap(key).put(key, value);
+ }
+
+ public void putAll(Map arg0) {
+ for (Iterator i=arg0.keySet().iterator(); i.hasNext(); ) {
+ Object k=i.next();
+ Object v=arg0.get(k);
+ put(k,v);
+ }
+ }
+
+ public Object remove(Object key) {
+ return submap(key).remove(key);
+ }
+
+ public int size() {
+ int ret=0;
+ for (int i=0; i<256; ++i)
+ ret += level0[i].size();
+ return ret;
+ }
+
+ public Collection values() {
+ List ret=new ArrayList(size());
+ for (int i=0; i<256; ++i)
+ ret.addAll(level0[i].values());
+ return ret;
+ }
+
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
index d33aa97..fa206fd 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
@@ -32,8 +32,7 @@ public class PackFile {
private final WindowedFile pack;
private final WindowedFile idx;
-
- private final long[] idxHeader;
+ private byte[][] idxdata;
private long objectCnt;
@@ -52,10 +51,9 @@ public class PackFile {
.substring(0, dot)
+ ".idx");
// FIXME window size and mmap type should be configurable
- idx = new WindowedFile(repo.getWindowCache(), idxFile,
- 64 * 1024 * 1024, true);
+ idx = new WindowedFile(new WindowCache(8*1024*1024,1), idxFile, 8*1024*1024, true);
try {
- idxHeader = readIndexHeader();
+ readIndexHeader();
} catch (IOException ioe) {
try {
idx.close();
@@ -75,7 +73,7 @@ public class PackFile {
}
ObjectLoader resolveBase(final long ofs) throws IOException {
- return reader(ofs, new byte[Constants.OBJECT_ID_LENGTH]);
+ return reader(ofs);
}
/**
@@ -87,19 +85,10 @@ public class PackFile {
*
* @param id
* the object to look for. Must not be null.
- * @param tmp
- * a temporary buffer loaned to this pack for use during the
- * search. This buffer must be at least
- * {@link Constants#OBJECT_ID_LENGTH} bytes in size. The buffer
- * will be overwritten during the search, but is unused upon
- * return.
* @return true if the object is in this pack; false otherwise.
- * @throws IOException
- * there was an error reading data from the pack's index file.
*/
- public boolean hasObject(final ObjectId id, final byte[] tmp)
- throws IOException {
- return findOffset(id, tmp) != -1;
+ public boolean hasObject(final ObjectId id) {
+ return findOffset(id) != -1;
}
/**
@@ -116,25 +105,17 @@ public class PackFile {
*
* @param id
* the object to obtain from the pack. Must not be null.
- * @param tmp
- * a temporary buffer loaned to this pack for use during the
- * search, and given to the returned loader if the object is
- * found. This buffer must be at least
- * {@link Constants#OBJECT_ID_LENGTH} bytes in size. The buffer
- * will be overwritten during the search. The buffer will be
- * given to the loader if a loader is returned. If null is
- * returned the caller may reuse the buffer.
* @return the object loader for the requested object if it is contained in
* this pack; null if the object was not found.
* @throws IOException
* the pack file or the index could not be read.
*/
- public PackedObjectLoader get(final ObjectId id, final byte[] tmp)
+ public PackedObjectLoader get(final ObjectId id)
throws IOException {
- final long offset = findOffset(id, tmp);
+ final long offset = findOffset(id);
if (offset == -1)
return null;
- final PackedObjectLoader objReader = reader(offset, tmp);
+ final PackedObjectLoader objReader = reader(offset);
objReader.setId(id);
return objReader;
}
@@ -173,22 +154,35 @@ public class PackFile {
objectCnt = pack.readUInt32(position, intbuf);
}
- private long[] readIndexHeader() throws CorruptObjectException, IOException {
+ private void readIndexHeader() throws CorruptObjectException, IOException {
if (idx.length() != (IDX_HDR_LEN + (24 * objectCnt) + (2 * Constants.OBJECT_ID_LENGTH)))
throw new CorruptObjectException("Invalid pack index");
- final long[] idxHeader = new long[256];
+ final long[] idxHeader = new long[256]; // really unsigned 32-bit...
final byte[] intbuf = new byte[4];
for (int k = 0; k < idxHeader.length; k++)
idxHeader[k] = idx.readUInt32(k * 4, intbuf);
- return idxHeader;
+ idxdata = new byte[idxHeader.length][];
+ for (int k = 0; k < idxHeader.length; k++) {
+ int n;
+ if (k == 0) {
+ n = (int)(idxHeader[k]);
+ } else {
+ n = (int)(idxHeader[k]-idxHeader[k-1]);
+ }
+ if (n > 0) {
+ idxdata[k] = new byte[n * (Constants.OBJECT_ID_LENGTH + 4)];
+ int off = (int) ((k == 0) ? 0 : idxHeader[k-1] * (Constants.OBJECT_ID_LENGTH + 4));
+ idx.read(off + IDX_HDR_LEN, idxdata[k]);
+ }
+ }
}
- private PackedObjectLoader reader(final long objOffset, final byte[] ib)
+ private PackedObjectLoader reader(final long objOffset)
throws IOException {
long pos = objOffset;
int p = 0;
-
+ final byte[] ib = new byte[Constants.OBJECT_ID_LENGTH];
pack.readFully(pos, ib);
int c = ib[p++] & 0xff;
final int typeCode = (c >> 4) & 7;
@@ -239,23 +233,26 @@ public class PackFile {
return new WholePackedObjectLoader(this, pos, type, (int) size);
}
- private long findOffset(final ObjectId objId, final byte[] tmpid)
- throws IOException {
+ private long findOffset(final ObjectId objId) {
final int levelOne = objId.getFirstByte();
- long high = idxHeader[levelOne];
- long low = levelOne == 0 ? 0 : idxHeader[levelOne - 1];
-
+ byte[] data = idxdata[levelOne];
+ if (data == null)
+ return -1;
+ long high = data.length / (4 + Constants.OBJECT_ID_LENGTH);
+ long low = 0;
do {
final long mid = (low + high) / 2;
- final long pos = IDX_HDR_LEN
- + ((4 + Constants.OBJECT_ID_LENGTH) * mid) + 4;
- idx.readFully(pos, tmpid);
- final int cmp = objId.compareTo(tmpid);
+ final long pos = ((4 + Constants.OBJECT_ID_LENGTH) * mid) + 4;
+ final int cmp = objId.compareTo(data, pos);
if (cmp < 0)
high = mid;
- else if (cmp == 0)
- return idx.readUInt32(pos - 4, tmpid);
- else
+ else if (cmp == 0) {
+ int b0 = data[(int)pos-4] & 0xff;
+ int b1 = data[(int)pos-3] & 0xff;
+ int b2 = data[(int)pos-2] & 0xff;
+ int b3 = data[(int)pos-1] & 0xff;
+ return (((long)b0) << 24) | ( b1 << 16 ) | ( b2 << 8 ) | (b3);
+ } else
low = mid + 1;
} while (low < high);
return -1;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index 0f2a900..482f41d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -152,17 +152,9 @@ public class Repository {
public boolean hasObject(final ObjectId objectId) {
int k = packs.length;
if (k > 0) {
- final byte[] tmp = new byte[Constants.OBJECT_ID_LENGTH];
do {
- try {
- if (packs[--k].hasObject(objectId, tmp))
- return true;
- } catch (IOException ioe) {
- // This shouldn't happen unless the pack was corrupted
- // after we opened it. We'll ignore the error as though
- // the object does not exist in this pack.
- //
- }
+ if (packs[--k].hasObject(objectId))
+ return true;
} while (k > 0);
}
return toFile(objectId).isFile();
@@ -171,10 +163,9 @@ public class Repository {
public ObjectLoader openObject(final ObjectId id) throws IOException {
int k = packs.length;
if (k > 0) {
- final byte[] tmp = new byte[Constants.OBJECT_ID_LENGTH];
do {
try {
- final ObjectLoader ol = packs[--k].get(id, tmp);
+ final ObjectLoader ol = packs[--k].get(id);
if (ol != null)
return ol;
} catch (IOException ioe) {
@@ -185,7 +176,7 @@ public class Repository {
// time to collect and try once more.
try {
System.gc();
- final ObjectLoader ol = packs[k].get(id, tmp);
+ final ObjectLoader ol = packs[k].get(id);
if (ol != null)
return ol;
} catch (IOException ioe2) {
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/ObjectIdMapTest.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/ObjectIdMapTest.java
new file mode 100644
index 0000000..f98c6f7
--- /dev/null
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/ObjectIdMapTest.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2006 Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ */
+package org.spearce.jgit.lib;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+import junit.textui.TestRunner;
+
+public class ObjectIdMapTest extends TestCase {
+
+ ObjectId[] ids = new ObjectId[1000000];
+
+ protected void setUp() throws Exception {
+ int b=0;
+ for (int i=0; i<ids.length; ++i) {
+ byte[] data = new byte[Constants.OBJECT_ID_LENGTH];
+ for (int j=0; j<Constants.OBJECT_ID_LENGTH; ++j)
+ data[j] = (byte) (b++^0xEE);
+ ids[i] = new ObjectId(data);
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ ids = null; // avoid out of memory
+ }
+
+ public void testBoth() {
+ long d1=0;
+ long d2=0;
+ long d3=0;
+ long d4=0;
+ long d5=0;
+ long d6=0;
+
+ for (int j=0; j<64; ++j) {
+ int x =
+ ((j & 1)!=0 ? 1 : 0) |
+ ((j & 2)!=0 ? 2 : 0) |
+ ((j & 4)!=0 ? 16 : 0) |
+ ((j & 8)!=0 ? 32 : 0) |
+ ((j & 16)!=0 ? 4 : 0) |
+ ((j & 32)!=0 ? 8 : 0);
+
+ if ((x&1) == 0) {
+ long t0 = System.currentTimeMillis();
+
+ Map treeMap = new TreeMap();
+ for (int i=0; i<ids.length; ++i)
+ treeMap.put(ids[i],ids[i]);
+
+ long t1 = System.currentTimeMillis();
+ d1 += t1-t0;
+ }
+ if ((x&2) == 0) {
+ long t0 = System.currentTimeMillis();
+ Map hashMap = new HashMap();
+ for (int i=0; i<ids.length; ++i)
+ hashMap.put(ids[i],ids[i]);
+ long t1 = System.currentTimeMillis();
+ d2 += t1-t0;
+ }
+
+ if ((x&4) == 0) {
+ long t0= System.currentTimeMillis();
+
+ Map levelMapWithTree = new ObjectIdMap(new TreeMap());
+ for (int i=0; i<ids.length; ++i)
+ levelMapWithTree.put(ids[i],ids[i]);
+
+ long t1 = System.currentTimeMillis();
+ d3 += t1-t0;
+ }
+
+ if ((x&8) == 0) {
+ long t0 = System.currentTimeMillis();
+ Map levelMapWithHash = new ObjectIdMap(new HashMap());
+ for (int i=0; i<ids.length; ++i)
+ levelMapWithHash.put(ids[i],ids[i]);
+
+ long t1 = System.currentTimeMillis();
+
+ d4 += t1-t0;
+ }
+
+ if ((x&16) == 0) {
+ long t0= System.currentTimeMillis();
+
+ Map levelMapWithTreeAndSpecialCompare = new ObjectIdMap(new TreeMap(new Comparator() {
+
+ public int compare(Object arg0, Object arg1) {
+ byte[] b0=((ObjectId)arg0).getBytes();
+ byte[] b1=((ObjectId)arg1).getBytes();
+ for (int i=1; i<Constants.OBJECT_ID_LENGTH; ++i) {
+ int a=b0[i]&0xff;
+ int b=b1[i]&0xff;
+ int c=a-b;
+ if (c!=0)
+ return c;
+ }
+ return 0;
+ }
+
+ }));
+ for (int i=0; i<ids.length; ++i)
+ levelMapWithTreeAndSpecialCompare.put(ids[i],ids[i]);
+
+ long t1 = System.currentTimeMillis();
+ d5 += t1-t0;
+ }
+
+ if ((j&32) == 0) {
+ long t0= System.currentTimeMillis();
+
+ Map levelMapWithTreeAndSpecialCompare = new ObjectIdMap(new TreeMap(new Comparator() {
+
+ public int compare(Object arg0, Object arg1) {
+ return ((Comparable)arg0).compareTo(arg1);
+ }
+
+ }));
+ for (int i=0; i<ids.length; ++i)
+ levelMapWithTreeAndSpecialCompare.put(ids[i],ids[i]);
+
+ long t1 = System.currentTimeMillis();
+ d6 += t1-t0;
+ }
+ }
+
+ System.out.println("TreeMap ="+d1);
+ System.out.println("HashMap ="+d2);
+ System.out.println("Partitioned TreeMap ObjectId.compare ="+d3);
+ System.out.println("Partitioned HashMap ="+d4);
+ System.out.println("Partitioned TreeMap enhanced compare ="+d5);
+ System.out.println("Partitioned TreeMap dummy compare ="+d6);
+ assertEquals(d5*10/10000, d2*8/10000); // d5 is ~20% better
+ }
+
+ public void testFunc() {
+ Map treeMap = new TreeMap();
+ for (int i=0; i<ids.length/100; ++i)
+ treeMap.put(ids[i],ids[i]);
+ Map levelMapWithTree = new ObjectIdMap(new TreeMap());
+ for (int i=0; i<ids.length/100; ++i)
+ levelMapWithTree.put(ids[i],ids[i]);
+
+ assertEquals(treeMap, levelMapWithTree);
+ }
+
+ public static void main(String[] args) {
+ TestRunner.run(ObjectIdMapTest.class);
+ }
+}
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0004_PackReader.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0004_PackReader.java
index 24f6b03..118415d 100644
--- a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0004_PackReader.java
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0004_PackReader.java
@@ -30,7 +30,7 @@ public class T0004_PackReader extends RepositoryTestCase {
id = new ObjectId("902d5476fa249b7abc9d84c611577a81381f0327");
pr = new PackFile(db, TEST_PACK);
- or = pr.get(id, new byte[Constants.OBJECT_ID_LENGTH]);
+ or = pr.get(id);
assertNotNull(or);
assertEquals(id, or.getId());
assertEquals(Constants.TYPE_TREE, or.getType());
^ permalink raw reply related
* [EGIT PATCH 06/10] Create a generic history walker
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
To: spearce; +Cc: git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
This was needed to created a performance test program. This
is a very stupid walker so far since it only follows the
first parent. The main reason is that the viewer is not
capable of more. The only reason it is usable to me is that
most projects I work on have few branches and even fewer
merges (that can be detected by CVS converters).
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../egit/core/internal/mapping/GitFileHistory.java | 149 ++++++-----------------
.../src/org/spearce/jgit/lib/Walker.java | 134 +++++++++++++++++++++
.../tst/org/spearce/jgit/lib/T0007_WalkerTest.java | 63 ++++++++++
3 files changed, 233 insertions(+), 113 deletions(-)
diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
index 0569862..71b29ce 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/internal/mapping/GitFileHistory.java
@@ -20,9 +20,7 @@ import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -42,6 +40,7 @@ import org.spearce.jgit.lib.ObjectId;
import org.spearce.jgit.lib.Repository;
import org.spearce.jgit.lib.Tree;
import org.spearce.jgit.lib.TreeEntry;
+import org.spearce.jgit.lib.Walker;
public class GitFileHistory extends FileHistory implements IAdaptable {
@@ -110,124 +109,30 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
return getData().getRepositoryMapping(resource.getProject());
}
- private Collection collectHistory() {
- Repository repository = getRepository();
- try {
- ObjectId id = repository.resolve("HEAD");
- Commit commit = repository.mapCommit(id);
- ObjectId[] initialResourceHash = new ObjectId[relativeResourceName.length];
- Arrays.fill(initialResourceHash, ObjectId.zeroId());
- TreeEntry[] activeDiffTreeEntries = null;
- try {
- activeDiffTreeEntries = getData().getActiveDiffTreeEntries(resource);
- } catch (CoreException e1) {
- // TODO: eclipse excetion logging
- e1.printStackTrace();
- }
- if (activeDiffTreeEntries!=null)
- initialResourceHash[initialResourceHash.length-1] = activeDiffTreeEntries[0].getId();
- return collectHistory(0, initialResourceHash, null,
- repository, commit);
- } catch (IOException e) {
- e.printStackTrace();
- return Collections.EMPTY_LIST;
- }
+static class EclipseWalker extends Walker {
+ IResource resource;
+
+ EclipseWalker(Repository repository, Commit start, String[] relativeResourceName,boolean leafIsBlob,IResource resource,boolean followMainOnly, ObjectId lastActiveDiffId) {
+ super(repository, start, relativeResourceName, leafIsBlob, followMainOnly, lastActiveDiffId);
+ this.resource = resource;
}
- private Collection collectHistory(int count, ObjectId[] lastResourceHash, TreeEntry lastEntry,
- Repository repository, Commit top) throws IOException {
- if (top == null)
- return Collections.EMPTY_LIST;
- Collection ret = new ArrayList(10000);
- Commit current = top;
- Commit previous = top;
-
- do {
- TreeEntry currentEntry = lastEntry;
- ObjectId[] currentResourceHash = new ObjectId[lastResourceHash.length];
- Tree t = current.getTree();
- for (int i = 0; i < currentResourceHash.length; ++i) {
- TreeEntry m;
- if (i == relativeResourceName.length-1 && resource.getType() == IResource.FILE)
- m = t.findBlobMember(relativeResourceName[i]);
- else
- m = t.findTreeMember(relativeResourceName[i]);
- if (m != null) {
- ObjectId id = m.getId();
- currentResourceHash[i] = id;
- if (id.equals(lastResourceHash[i])) {
- while (++i < currentResourceHash.length) {
- currentResourceHash[i] = lastResourceHash[i];
- }
- } else {
- if (m instanceof Tree) {
- t = (Tree)m;
- } else {
- if (i == currentResourceHash.length - 1) {
- currentEntry = m;
- } else {
- currentEntry = null;
- while (++i < currentResourceHash.length) {
- currentResourceHash[i] = ObjectId.zeroId();
- }
- }
- }
- }
- } else {
- for (; i < currentResourceHash.length; ++i) {
- currentResourceHash[i] = ObjectId.zeroId();
- }
- }
- }
-
- if (currentResourceHash.length == 0 || !currentResourceHash[currentResourceHash.length-1].equals(lastResourceHash[currentResourceHash.length-1]))
- ret.add(new GitFileRevision(previous, resource, count));
-
- lastResourceHash = currentResourceHash;
- previous = current;
-
- // TODO: we may need to list more revisions when traversing
- // branches
- List parents = current.getParentIds();
- if ((flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0) {
- for (int i = 1; i < parents.size(); ++i) {
- ObjectId mergeParentId = (ObjectId) parents.get(i);
- Commit mergeParent;
- try {
- mergeParent = repository.mapCommit(mergeParentId);
- ret.addAll(collectHistory(0, lastResourceHash, currentEntry, repository,
- mergeParent));
- // TODO: this gets us a lot of duplicates that we need
- // to filter out
- // Leave that til we get a GUI.
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- if (parents.size() > 0) {
- ObjectId parentId = (ObjectId) parents.get(0);
- try {
- current = repository.mapCommit(parentId);
- } catch (IOException e) {
- e.printStackTrace();
- current = null;
- }
- } else
- current = null;
- if (count>=0)
- count++;
- } while (current != null);
-
- return ret;
+ protected void collect(Collection ret,Commit commit, int count) {
+ ret.add(new GitFileRevision(commit, resource, count));
}
+
+};
public IFileRevision[] getFileRevisions() {
if (revisions == null)
if ((flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0)
findSingleRevision();
else
- findRevisions();
+ try {
+ findRevisions();
+ } catch (IOException e) {
+ throw new Error(e);
+ }
return revisions;
}
@@ -272,7 +177,7 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
}
}
- private void findRevisions() {
+ private void findRevisions() throws IOException {
RepositoryProvider provider = RepositoryProvider.getProvider(resource
.getProject());
if (provider instanceof GitProvider) {
@@ -281,7 +186,25 @@ public class GitFileHistory extends FileHistory implements IAdaptable {
long time0 = new Date().getTime();
System.out.println("getting file history");
List ret = new ArrayList();
- Collection githistory = collectHistory();
+ TreeEntry[] activeDiffTreeEntries = null;
+ try {
+ activeDiffTreeEntries = getData().getActiveDiffTreeEntries(resource);
+ } catch (CoreException e1) {
+ // TODO: eclipse excetion logging
+ e1.printStackTrace();
+ }
+ ObjectId activeDiffLeafId = null;
+ if (activeDiffTreeEntries!=null)
+ activeDiffLeafId = activeDiffTreeEntries[0].getId();
+
+ ObjectId head = getRepository().resolve("HEAD");
+ Commit start = getRepository().mapCommit(head);
+ EclipseWalker walker = new EclipseWalker(getRepository(), start, relativeResourceName,
+ resource.getType() == IResource.FILE,
+ resource,
+ (flags & IFileHistoryProvider.SINGLE_LINE_OF_DESCENT) == 0,
+ activeDiffLeafId);
+ Collection githistory = walker.collectHistory();
if (githistory.size() >0) {
if (resource.getType()==IResource.FILE) {
// TODO: consider index in future versions
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
new file mode 100644
index 0000000..2928e1d
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Walker.java
@@ -0,0 +1,134 @@
+/**
+ *
+ */
+package org.spearce.jgit.lib;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+public abstract class Walker {
+ private String[] relativeResourceName;
+ private boolean leafIsBlob;
+ private boolean followMainOnly;
+ private Repository repository;
+ private ObjectId activeDiffLeafId;
+ private final Commit start;
+
+ protected abstract void collect(Collection ret,Commit commit, int count);
+
+ protected Walker(Repository repostory, Commit start, String[] relativeResourceName,boolean leafIsBlob,boolean followMainOnly, ObjectId activeDiffLeafId) {
+ this.repository = repostory;
+ this.start = start;
+ this.relativeResourceName = relativeResourceName;
+ this.leafIsBlob = leafIsBlob;
+ this.followMainOnly = followMainOnly;
+ this.activeDiffLeafId = activeDiffLeafId;
+ }
+
+ public Collection collectHistory() {
+ try {
+ Commit commit = start;
+ ObjectId[] initialResourceHash = new ObjectId[relativeResourceName.length];
+ Arrays.fill(initialResourceHash, ObjectId.zeroId());
+ if (activeDiffLeafId != null)
+ initialResourceHash[initialResourceHash.length-1] = activeDiffLeafId;
+ return collectHistory(0, initialResourceHash, null,
+ repository, commit);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return Collections.EMPTY_LIST;
+ }
+ }
+
+ Collection collectHistory(int count, ObjectId[] lastResourceHash, TreeEntry lastEntry,
+ Repository repository, Commit top) throws IOException {
+ if (top == null)
+ return Collections.EMPTY_LIST;
+ Collection ret = new ArrayList(10000);
+ Commit current = top;
+ Commit previous = top;
+
+ do {
+ TreeEntry currentEntry = lastEntry;
+ ObjectId[] currentResourceHash = new ObjectId[lastResourceHash.length];
+ Tree t = current.getTree();
+ for (int i = 0; i < currentResourceHash.length; ++i) {
+ TreeEntry m;
+ if (i == relativeResourceName.length-1 && leafIsBlob)
+ m = t.findBlobMember(relativeResourceName[i]);
+ else
+ m = t.findTreeMember(relativeResourceName[i]);
+ if (m != null) {
+ ObjectId id = m.getId();
+ currentResourceHash[i] = id;
+ if (id.equals(lastResourceHash[i])) {
+ while (++i < currentResourceHash.length) {
+ currentResourceHash[i] = lastResourceHash[i];
+ }
+ } else {
+ if (m instanceof Tree) {
+ t = (Tree)m;
+ } else {
+ if (i == currentResourceHash.length - 1) {
+ currentEntry = m;
+ } else {
+ currentEntry = null;
+ while (++i < currentResourceHash.length) {
+ currentResourceHash[i] = ObjectId.zeroId();
+ }
+ }
+ }
+ }
+ } else {
+ for (; i < currentResourceHash.length; ++i) {
+ currentResourceHash[i] = ObjectId.zeroId();
+ }
+ }
+ }
+
+ if (currentResourceHash.length == 0 || !currentResourceHash[currentResourceHash.length-1].equals(lastResourceHash[currentResourceHash.length-1])) {
+ collect(ret, previous, count);
+ }
+ lastResourceHash = currentResourceHash;
+ previous = current;
+
+ // TODO: we may need to list more revisions when traversing
+ // branches
+ List parents = current.getParentIds();
+ if (!followMainOnly) {
+ for (int i = 1; i < parents.size(); ++i) {
+ ObjectId mergeParentId = (ObjectId) parents.get(i);
+ Commit mergeParent;
+ try {
+ mergeParent = repository.mapCommit(mergeParentId);
+ ret.addAll(collectHistory(0, lastResourceHash, currentEntry, repository,
+ mergeParent));
+ // TODO: this gets us a lot of duplicates that we need
+ // to filter out
+ // Leave that til we get a GUI.
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ if (parents.size() > 0) {
+ ObjectId parentId = (ObjectId) parents.get(0);
+ try {
+ current = repository.mapCommit(parentId);
+ } catch (IOException e) {
+ e.printStackTrace();
+ current = null;
+ }
+ } else
+ current = null;
+ if (count>=0)
+ count++;
+ } while (current != null);
+
+ return ret;
+ }
+}
\ No newline at end of file
diff --git a/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java
new file mode 100644
index 0000000..82f0623
--- /dev/null
+++ b/org.spearce.jgit/tst/org/spearce/jgit/lib/T0007_WalkerTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2006 Robin Rosenberg <robin.rosenberg@dewire.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License, version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ */
+package org.spearce.jgit.lib;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+
+import junit.textui.TestRunner;
+
+/**
+ * A performance test like T0006_DeepSpeedTest, but more
+ * realistic since it is smarter.
+ */
+public class T0007_WalkerTest extends SpeedTestBase {
+
+ protected void setUp() throws Exception {
+ prepare(new String[] { "git", "log", "365bbe0d0caaf2ba74d56556827babf0bc66965d","--","net/netfilter/nf_queue.c" });
+ }
+
+ public void testHistoryScan() throws IOException {
+// long start = System.currentTimeMillis();
+ Repository db = new Repository(new File(kernelrepo));
+ String[] path = { "net", "netfilter", "nf_queue.c" };
+ Walker walker = new Walker(db,db.mapCommit(new ObjectId("365bbe0d0caaf2ba74d56556827babf0bc66965d")),path,true,true,null) {
+
+ protected void collect(Collection ret, Commit commit, int count) {
+ System.out.println("Got: "+count+" "+commit.getCommitId());
+ ret.add(commit);
+ }
+
+ };
+ Commit[] history = (Commit[])walker.collectHistory().toArray(new Commit[0]);
+ assertEquals(8, history.length);
+ assertEquals("365bbe0d0caaf2ba74d56556827babf0bc66965d",history[0].getCommitId().toString());
+ assertEquals("a4c12d6c5dde48c69464baf7c703e425ee511433",history[1].getCommitId().toString());
+ assertEquals("761a126017e3f001d3f5a574787aa232a9cd5bb5",history[2].getCommitId().toString());
+ assertEquals("22a3e233ca08a2ddc949ba1ae8f6e16ec7ef1a13",history[3].getCommitId().toString());
+ assertEquals("460fbf82c0842cad3f3c744c4dcb81978b7829f3",history[4].getCommitId().toString());
+ assertEquals("272a5322d5219b00a1e541ad9d0d76824df1aa2a",history[5].getCommitId().toString());
+ assertEquals("8e33ba49765484bc6de3a2f8143733713fa93bc1",history[6].getCommitId().toString());
+ assertEquals("826509f8110049663799bc20f2b5b6170e2f78ca",history[7].getCommitId().toString());
+
+ }
+
+ public static void main(String[] args) {
+ TestRunner.run(T0007_WalkerTest.class);
+ }
+}
^ permalink raw reply related
* [EGIT PATCH 05/10] Speed up ObjectId a little.
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
To: spearce; +Cc: git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
ObjectId size if fixed so we can exploit this fact.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/jgit/lib/ObjectId.java | 29 ++++++++++++++---------
1 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
index 45e23e6..fea0d91 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ObjectId.java
@@ -86,7 +86,7 @@ public class ObjectId implements Comparable {
private static int compare(final byte[] a, final byte[] b) {
if (a==b)
return 0;
- for (int k = 0; k < a.length && k < b.length; k++) {
+ for (int k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
final int ak = a[k] & 0xff;
final int bk = b[k] & 0xff;
if (ak < bk)
@@ -94,7 +94,11 @@ public class ObjectId implements Comparable {
else if (ak > bk)
return 1;
}
- return a.length == b.length ? 0 : a.length < b.length ? -1 : 1;
+ if (a.length != Constants.OBJECT_ID_LENGTH)
+ throw new IllegalArgumentException("Looks like a bad object id");
+ if (b.length != Constants.OBJECT_ID_LENGTH)
+ throw new IllegalArgumentException("Looks like a bad object id");
+ return 0;
}
private final byte[] id;
@@ -106,9 +110,11 @@ public class ObjectId implements Comparable {
}
id = new byte[Constants.OBJECT_ID_LENGTH];
+ char[] bs = new char[Constants.OBJECT_ID_LENGTH*2];
+ i.getChars(0,Constants.OBJECT_ID_LENGTH*2,bs,0);
for (int j = 0, k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
- final char c1 = i.charAt(j++);
- final char c2 = i.charAt(j++);
+ final char c1 = bs[j++];
+ final char c2 = bs[j++];
int b;
if ('0' <= c1 && c1 <= '9') {
@@ -181,7 +187,7 @@ public class ObjectId implements Comparable {
}
public void copyTo(final OutputStream w) throws IOException {
- for (int k = 0; k < id.length; k++) {
+ for (int k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
final int b = id[k];
final int b1 = (b >> 4) & 0xf;
final int b2 = b & 0xf;
@@ -191,7 +197,7 @@ public class ObjectId implements Comparable {
}
public void copyTo(final Writer w) throws IOException {
- for (int k = 0; k < id.length; k++) {
+ for (int k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
final int b = id[k];
final int b1 = (b >> 4) & 0xf;
final int b2 = b & 0xf;
@@ -201,14 +207,15 @@ public class ObjectId implements Comparable {
}
public String toString() {
- final StringBuffer r = new StringBuffer(2 * id.length);
- for (int k = 0; k < id.length; k++) {
+ byte s[] = new byte[Constants.OBJECT_ID_LENGTH*2];
+ int i = 0;
+ for (int k = 0; k < Constants.OBJECT_ID_LENGTH; k++) {
final int b = id[k];
final int b1 = (b >> 4) & 0xf;
final int b2 = b & 0xf;
- r.append(b1 < 10 ? (char) ('0' + b1) : (char) ('a' + b1 - 10));
- r.append(b2 < 10 ? (char) ('0' + b2) : (char) ('a' + b2 - 10));
+ s[i++] = (b1 < 10 ? (byte) ('0' + b1) : (byte) ('a' + b1 - 10));
+ s[i++] = (b2 < 10 ? (byte) ('0' + b2) : (byte) ('a' + b2 - 10));
}
- return r.toString();
+ return new String(s,0);
}
}
^ permalink raw reply related
* [EGIT PATCH 04/10] Bug: Do not crash when showing diff for first version of a file
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
To: spearce; +Cc: git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
We crashed because the right side did not contain any information
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../spearce/egit/ui/internal/GitResourceNode.java | 28 ++++++++++++++---------
1 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitResourceNode.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitResourceNode.java
index bdf8902..010b738 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitResourceNode.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/GitResourceNode.java
@@ -70,7 +70,10 @@ public class GitResourceNode extends BufferedContent implements IStructureCompar
}
public String getName() {
- return entry.getFullName();
+ if (entry != null)
+ return entry.getFullName();
+ else
+ return "<none>";
}
public Image getImage() {
@@ -81,16 +84,19 @@ public class GitResourceNode extends BufferedContent implements IStructureCompar
if (entry instanceof Tree)
return ITypedElement.FOLDER_TYPE;
else {
- String name = entry.getName();
- if (name != null) {
- int index = name.lastIndexOf('.');
- if (index == -1)
- return ""; //$NON-NLS-1$
- if (index == (name.length() - 1))
- return ""; //$NON-NLS-1$
- return name.substring(index + 1);
- }
- return "";
+ if (entry != null) {
+ String name = entry.getName();
+ if (name != null) {
+ int index = name.lastIndexOf('.');
+ if (index == -1)
+ return ""; //$NON-NLS-1$
+ if (index == (name.length() - 1))
+ return ""; //$NON-NLS-1$
+ return name.substring(index + 1);
+ }
+ return "";
+ } else
+ return "";
}
}
^ permalink raw reply related
* [EGIT PATCH 03/10] Update compare window immediately
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
To: spearce; +Cc: git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
Compute the commit diff for the selected revision in the history
view immediately when one version is selected if selection is
made with the left mouse button and a compare window is already
open. Thanks to the way git data structures are designed the diff
is usually instantenous.
We can't have it this way in the long run. Figure out something
better, like adding an icon to the history view for selecting
behaviour. Another ugly hack is the way I detect which mouse
button was clicked, if any so that right-clicking on a history
item does not cause the diff to be changed.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/egit/ui/GitHistoryPage.java | 47 +++++++++++++++++++----
1 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
index 8be23ec..4b437a6 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
@@ -18,6 +18,7 @@ package org.spearce.egit.ui;
import java.io.IOException;
import java.util.Date;
+import java.util.List;
import java.util.Map;
import org.eclipse.compare.CompareConfiguration;
@@ -42,6 +43,8 @@ import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
@@ -83,6 +86,8 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
private IFileRevision[] fileRevisions;
+ protected boolean hintShowDiffNow;
+
public GitHistoryPage(Object object) {
setInput(object);
}
@@ -114,6 +119,20 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
"Compare");
final GitCompareRevisionAction compareActionPrev = new GitCompareRevisionAction(
"Show commit");
+ tree.addMouseListener(new MouseListener() {
+
+ public void mouseUp(MouseEvent e) {
+ }
+
+ public void mouseDown(MouseEvent e) {
+ hintShowDiffNow = e.button==1;
+ }
+
+ public void mouseDoubleClick(MouseEvent e) {
+ }
+
+ });
+
tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// update the current
@@ -130,16 +149,25 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
GitProvider provider = (GitProvider)RepositoryProvider
.getProvider(project);
RepositoryMapping repositoryMapping = provider.getData().getRepositoryMapping(project);
- ObjectId parentId = (ObjectId)((GitFileRevision)selection2[0]).getCommit().getParentIds().get(0);
try {
- if (selection2.length == 1) {
- Commit parent = repositoryMapping.getRepository().mapCommit(parentId);
- IFileRevision previous = new GitFileRevision(parent,
- ((GitFileRevision)selection2[0]).getResource(),
- ((GitFileRevision)selection2[0]).getCount()+1);
-// compareActionPrev.setCurrentFileRevision(selection2[0]);
- compareActionPrev.setCurrentFileRevision(null);
- compareActionPrev.selectionChanged(new StructuredSelection(new IFileRevision[] {selection2[0], previous}));
+ if (selection2.length == 1 && hintShowDiffNow) {
+ List parentIds = ((GitFileRevision)selection2[0]).getCommit().getParentIds();
+ if (parentIds.size() > 0) {
+ ObjectId parentId = (ObjectId)parentIds.get(0);
+ Commit parent = repositoryMapping.getRepository().mapCommit(parentId);
+ IFileRevision previous = new GitFileRevision(parent,
+ ((GitFileRevision)selection2[0]).getResource(),
+ ((GitFileRevision)selection2[0]).getCount()+1);
+ compareActionPrev.setCurrentFileRevision(null);
+ compareActionPrev.selectionChanged(new StructuredSelection(new IFileRevision[] {selection2[0], previous}));
+ System.out.println("detail="+e.detail);
+ tree.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (GitCompareRevisionAction.findReusableCompareEditor(GitHistoryPage.this.getSite().getPage()) != null)
+ compareActionPrev.run();
+ }
+ });
+ }
} else {
compareActionPrev.setCurrentFileRevision(null);
compareActionPrev.selectionChanged(new StructuredSelection(new IFileRevision[0]));
@@ -148,6 +176,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
// TODO Auto-generated catch block
e1.printStackTrace();
}
+ hintShowDiffNow = false;
}
});
compareAction.setPage(this);
^ permalink raw reply related
* [EGIT PATCH 02/10] Recursion and update of all elements regardless of need.
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
To: spearce; +Cc: git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
When selecting an element in the history view viewer.updateElement
is called for every element recursively. If the number of
elements is very largs this results in a stack overflow. This
only happens with Eclipse 3.3 M7 and not M6.
Is it thig bug? https://bugs.eclipse.org/bugs/show_bug.cgi?id=149642
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/egit/ui/GitHistoryPage.java | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
index 7bc947b..8be23ec 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/GitHistoryPage.java
@@ -281,6 +281,8 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
viewer = new TreeViewer(tree, SWT.VIRTUAL | SWT.FULL_SELECTION);
+ viewer.setUseHashlookup(true);
+
createColumns();
viewer.setLabelProvider(new GitHistoryLabelProvider());
@@ -354,6 +356,7 @@ public class GitHistoryPage extends HistoryPage implements IAdaptable,
}
public void updateElement(Object parent, int index) {
+ System.out.println("updateElement("+parent+","+index);
viewer.replace(parent, index, fileRevisions[index]);
}
}
^ permalink raw reply related
* [EGIT PATCH 01/10] Fixes due to changes in the Eclipse Team API
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
To: spearce; +Cc: git
In-Reply-To: <20070507212636.21546.29280.stgit@lathund.dewire.com>
There were changes made in Eclipse 3.3M7 that
blew our cover. Apparently we were not using the
API:s properly. Hopefully this is somewhat better.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../actions/CompareWithRevisionAction.java | 5 ++---
.../actions/ShowResourceInHistoryAction.java | 5 ++---
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithRevisionAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithRevisionAction.java
index 9cded79..981c14c 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithRevisionAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CompareWithRevisionAction.java
@@ -22,14 +22,13 @@ import java.util.Hashtable;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ui.actions.TeamAction;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.history.HistoryPageSaveablePart;
public class CompareWithRevisionAction extends TeamAction {
- public void run(IAction action) {
+ public void execute(IAction action) {
super.run(action);
System.out.println("Run:" + action);
System.out.println("Selection resources:"
@@ -45,7 +44,7 @@ public class CompareWithRevisionAction extends TeamAction {
HistoryPageSaveablePart.showHistoryInDialog(shell, object);
}
- protected boolean isEnabled() throws TeamException {
+ public boolean isEnabled() {
return !getSelection().isEmpty();
}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ShowResourceInHistoryAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ShowResourceInHistoryAction.java
index db6f3e2..d2f9c47 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ShowResourceInHistoryAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/ShowResourceInHistoryAction.java
@@ -18,14 +18,13 @@ package org.spearce.egit.ui.internal.actions;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ui.actions.TeamAction;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.history.HistoryPageSaveablePart;
public class ShowResourceInHistoryAction extends TeamAction {
- public void run(IAction action) {
+ public void execute(IAction action) {
TeamUI.getHistoryView().showHistoryFor(getSelectedResources()[0]);
}
@@ -33,7 +32,7 @@ public class ShowResourceInHistoryAction extends TeamAction {
HistoryPageSaveablePart.showHistoryInDialog(shell, object);
}
- protected boolean isEnabled() throws TeamException {
+ public boolean isEnabled() {
return !getSelection().isEmpty();
}
}
^ permalink raw reply related
* [EGIT 00/10] This weeks Eclipse patches
From: Robin Rosenberg @ 2007-05-07 21:29 UTC (permalink / raw)
To: spearce; +Cc: git
A random collection of improvements to the Eclipse
plugin.
Highlights:
- Now compatible with Eclipse 3.2.1 through 3.3 M7
- Update compare view immediately when selecting a commit
with the left button.
- Compare with previous menu item, not just two selected
commits.
- Tooltip with full comment in history view
- Minor performance and API enhancements
- New bugs (FREE, apply now!)
You'll need Sun's JDK version 1.6 to run gracefully since the
memory mapping stresses the GC. With older versions you will get
out of memory errors needlessly, which currently means the
implementation does not see all objects.
-- robin
^ permalink raw reply
* RE: [PATCH 4/5] Add --remote option to send-pack
From: Loeliger Jon-LOELIGER @ 2007-05-07 20:08 UTC (permalink / raw)
To: Junio C Hamano, Daniel Barkalow; +Cc: git
In-Reply-To: <7vr6pvln89.fsf@assigned-by-dhcp.cox.net>
> Another thing is that which branch is merged into the current
> branch should not be a function of the current branch, as the
> current configuration mechanism suggests. The current way maps
> the current branch to "which repository's which branch". In
> addition to that, I think it should be a function of ("current
> branch", "remote repository") pair. IOW, allow you to say "If I
> pull from this remote without saying which one to merge, merge
> that branch. If I pull from this other remote, merge that other
> branch". Something like:
>
> [branch "master"]
> ; Use this when "git pull" did not say which remote
> remote = origin
>
> ; Use this when "git pull origin" did not say which
> ; branch(es) to merge
> merge = refs/heads/master
> ; the above should be a synonym for
> ; merge = refs/heads/master for origin
>
> ; "git pull fast-import" while on my "master"
> ; would merge 'for-junio' branch there.
> merge = refs/heads/for-junio for fast-import
>
> ; similarly, but use subtree strategy.
> merge = refs/heads/for-junio with subtree for git-gui
>
> [remote "origin"]
> url = git://git.kernel.org/pub/scm/git/git.git/
> fetch = refs/heads/*:remotes/origin/*
> [remote "fast-import"]
> url = git://repo.or.cz/git/fastimport.git/
> fetch = refs/heads/*:remotes/gfi/*
> [remote "git-gui"]
> url = git://repo.or.cz/git-gui.git/
> fetch = refs/heads/*:refs/remotes/git-gui/*
>
Yes, please!
Jdl
^ permalink raw reply
* Re: [PATCH] submodule merge support
From: Martin Waitz @ 2007-05-07 19:33 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Johannes Sixt, git
In-Reply-To: <alpine.LFD.0.98.0705071015230.3802@woody.linux-foundation.org>
[-- Attachment #1: Type: text/plain, Size: 342 bytes --]
hoi :)
On Mon, May 07, 2007 at 10:17:11AM -0700, Linus Torvalds wrote:
> Oh, btw, you should also look out for the case where the superproject
> doesn't actually have the subprojects in question checked out. What
> happens then? Just leave them conflicted?
yes, I think that's the only sane thing one can do.
--
Martin Waitz
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox