Skip to content

Commit 1c14691

Browse files
author
Vladimir Kotal
authored
remove repository update capability (#2938)
fixes #2330
1 parent e3c4fcc commit 1c14691

20 files changed

+0
-357
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/AccuRevRepository.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.nio.file.Paths;
3131
import java.nio.file.Path;
3232
import java.util.ArrayList;
33-
import java.util.List;
3433
import java.util.logging.Level;
3534
import java.util.logging.Logger;
3635
import java.util.regex.Matcher;
@@ -226,20 +225,6 @@ boolean getHistoryGet(
226225
return false;
227226
}
228227

229-
@Override
230-
public void update() throws IOException {
231-
File directory = new File(getDirectoryName());
232-
List<String> cmd = new ArrayList<>();
233-
234-
cmd.add(RepoCommand);
235-
cmd.add("update");
236-
237-
Executor executor = new Executor(cmd, directory);
238-
if (executor.exec() != 0) {
239-
throw new IOException(executor.getErrorString());
240-
}
241-
}
242-
243228
@Override
244229
boolean fileHasHistory(File file) {
245230
return true;

opengrok-indexer/src/main/java/org/opengrok/indexer/history/BazaarRepository.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -167,30 +167,6 @@ public boolean fileHasAnnotation(File file) {
167167
return true;
168168
}
169169

170-
@Override
171-
public void update() throws IOException {
172-
File directory = new File(getDirectoryName());
173-
174-
List<String> cmd = new ArrayList<>();
175-
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
176-
cmd.add(RepoCommand);
177-
cmd.add("info");
178-
Executor executor = new Executor(cmd, directory);
179-
if (executor.exec() != 0) {
180-
throw new IOException(executor.getErrorString());
181-
}
182-
183-
if (executor.getOutputString().contains("parent branch:")) {
184-
cmd.clear();
185-
cmd.add(RepoCommand);
186-
cmd.add("up");
187-
executor = new Executor(cmd, directory);
188-
if (executor.exec() != 0) {
189-
throw new IOException(executor.getErrorString());
190-
}
191-
}
192-
}
193-
194170
@Override
195171
public boolean fileHasHistory(File file) {
196172
// Todo: is there a cheap test for whether Bazaar has history

opengrok-indexer/src/main/java/org/opengrok/indexer/history/BitKeeperRepository.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,6 @@ public void buildTagList(File directory, boolean interactive) {
437437
}
438438
}
439439

440-
/* Update Stuff */
441-
442-
@Override
443-
public void update() {
444-
throw new UnsupportedOperationException("Not supported yet.");
445-
}
446-
447440
@Override
448441
String determineCurrentVersion(boolean interactive) throws IOException {
449442
return null;

opengrok-indexer/src/main/java/org/opengrok/indexer/history/CVSRepository.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,6 @@ public boolean isRepositoryFor(File file, boolean interactive) {
141141
return false;
142142
}
143143

144-
@Override
145-
public void update() throws IOException {
146-
File directory = new File(getDirectoryName());
147-
148-
List<String> cmd = new ArrayList<>();
149-
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
150-
cmd.add(RepoCommand);
151-
cmd.add("update");
152-
Executor executor = new Executor(cmd, directory);
153-
if (executor.exec() != 0) {
154-
throw new IOException(executor.getErrorString());
155-
}
156-
}
157-
158144
@Override
159145
String determineBranch(boolean interactive) throws IOException {
160146
String branch = null;

opengrok-indexer/src/main/java/org/opengrok/indexer/history/ClearCaseRepository.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
*/
2424
package org.opengrok.indexer.history;
2525

26-
import java.io.BufferedReader;
2726
import java.io.File;
2827
import java.io.FileInputStream;
2928
import java.io.IOException;
30-
import java.io.InputStreamReader;
3129
import java.util.ArrayList;
3230
import java.util.Arrays;
3331
import java.util.List;
@@ -177,44 +175,6 @@ public boolean fileHasAnnotation(File file) {
177175
return true;
178176
}
179177

180-
@SuppressWarnings("PMD.EmptyWhileStmt")
181-
@Override
182-
public void update() throws IOException {
183-
File directory = new File(getDirectoryName());
184-
185-
// Check if this is a snapshot view
186-
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
187-
String[] argv = {RepoCommand, "catcs"};
188-
Executor executor = new Executor(Arrays.asList(argv), directory);
189-
int status = executor.exec();
190-
if (status != 0) {
191-
LOGGER.log(Level.WARNING, "Failed to determine if {0} is snapshot view",
192-
directory);
193-
return;
194-
}
195-
boolean snapshot = false;
196-
String line;
197-
try (BufferedReader in = new BufferedReader(
198-
new InputStreamReader(executor.getOutputStream()))) {
199-
while (!snapshot && (line = in.readLine()) != null) {
200-
snapshot = line.startsWith("load");
201-
}
202-
}
203-
204-
if (snapshot) {
205-
// It is a snapshot view, we need to update it manually
206-
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
207-
argv = new String[]{RepoCommand, "update", "-overwrite", "-f"};
208-
executor = new Executor(Arrays.asList(argv), directory);
209-
try (BufferedReader in = new BufferedReader(
210-
new InputStreamReader(executor.getOutputStream()))) {
211-
while ((line = in.readLine()) != null) {
212-
// do nothing
213-
}
214-
}
215-
}
216-
}
217-
218178
@Override
219179
public boolean fileHasHistory(File file) {
220180
// Todo: is there a cheap test for whether ClearCase has history

opengrok-indexer/src/main/java/org/opengrok/indexer/history/GitRepository.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -487,32 +487,6 @@ public boolean fileHasAnnotation(File file) {
487487
return true;
488488
}
489489

490-
@Override
491-
public void update() throws IOException {
492-
File directory = new File(getDirectoryName());
493-
List<String> cmd = new ArrayList<>();
494-
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
495-
cmd.add(RepoCommand);
496-
cmd.add("config");
497-
cmd.add("--list");
498-
499-
Executor executor = new Executor(cmd, directory);
500-
if (executor.exec() != 0) {
501-
throw new IOException(executor.getErrorString());
502-
}
503-
504-
if (executor.getOutputString().contains("remote.origin.url=")) {
505-
cmd.clear();
506-
cmd.add(RepoCommand);
507-
cmd.add("pull");
508-
cmd.add("-n");
509-
cmd.add("-q");
510-
if (executor.exec() != 0) {
511-
throw new IOException(executor.getErrorString());
512-
}
513-
}
514-
}
515-
516490
@Override
517491
public boolean fileHasHistory(File file) {
518492
// Todo: is there a cheap test for whether Git has history

opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryGuru.java

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -506,69 +506,6 @@ public Collection<RepositoryInfo> getRepositories() {
506506
map(ri -> new RepositoryInfo(ri)).collect(Collectors.toSet());
507507
}
508508

509-
/**
510-
* Update the source contents in all repositories.
511-
*/
512-
public void updateRepositories() {
513-
for (Map.Entry<String, Repository> entry : repositories.entrySet()) {
514-
Repository repository = entry.getValue();
515-
516-
String path = entry.getKey();
517-
String type = repository.getClass().getSimpleName();
518-
519-
if (repository.isWorking()) {
520-
LOGGER.info(String.format("Update %s repository in %s",
521-
type, path));
522-
523-
try {
524-
repository.update();
525-
} catch (UnsupportedOperationException e) {
526-
LOGGER.warning(String.format("Skipping update of %s repository"
527-
+ " in %s: Not implemented", type, path));
528-
} catch (Exception e) {
529-
LOGGER.log(Level.WARNING, "An error occurred while updating "
530-
+ path + " (" + type + ")", e);
531-
}
532-
} else {
533-
LOGGER.warning(String.format("Skipping update of %s repository in "
534-
+ "%s: Missing SCM dependencies?", type, path));
535-
}
536-
}
537-
}
538-
539-
/**
540-
* Update the source contents in given repositories.
541-
*
542-
* @param paths A list of files/directories to update
543-
*/
544-
public void updateRepositories(Collection<String> paths) {
545-
List<Repository> repos = getReposFromString(paths);
546-
547-
for (Repository repository : repos) {
548-
String type = repository.getClass().getSimpleName();
549-
550-
if (repository.isWorking()) {
551-
LOGGER.info(String.format("Update %s repository in %s", type,
552-
repository.getDirectoryName()));
553-
554-
try {
555-
repository.update();
556-
} catch (UnsupportedOperationException e) {
557-
LOGGER.warning(String.format("Skipping update of %s repository"
558-
+ " in %s: Not implemented", type,
559-
repository.getDirectoryName()));
560-
} catch (Exception e) {
561-
LOGGER.log(Level.WARNING, "An error occurred while updating "
562-
+ repository.getDirectoryName() + " (" + type + ")", e);
563-
}
564-
} else {
565-
LOGGER.warning(String.format("Skipping update of %s repository in"
566-
+ " %s: Missing SCM dependencies?", type,
567-
repository.getDirectoryName()));
568-
}
569-
}
570-
}
571-
572509
private void createCache(Repository repository, String sinceRevision) {
573510
String path = repository.getDirectoryName();
574511
String type = repository.getClass().getSimpleName();

opengrok-indexer/src/main/java/org/opengrok/indexer/history/MercurialRepository.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -442,31 +442,6 @@ public boolean fileHasAnnotation(File file) {
442442
return true;
443443
}
444444

445-
@Override
446-
public void update() throws IOException {
447-
File directory = new File(getDirectoryName());
448-
449-
List<String> cmd = new ArrayList<>();
450-
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
451-
cmd.add(RepoCommand);
452-
cmd.add("showconfig");
453-
Executor executor = new Executor(cmd, directory);
454-
if (executor.exec() != 0) {
455-
throw new IOException(executor.getErrorString());
456-
}
457-
458-
if (executor.getOutputString().contains("paths.default=")) {
459-
cmd.clear();
460-
cmd.add(RepoCommand);
461-
cmd.add("pull");
462-
cmd.add("-u");
463-
executor = new Executor(cmd, directory);
464-
if (executor.exec() != 0) {
465-
throw new IOException(executor.getErrorString());
466-
}
467-
}
468-
}
469-
470445
@Override
471446
public boolean fileHasHistory(File file) {
472447
// Todo: is there a cheap test for whether mercurial has history

opengrok-indexer/src/main/java/org/opengrok/indexer/history/MonotoneRepository.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -156,30 +156,6 @@ public boolean fileHasAnnotation(File file) {
156156
return true;
157157
}
158158

159-
@Override
160-
public void update() throws IOException {
161-
File directory = new File(getDirectoryName());
162-
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
163-
164-
List<String> cmd = new ArrayList<>();
165-
cmd.add(RepoCommand);
166-
cmd.add("pull");
167-
cmd.add(getQuietOption());
168-
Executor executor = new Executor(cmd, directory);
169-
if (executor.exec() != 0) {
170-
throw new IOException(executor.getErrorString());
171-
}
172-
173-
cmd.clear();
174-
cmd.add(RepoCommand);
175-
cmd.add("update");
176-
cmd.add(getQuietOption());
177-
executor = new Executor(cmd, directory);
178-
if (executor.exec() != 0) {
179-
throw new IOException(executor.getErrorString());
180-
}
181-
}
182-
183159
@Override
184160
public boolean fileHasHistory(File file) {
185161
return true;

opengrok-indexer/src/main/java/org/opengrok/indexer/history/PerforceRepository.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,6 @@ boolean getHistoryGet(
119119
return false;
120120
}
121121

122-
@Override
123-
public void update() throws IOException {
124-
File directory = new File(getDirectoryName());
125-
126-
List<String> cmd = new ArrayList<>();
127-
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
128-
cmd.add(RepoCommand);
129-
cmd.add("sync");
130-
Executor executor = new Executor(cmd, directory);
131-
if (executor.exec() != 0) {
132-
throw new IOException(executor.getErrorString());
133-
}
134-
}
135-
136122
@Override
137123
boolean fileHasHistory(File file) {
138124
return true;

0 commit comments

Comments
 (0)