tikhomirov@32: /* tikhomirov@74: * Copyright (c) 2011 TMate Software Ltd tikhomirov@74: * tikhomirov@74: * This program is free software; you can redistribute it and/or modify tikhomirov@74: * it under the terms of the GNU General Public License as published by tikhomirov@74: * the Free Software Foundation; version 2 of the License. tikhomirov@74: * tikhomirov@74: * This program is distributed in the hope that it will be useful, tikhomirov@74: * but WITHOUT ANY WARRANTY; without even the implied warranty of tikhomirov@74: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tikhomirov@74: * GNU General Public License for more details. tikhomirov@74: * tikhomirov@74: * For information on how to redistribute this software under tikhomirov@74: * the terms of a license other than GNU General Public License tikhomirov@102: * contact TMate Software at support@hg4j.com tikhomirov@32: */ tikhomirov@74: package org.tmatesoft.hg.console; tikhomirov@32: tikhomirov@32: import java.io.File; tikhomirov@299: import java.util.Collections; tikhomirov@32: tikhomirov@354: import org.tmatesoft.hg.core.HgCallbackTargetException; tikhomirov@354: import org.tmatesoft.hg.core.HgException; tikhomirov@182: import org.tmatesoft.hg.core.Nodeid; tikhomirov@74: import org.tmatesoft.hg.repo.HgBundle; tikhomirov@182: import org.tmatesoft.hg.repo.HgChangelog; tikhomirov@169: import org.tmatesoft.hg.repo.HgLookup; tikhomirov@74: import org.tmatesoft.hg.repo.HgRepository; tikhomirov@182: import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; tikhomirov@74: tikhomirov@32: tikhomirov@32: /** tikhomirov@74: * WORK IN PROGRESS, DO NOT USE tikhomirov@74: * tikhomirov@74: * @author Artem Tikhomirov tikhomirov@74: * @author TMate Software Ltd. tikhomirov@32: */ tikhomirov@32: public class Bundle { tikhomirov@32: public static void main(String[] args) throws Exception { tikhomirov@299: Options cmdLineOpts = Options.parse(args, Collections.emptySet()); tikhomirov@182: final HgRepository hgRepo = cmdLineOpts.findRepository(); tikhomirov@37: if (hgRepo.isInvalid()) { tikhomirov@37: System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation()); tikhomirov@37: return; tikhomirov@37: } tikhomirov@190: File bundleFile = new File("/temp/hg/hg-bundle-cpython.tmp"); tikhomirov@169: HgBundle hgBundle = new HgLookup().loadBundle(bundleFile); tikhomirov@190: hgBundle.inspectFiles(new HgBundle.Dump()); tikhomirov@190: if (Boolean.parseBoolean("true")) { tikhomirov@190: return; tikhomirov@190: } tikhomirov@169: /* pass -R , e.g. for bundle with tip=168 and -R \temp\hg4j-50 with tip:159 tikhomirov@169: +Changeset {User: ..., Comment: Integer ....} tikhomirov@169: +Changeset {User: ..., Comment: Approach with ...} tikhomirov@169: -Changeset {User: ..., Comment: Correct project name...} tikhomirov@169: -Changeset {User: ..., Comment: Record possible...} tikhomirov@169: */ tikhomirov@182: hgBundle.changes(hgRepo, new HgChangelog.Inspector() { tikhomirov@182: private final HgChangelog changelog = hgRepo.getChangelog(); tikhomirov@182: tikhomirov@182: public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) { tikhomirov@354: try { tikhomirov@354: if (changelog.isKnown(nodeid)) { tikhomirov@354: System.out.print("+"); tikhomirov@354: } else { tikhomirov@354: System.out.print("-"); tikhomirov@354: } tikhomirov@354: System.out.printf("%d:%s\n%s\n", revisionNumber, nodeid.shortNotation(), cset.toString()); tikhomirov@354: } catch (HgException ex) { tikhomirov@354: throw new HgCallbackTargetException.Wrap(ex); tikhomirov@182: } tikhomirov@182: } tikhomirov@182: }); tikhomirov@35: } tikhomirov@169: tikhomirov@169: /* tikhomirov@169: * TODO EXPLAIN why DataAccess.java on merge from branch has P2 set, and P1 is NULL tikhomirov@169: * tikhomirov@169: * excerpt from dump('hg-bundle-00') output (node, p1, p2, cs): tikhomirov@169: src/org/tmatesoft/hg/internal/DataAccess.java tikhomirov@169: 186af94a2a7ddb34190e63ce556d0fa4dd24add2 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 6f1b88693d48422e98c3eaaa8428ffd4d4d98ca7; patches:1 tikhomirov@169: be8d0fdc4ff268bf5eb0a9120282ce6e63de1606 186af94a2a7ddb34190e63ce556d0fa4dd24add2 0000000000000000000000000000000000000000 a3a2e5deb320d7412ccbb59bdc44668d445bc4c4; patches:2 tikhomirov@169: 333d7bbd4a80a5d6fb4b44e54e39e290f50dc7f8 be8d0fdc4ff268bf5eb0a9120282ce6e63de1606 0000000000000000000000000000000000000000 e93101b97e4ab0a3f3402ec0e80b6e559237c7c8; patches:1 tikhomirov@169: 56e4523cb8b42630daf70511d73d29e0b375dfa5 0000000000000000000000000000000000000000 333d7bbd4a80a5d6fb4b44e54e39e290f50dc7f8 d5268ca7715b8d96204fc62abc632e8f55761547; patches:6 tikhomirov@169: f85b6d7ed3cc4b7c6f99444eb0a41b58793cc900 56e4523cb8b42630daf70511d73d29e0b375dfa5 0000000000000000000000000000000000000000 b413b16d10a50cc027f4c38e4df5a9fedd618a79; patches:4 tikhomirov@169: tikhomirov@169: RevlogDump for the file says: tikhomirov@169: Index Offset Flags Packed Actual Base Rev Link Rev Parent1 Parent2 nodeid tikhomirov@169: 0: 4295032832 0 1109 2465 0 74 -1 -1 186af94a2a7ddb34190e63ce556d0fa4dd24add2 tikhomirov@169: 1: 1109 0 70 2364 0 102 0 -1 be8d0fdc4ff268bf5eb0a9120282ce6e63de1606 tikhomirov@169: 2: 1179 0 63 2365 0 122 1 -1 333d7bbd4a80a5d6fb4b44e54e39e290f50dc7f8 tikhomirov@169: 3: 1242 0 801 3765 0 157 -1 2 56e4523cb8b42630daf70511d73d29e0b375dfa5 tikhomirov@169: 4: 2043 0 130 3658 0 158 3 -1 f85b6d7ed3cc4b7c6f99444eb0a41b58793cc900 tikhomirov@169: tikhomirov@169: Excerpt from changelog dump: tikhomirov@169: 155: 30541 0 155 195 155 155 154 -1 a4ec5e08701771b96057522188b16ed289e9e8fe tikhomirov@169: 156: 30696 0 154 186 155 156 155 -1 643ddec3be36246fc052cf22ece503fa60cafe22 tikhomirov@169: 157: 30850 0 478 1422 155 157 156 53 d5268ca7715b8d96204fc62abc632e8f55761547 tikhomirov@169: 158: 31328 0 247 665 155 158 157 -1 b413b16d10a50cc027f4c38e4df5a9fedd618a79 tikhomirov@169: tikhomirov@169: tikhomirov@169: */ tikhomirov@32: }