Mercurial > jhg
comparison cmdline/org/tmatesoft/hg/console/Log.java @ 143:b9700740553a
Command line tools parse and respect most of command-line arguments
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 17 Feb 2011 22:16:25 +0100 |
| parents | 37a34044e6bd |
| children | 3a7696fb457c |
comparison
equal
deleted
inserted
replaced
| 142:37a34044e6bd | 143:b9700740553a |
|---|---|
| 40 HgRepository hgRepo = cmdLineOpts.findRepository(); | 40 HgRepository hgRepo = cmdLineOpts.findRepository(); |
| 41 if (hgRepo.isInvalid()) { | 41 if (hgRepo.isInvalid()) { |
| 42 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); | 42 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); |
| 43 return; | 43 return; |
| 44 } | 44 } |
| 45 System.out.println(hgRepo.getLocation()); | |
| 46 final Dump dump = new Dump(hgRepo); | 45 final Dump dump = new Dump(hgRepo); |
| 47 dump.complete = true; //cmdLineOpts; | 46 dump.complete = cmdLineOpts.getBoolean("--debug"); |
| 48 dump.verbose = false; //cmdLineOpts; | 47 dump.verbose = cmdLineOpts.getBoolean("-v", "--verbose"); |
| 49 dump.reverseOrder = true; | 48 dump.reverseOrder = true; |
| 50 HgLogCommand cmd = new HgLogCommand(hgRepo); | 49 HgLogCommand cmd = new HgLogCommand(hgRepo); |
| 51 if (cmdLineOpts.users != null) { | 50 for (String u : cmdLineOpts.getList("-u", "--user")) { |
| 52 for (String u : cmdLineOpts.users) { | 51 cmd.user(u); |
| 53 cmd.user(u); | 52 } |
| 54 } | 53 for (String b : cmdLineOpts.getList("-b", "--branches")) { |
| 55 } | 54 cmd.branch(b); |
| 56 if (cmdLineOpts.branches != null) { | 55 } |
| 57 for (String b : cmdLineOpts.branches) { | 56 int limit = cmdLineOpts.getSingleInt(-1, "-l", "--limit"); |
| 58 cmd.branch(b); | 57 if (limit != -1) { |
| 59 } | 58 cmd.limit(limit); |
| 60 } | 59 } |
| 61 if (cmdLineOpts.limit != -1) { | 60 List<String> files = cmdLineOpts.getList(""); |
| 62 cmd.limit(cmdLineOpts.limit); | 61 if (files.isEmpty()) { |
| 63 | 62 if (limit == -1) { |
| 64 } | |
| 65 if (cmdLineOpts.files.isEmpty()) { | |
| 66 if (cmdLineOpts.limit == -1) { | |
| 67 // no revisions and no limit | 63 // no revisions and no limit |
| 68 cmd.execute(dump); | 64 cmd.execute(dump); |
| 69 } else { | 65 } else { |
| 70 // in fact, external (to dump inspector) --limit processing yelds incorrect results when other args | 66 // in fact, external (to dump inspector) --limit processing yelds incorrect results when other args |
| 71 // e.g. -u or -b are used (i.e. with -u shall give <limit> csets with user, not check last <limit> csets for user | 67 // e.g. -u or -b are used (i.e. with -u shall give <limit> csets with user, not check last <limit> csets for user |
| 72 int[] r = new int[] { 0, hgRepo.getChangelog().getRevisionCount() }; | 68 int[] r = new int[] { 0, hgRepo.getChangelog().getRevisionCount() }; |
| 73 if (fixRange(r, dump.reverseOrder, cmdLineOpts.limit) == 0) { | 69 if (fixRange(r, dump.reverseOrder, limit) == 0) { |
| 74 System.out.println("No changes"); | 70 System.out.println("No changes"); |
| 75 return; | 71 return; |
| 76 } | 72 } |
| 77 cmd.range(r[0], r[1]).execute(dump); | 73 cmd.range(r[0], r[1]).execute(dump); |
| 78 } | 74 } |
| 79 dump.complete(); | 75 dump.complete(); |
| 80 } else { | 76 } else { |
| 81 for (String fname : cmdLineOpts.files) { | 77 for (String fname : files) { |
| 82 HgDataFile f1 = hgRepo.getFileNode(fname); | 78 HgDataFile f1 = hgRepo.getFileNode(fname); |
| 83 System.out.println("History of the file: " + f1.getPath()); | 79 System.out.println("History of the file: " + f1.getPath()); |
| 84 if (cmdLineOpts.limit == -1) { | 80 if (limit == -1) { |
| 85 cmd.file(f1.getPath(), true).execute(dump); | 81 cmd.file(f1.getPath(), true).execute(dump); |
| 86 } else { | 82 } else { |
| 87 int[] r = new int[] { 0, f1.getRevisionCount() }; | 83 int[] r = new int[] { 0, f1.getRevisionCount() }; |
| 88 if (fixRange(r, dump.reverseOrder, cmdLineOpts.limit) == 0) { | 84 if (fixRange(r, dump.reverseOrder, limit) == 0) { |
| 89 System.out.println("No changes"); | 85 System.out.println("No changes"); |
| 90 continue; | 86 continue; |
| 91 } | 87 } |
| 92 cmd.range(r[0], r[1]).file(f1.getPath(), true).execute(dump); | 88 cmd.range(r[0], r[1]).file(f1.getPath(), true).execute(dump); |
| 93 } | 89 } |
