Fix deprecation warnings from latest JGit update

- FS is no longer required for LockFile constructor.
 - TestRepository#getClock was renamed getDate.
 - Replace usages of RefDatabase#getRef with either exactRef, when we
   know we can bypass the full lookup path, or findRef, where the
   input is user-provided and we might need to add an implicit prefix.

Change-Id: I6309b91ccf99ffaa724be273ddae0d9857b825f9
This commit is contained in:
Dave Borowitz
2016-01-06 10:34:50 -05:00
parent bb5c68c4b9
commit f83c424b4b
25 changed files with 44 additions and 48 deletions

View File

@@ -316,18 +316,17 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
}
@Override
public void setProjectDescription(final Project.NameKey name,
final String description) {
public void setProjectDescription(Project.NameKey name, String description) {
// Update git's description file, in case gitweb is being used
//
try (Repository e = openRepository(name)) {
final String old = getProjectDescription(e);
String old = getProjectDescription(e);
if ((old == null && description == null)
|| (old != null && old.equals(description))) {
return;
}
final LockFile f = new LockFile(new File(e.getDirectory(), "description"), FS.DETECTED);
LockFile f = new LockFile(new File(e.getDirectory(), "description"));
if (f.lock()) {
String d = description;
if (d != null) {

View File

@@ -229,12 +229,12 @@ public class SubmoduleOp {
boolean sameAuthorForAll = true;
try (Repository pdb = repoManager.openRepository(subscriber.getParentKey())) {
if (pdb.getRef(subscriber.get()) == null) {
if (pdb.exactRef(subscriber.get()) == null) {
throw new SubmoduleException(
"The branch was probably deleted from the subscriber repository");
}
DirCache dc = readTree(pdb, pdb.getRef(subscriber.get()));
DirCache dc = readTree(pdb, pdb.exactRef(subscriber.get()));
DirCacheEditor ed = dc.editor();
for (SubmoduleSubscription s : updates) {
@@ -308,7 +308,7 @@ public class SubmoduleOp {
ObjectId tree = dc.writeTree(oi);
ObjectId currentCommitId =
pdb.getRef(subscriber.get()).getObjectId();
pdb.exactRef(subscriber.get()).getObjectId();
CommitBuilder commit = new CommitBuilder();
commit.setTreeId(tree);

View File

@@ -507,7 +507,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
Ref[] result = new Ref[showBranch.size()];
try (Repository git = repoManager.openRepository(projectName)) {
for (int i = 0; i < showBranch.size(); i++) {
Ref ref = git.getRef(showBranch.get(i));
Ref ref = git.findRef(showBranch.get(i));
if (ref != null
&& ref.getObjectId() != null
&& (projectControl.controlForRef(ref.getLeaf().getName()).isVisible())

View File

@@ -93,7 +93,7 @@ public class DefaultSecureStore extends SecureStore {
if (FileUtil.modified(sec)) {
final byte[] out = Constants.encode(sec.toText());
final File path = sec.getFile();
final LockFile lf = new LockFile(path, FS.DETECTED);
final LockFile lf = new LockFile(path);
if (!lf.lock()) {
throw new IOException("Cannot lock " + path);
}

View File

@@ -258,7 +258,7 @@ public class ProjectConfigTest extends LocalDiskRepositoryTestCase {
md.setMessage("Edit\n");
cfg.commit(md);
Ref ref = db.getRef(RefNames.REFS_CONFIG);
Ref ref = db.exactRef(RefNames.REFS_CONFIG);
return util.getRevWalk().parseCommit(ref.getObjectId());
}
}

View File

@@ -559,12 +559,12 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
batch1 = update1.openUpdateInBatch(bru);
batch1.write(update1, new CommitBuilder());
batch1.commit();
assertThat(repo.getRef(update1.getRefName())).isNull();
assertThat(repo.exactRef(update1.getRefName())).isNull();
batch2 = update2.openUpdateInBatch(bru);
batch2.write(update2, new CommitBuilder());
batch2.commit();
assertThat(repo.getRef(update2.getRefName())).isNull();
assertThat(repo.exactRef(update2.getRefName())).isNull();
} finally {
if (batch1 != null) {
batch1.close();
@@ -586,8 +586,8 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
assertThat(cmds.get(0).getResult()).isEqualTo(ReceiveCommand.Result.OK);
assertThat(cmds.get(1).getResult()).isEqualTo(ReceiveCommand.Result.OK);
assertThat(repo.getRef(update1.getRefName())).isNotNull();
assertThat(repo.getRef(update2.getRefName())).isNotNull();
assertThat(repo.exactRef(update1.getRefName())).isNotNull();
assertThat(repo.exactRef(update2.getRefName())).isNotNull();
}
@Test