From: mr.gaffo@gmail.com
To: git@vger.kernel.org
Cc: Mike Gaffney <mr.gaffo@gmail.com>
Subject: [PATCH JGit 4/5] Adding in a InfoDatabase like ObjectDatabase and and implementation based upon a directory.
Date: Tue, 15 Sep 2009 19:48:35 -0500 [thread overview]
Message-ID: <1253062116-13830-5-git-send-email-mr.gaffo@gmail.com> (raw)
In-Reply-To: <1253062116-13830-4-git-send-email-mr.gaffo@gmail.com>
From: Mike Gaffney <mr.gaffo@gmail.com>
Signed-off-by: Mike Gaffney <mr.gaffo@gmail.com>
---
.../jgit/lib/InfoDirectoryDatabaseTest.java | 66 ++++++++++++++++++++
.../org/spearce/jgit/lib/ObjectDirectoryTest.java | 1 -
.../src/org/spearce/jgit/lib/InfoDatabase.java | 44 +++++++++++++
.../spearce/jgit/lib/InfoDirectoryDatabase.java | 54 ++++++++++++++++
.../src/org/spearce/jgit/lib/Repository.java | 11 +++
5 files changed, 175 insertions(+), 1 deletions(-)
create mode 100644 org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
create mode 100644 org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
new file mode 100644
index 0000000..066473d
--- /dev/null
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/InfoDirectoryDatabaseTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2009, Mike Gaffney.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.spearce.jgit.lib;
+
+import java.io.File;
+
+import org.spearce.jgit.util.JGitTestUtil;
+
+import junit.framework.TestCase;
+
+public class InfoDirectoryDatabaseTest extends TestCase {
+
+ private File testDir;
+
+ @Override
+ protected void setUp() throws Exception {
+ testDir = JGitTestUtil.generateTempDirectoryFileObject();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (testDir.exists()){
+ JGitTestUtil.recursiveDelete(testDir, false, getClass().getName() + "." + getName(), true);
+ }
+ }
+
+ public void testCreateCreatesDirectory() throws Exception {
+ assertFalse(testDir.exists());
+ new InfoDirectoryDatabase(testDir).create();
+ assertTrue(testDir.exists());
+ }
+}
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
index 204fb7c..8c1d32d 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/ObjectDirectoryTest.java
@@ -38,7 +38,6 @@
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.List;
import org.spearce.jgit.util.JGitTestUtil;
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
new file mode 100644
index 0000000..2a8d88d
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDatabase.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2009, Mike Gaffney.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.spearce.jgit.lib;
+
+public abstract class InfoDatabase {
+
+ public void create() {
+ }
+
+}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
new file mode 100644
index 0000000..90655e8
--- /dev/null
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/InfoDirectoryDatabase.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2009, Mike Gaffney.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.spearce.jgit.lib;
+
+import java.io.File;
+
+public class InfoDirectoryDatabase extends InfoDatabase {
+
+ private File info;
+
+ public InfoDirectoryDatabase(final File directory) {
+ info = directory;
+ }
+
+ @Override
+ public void create() {
+ info.mkdirs();
+ }
+
+}
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 46b7804..f658b5c 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -97,6 +97,8 @@
private final RefDatabase refs;
private final ObjectDirectory objectDatabase;
+
+ private final InfoDatabase infoDatabase;
private GitIndex index;
@@ -116,6 +118,7 @@ public Repository(final File d) throws IOException {
gitDir = d.getAbsoluteFile();
refs = new RefDatabase(this);
objectDatabase = new ObjectDirectory(FS.resolve(gitDir, "objects"));
+ infoDatabase = new InfoDirectoryDatabase(FS.resolve(gitDir, "info"));
final FileBasedConfig userConfig;
userConfig = SystemReader.getInstance().openUserConfig();
@@ -177,6 +180,7 @@ public void create(boolean bare) throws IOException {
gitDir.mkdirs();
refs.create();
objectDatabase.create();
+ infoDatabase.create();
new File(gitDir, "branches").mkdir();
new File(gitDir, "remotes").mkdir();
@@ -210,6 +214,13 @@ public File getObjectsDirectory() {
public ObjectDatabase getObjectDatabase() {
return objectDatabase;
}
+
+ /**
+ * @return the info database which stores this repository's info
+ */
+ public InfoDatabase getInfoDatabase() {
+ return infoDatabase;
+ }
/**
* @return the configuration of this repository
--
1.6.4.2
next prev parent reply other threads:[~2009-09-16 0:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-16 0:48 [PATCH JGit] Adding update-server-info functionality try2 mr.gaffo
2009-09-16 0:48 ` [PATCH JGit 1/5] adding tests for ObjectDirectory mr.gaffo
2009-09-16 0:48 ` [PATCH JGit 2/5] Create abstract method on ObjectDatabase for accessing the list of local pack files mr.gaffo
2009-09-16 0:48 ` [PATCH JGit 3/5] Implemented directory based info cache for objects/info/packs mr.gaffo
2009-09-16 0:48 ` mr.gaffo [this message]
2009-09-16 0:48 ` [PATCH JGit 5/5] added tests for the file based info cache update and made pass mr.gaffo
2009-10-08 17:12 ` Shawn O. Pearce
2009-10-08 17:05 ` [PATCH JGit 4/5] Adding in a InfoDatabase like ObjectDatabase and and implementation based upon a directory Shawn O. Pearce
2009-10-08 17:00 ` [PATCH JGit 3/5] Implemented directory based info cache for objects/info/packs Shawn O. Pearce
2009-09-21 19:40 ` [PATCH JGit 2/5] Create abstract method on ObjectDatabase for accessing the list of local pack files Shawn O. Pearce
2009-09-21 19:51 ` Michael Gaffney
2009-09-21 19:30 ` [PATCH JGit 1/5] adding tests for ObjectDirectory Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1253062116-13830-5-git-send-email-mr.gaffo@gmail.com \
--to=mr.gaffo@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).