< prev index next >

bots/hgbridge/src/main/java/org/openjdk/skara/bots/hgbridge/JBridgeBot.java

Print this page

 46     public String toString() {
 47         return "JBridgeBot@" + exporterConfig.source();
 48     }
 49 
 50     @Override
 51     public List<WorkItem> getPeriodicItems() {
 52         return List.of(this);
 53     }
 54 
 55     @Override
 56     public boolean concurrentWith(WorkItem other) {
 57         if (other instanceof JBridgeBot) {
 58             JBridgeBot otherBridgeBot = (JBridgeBot)other;
 59             return !exporterConfig.source().equals(otherBridgeBot.exporterConfig.source());
 60         } else {
 61             return true;
 62         }
 63     }
 64 
 65     private void pushMarks(Path markSource, String destName, Path markScratchPath) throws IOException {
 66         var marksRepo = Repository.materialize(markScratchPath, exporterConfig.marksRepo().url(), exporterConfig.marksRef());

 67 
 68         // We should never change existing marks
 69         var markDest = markScratchPath.resolve(destName);
 70         var updated = Files.readString(markSource);
 71         if (Files.exists(markDest)) {
 72             var existing = Files.readString(markDest);
 73 
 74             if (!updated.startsWith(existing)) {
 75                 throw new RuntimeException("Update containing conflicting marks!");
 76             }
 77             if (existing.equals(updated)) {
 78                 // Nothing new to push
 79                 return;
 80             }
 81         } else {
 82             if (!Files.exists(markDest.getParent())) {
 83                 Files.createDirectories(markDest.getParent());
 84             }
 85         }
 86 

 46     public String toString() {
 47         return "JBridgeBot@" + exporterConfig.source();
 48     }
 49 
 50     @Override
 51     public List<WorkItem> getPeriodicItems() {
 52         return List.of(this);
 53     }
 54 
 55     @Override
 56     public boolean concurrentWith(WorkItem other) {
 57         if (other instanceof JBridgeBot) {
 58             JBridgeBot otherBridgeBot = (JBridgeBot)other;
 59             return !exporterConfig.source().equals(otherBridgeBot.exporterConfig.source());
 60         } else {
 61             return true;
 62         }
 63     }
 64 
 65     private void pushMarks(Path markSource, String destName, Path markScratchPath) throws IOException {
 66         var marksRepo = Repository.materialize(markScratchPath, exporterConfig.marksRepo().url(),
 67                                                "+" + exporterConfig.marksRef() + ":hgbridge_marks");
 68 
 69         // We should never change existing marks
 70         var markDest = markScratchPath.resolve(destName);
 71         var updated = Files.readString(markSource);
 72         if (Files.exists(markDest)) {
 73             var existing = Files.readString(markDest);
 74 
 75             if (!updated.startsWith(existing)) {
 76                 throw new RuntimeException("Update containing conflicting marks!");
 77             }
 78             if (existing.equals(updated)) {
 79                 // Nothing new to push
 80                 return;
 81             }
 82         } else {
 83             if (!Files.exists(markDest.getParent())) {
 84                 Files.createDirectories(markDest.getParent());
 85             }
 86         }
 87 
< prev index next >