< prev index next >

vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java

Print this page

1075         }
1076         if (remote != null) {
1077             cmd.add(remote);
1078         }
1079         try (var p = capture(cmd)) {
1080             await(p);
1081         }
1082     }
1083 
1084     @Override
1085     public boolean contains(Branch b, Hash h) throws IOException {
1086         try (var p = capture("hg", "log", "--template", "{branch}", "-r", h.hex())) {
1087             var res = await(p);
1088             if (res.stdout().size() != 1) {
1089                 throw new IOException("Unexpected output: " + String.join("\n", res.stdout()));
1090             }
1091             var line = res.stdout().get(0);
1092             return line.equals(b.name());
1093         }
1094     }


































1095 }

1075         }
1076         if (remote != null) {
1077             cmd.add(remote);
1078         }
1079         try (var p = capture(cmd)) {
1080             await(p);
1081         }
1082     }
1083 
1084     @Override
1085     public boolean contains(Branch b, Hash h) throws IOException {
1086         try (var p = capture("hg", "log", "--template", "{branch}", "-r", h.hex())) {
1087             var res = await(p);
1088             if (res.stdout().size() != 1) {
1089                 throw new IOException("Unexpected output: " + String.join("\n", res.stdout()));
1090             }
1091             var line = res.stdout().get(0);
1092             return line.equals(b.name());
1093         }
1094     }
1095 
1096     @Override
1097     public List<Reference> remoteBranches(String remote) throws IOException {
1098         var refs = new ArrayList<Reference>();
1099 
1100         var ext = Files.createTempFile("ext", ".py");
1101         copyResource(EXT_PY, ext);
1102 
1103         try (var p = capture("hg", "--config", "extensions.ls-remote=" + ext, "ls-remote", remote)) {
1104             var res = await(p);
1105             for (var line : res.stdout()) {
1106                 var parts = line.split("\t");
1107                 refs.add(new Reference(parts[1], new Hash(parts[0])));
1108             }
1109         }
1110         return refs;
1111     }
1112 
1113     @Override
1114     public List<String> remotes() throws IOException {
1115         var remotes = new ArrayList<String>();
1116         try (var p = capture("hg", "paths")) {
1117             for (var line : await(p).stdout()) {
1118                 var parts = line.split(" = ");
1119                 var name = parts[0];
1120                 if (name.endsWith("-push") || name.endsWith(":push")) {
1121                     continue;
1122                 } else {
1123                     remotes.add(name);
1124                 }
1125             }
1126         }
1127         return remotes;
1128     }
1129 }
< prev index next >