mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Remove unnecessary interfaces
This commit is contained in:
@@ -55,23 +55,36 @@ public class SimpleHgWorkingCopyFactory extends SimpleWorkingCopyFactory<Reposit
|
||||
this.hgRepositoryEnvironmentBuilder = hgRepositoryEnvironmentBuilder;
|
||||
}
|
||||
@Override
|
||||
public WorkingCopyInitializer<Repository, Repository> getInitializer(HgCommandContext context) {
|
||||
return (target, initialBranch) -> {
|
||||
Repository centralRepository = openCentral(context);
|
||||
CloneCommand cloneCommand = CloneCommandFlags.on(centralRepository);
|
||||
if (initialBranch != null) {
|
||||
cloneCommand.updaterev(initialBranch);
|
||||
}
|
||||
try {
|
||||
cloneCommand.execute(target.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
throw new InternalRepositoryException(context.getScmRepository(), "could not clone repository", e);
|
||||
}
|
||||
public ParentAndClone<Repository, Repository> initialize(HgCommandContext context, File target, String initialBranch) {
|
||||
Repository centralRepository = openCentral(context);
|
||||
CloneCommand cloneCommand = CloneCommandFlags.on(centralRepository);
|
||||
if (initialBranch != null) {
|
||||
cloneCommand.updaterev(initialBranch);
|
||||
}
|
||||
try {
|
||||
cloneCommand.execute(target.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
throw new InternalRepositoryException(context.getScmRepository(), "could not clone repository", e);
|
||||
}
|
||||
|
||||
BaseRepository clone = Repository.open(target);
|
||||
|
||||
return new ParentAndClone<>(centralRepository, clone, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ParentAndClone<Repository, Repository> reclaim(HgCommandContext context, File target, String initialBranch) throws ReclaimFailedException {
|
||||
Repository centralRepository = openCentral(context);
|
||||
try {
|
||||
BaseRepository clone = Repository.open(target);
|
||||
|
||||
for (String unknown : StatusCommand.on(clone).execute().getUnknown()) {
|
||||
delete(clone.getDirectory(), unknown);
|
||||
}
|
||||
UpdateCommand.on(clone).rev(initialBranch).clean().execute();
|
||||
return new ParentAndClone<>(centralRepository, clone, target);
|
||||
};
|
||||
} catch (ExecutionException | IOException e) {
|
||||
throw new ReclaimFailedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Repository openCentral(HgCommandContext context) {
|
||||
@@ -80,23 +93,6 @@ public class SimpleHgWorkingCopyFactory extends SimpleWorkingCopyFactory<Reposit
|
||||
return context.openWithSpecialEnvironment(repositoryMapBiConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WorkingCopyReclaimer<Repository, Repository> getReclaimer(HgCommandContext context) {
|
||||
return (target, initialBranch) -> {
|
||||
Repository centralRepository = openCentral(context);
|
||||
try {
|
||||
BaseRepository clone = Repository.open(target);
|
||||
for (String unknown : StatusCommand.on(clone).execute().getUnknown()) {
|
||||
delete(clone.getDirectory(), unknown);
|
||||
}
|
||||
UpdateCommand.on(clone).rev(initialBranch).clean().execute();
|
||||
return new ParentAndClone<>(centralRepository, clone, target);
|
||||
} catch (ExecutionException | IOException e) {
|
||||
throw new ReclaimFailedException(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void delete(File directory, String unknownFile) throws IOException {
|
||||
IOUtil.delete(new File(directory, unknownFile));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user