fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. // git のイメージ(一部だけ)
  8.  
  9.  
  10. static class Blob { // (リポジトリ内にコピー保存された)ファイル
  11. String hash;
  12. String filePath;
  13. int fileSize;
  14. long lastUpdate;
  15. public Blob() {}
  16. }
  17.  
  18. static class Commit {
  19. String hash;
  20. HashMap<String, Blob> blobs; // このコミットが持つ全てのファイル(Blob)
  21. ArrayList<Commit> parents; // このコミットの親
  22. ArrayList<Commit> children; // このコミットの子
  23. public Commit() {}
  24. public boolean include(Commit commit) {
  25. if (this == commit) return true;
  26. for (Commit parent : parents) {
  27. if (parent.include(commit)) return true;
  28. }
  29. return false;
  30. }
  31. }
  32.  
  33. static class Branch {
  34. String name;
  35. Commit HEAD;
  36. public Branch(String name, Commit head) {
  37. this.name = name;
  38. HEAD = head;
  39. }
  40. public void merge(Branch b) {
  41. if (b.HEAD.include(this.HEAD)) {
  42. fastForward(b.HEAD);
  43. } else {
  44. // 2つのHEAD(Commit)が持つファイルを比較して
  45. // 必要なら各ファイルごとにマージして
  46. // その結果を新しいコミットに記録して
  47. // その新しいコミットをこのBranchのHEADとする
  48. }
  49. }
  50. private void fastForward(Commit head) {
  51. HEAD = head;
  52. }
  53. }
  54.  
  55. static class Tag {
  56. final String name;
  57. final Commit commit;
  58. public Tag(String name, Commit commit) {
  59. this.name = name;
  60. this.commit = commit;
  61. }
  62. }
  63.  
  64.  
  65. public static void main (String[] args) throws java.lang.Exception
  66. {
  67. }
  68. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
Standard output is empty