Package com.aragost.javahg.internals

Examples of com.aragost.javahg.internals.HgInputStream


     *
     * @return old branch name
     * @throws IOException
     */
    public String clean() throws IOException {
        HgInputStream stream = launchStream("--clean");
        stream.mustMatch(CLEAN_PREFIX);
        String oldName = stream.textUpTo('\n');
        stream.consumeAll();
        return oldName;
    }
View Full Code Here


     * Rollback last transaction.
     *
     * @return The new tip of the repository
     */
    public Changeset execute() {
        HgInputStream stream = launchStream();
        try {
            stream.mustMatch(REPOSITORY_TIP_ROLLBACK_REVSION);
            int rev = stream.decimalIntUpTo(' ');
            stream.consumeAll();
            return Utils.single(LogCommand.on(getRepository()).rev(String.valueOf(rev)).execute());
        } catch (IOException e) {
            throw new RuntimeIOException(e);
        }
    }
View Full Code Here

     *
     * @return all bookmarks
     */
    public List<Bookmark> list() {
        Repository repo = getRepository();
        HgInputStream stream = launchStream();
        try {
            if (stream.match(NO_BOOKMARKS)) {
                return Collections.emptyList();
            }
            List<Bookmark> result = Lists.newArrayList();
            while (stream.peek() != -1) {
                stream.mustMatch(' ');
                boolean active = stream.read() == '*';
                stream.mustMatch(' ');
                String name = stream.textUpTo(' ');
                stream.upTo(':');
                String node = stream.textUpTo('\n');
                Bookmark bookmark = new Bookmark(repo.changeset(node), name, active);
                result.add(bookmark);
            }
            return result;
        } catch (IOException e) {
View Full Code Here

        List<String> commandLine = new ArrayList<String>(this.cmdLine);
        getRepository().addToCommandLine(commandLine);
        commandLine.addAll(Arrays.asList(args));
        try {
            this.outputChannelStream = this.repository.getServer().runCommand(commandLine, this);
            return new HgInputStream(outputChannelStream, this.repository.getServer().getDecoder());
        } catch (IOException e) {
            throw new RuntimeIOException(e);
        }
    }
View Full Code Here

    public Bundle execute(String src) throws IOException {
        if (this.bundleFile == null) {
            this.bundleFile = File.createTempFile("javahg", "hg");
        }
        cmdAppend("--bundle", this.bundleFile.getPath());
        HgInputStream stream = launchStream(src);
        Bundle bundle = new Bundle(getRepository().getBaseRepository(), this.bundleFile);
        List<Changeset> changesets = Changeset.readListFromStream(bundle.getOverlayRepository(), stream);
        if (changesets.isEmpty()) {
            bundle.close();
            return null;
View Full Code Here

     *            With no files, all changesets are considered.
     * @return the log as a list of changesets
     * @throws IOException
     */
    public List<Changeset> execute(String... files) throws IOException {
        HgInputStream stream = launchStream(files);
        return Changeset.readListFromStream(getRepository(), stream);
    }
View Full Code Here

     *
     * @return List we status of merge files
     * @throws IOException
     */
    public List<ResolveStatusLine> list() throws IOException {
        HgInputStream stream = launchStream("--list");
        List<ResolveStatusLine> result = Lists.newArrayList();
        while (stream.peek() != -1) {
            result.add(ResolveStatusLine.fromStream(stream));
        }
        return result;
    }
View Full Code Here

                                    "serve", "--port", "0", "-d", "--pid-file",
                                    pidFile.toString(), "-R",
                                    repo.getDirectory().toString() },
                            additionalConfig, String.class));

            HgInputStream in = new HgInputStream(process.getInputStream(),
                    repo.newDecoder());

            Assert.assertTrue(in.find("(bound to *:".getBytes()));
            final int port = in.readDecimal().intValue();
            in.close();

            return new ServeState() {

                public int getPort() {
                    return port;
                }

                public void stop() {
                    BufferedReader in = null;;
                    try {
                        // probably already dead:
                        process.destroy();

                        in = new BufferedReader(new InputStreamReader(new FileInputStream(pidFile)));
                        killProcess(Integer.parseInt(in.readLine()));

                    } catch (Exception e) {
                        throw Utils.asRuntime(e);
                    } finally {
                        try {
                            in.close();
                        } catch (IOException e) {
                            throw Utils.asRuntime(e);
                        }
                    }
                }};
View Full Code Here

     *
     * @return all bookmarks
     */
    public List<Bookmark> list() {
        Repository repo = getRepository();
        HgInputStream stream = launchStream();
        try {
            if (stream.match(NO_BOOKMARKS)) {
                stream.consumeAll();
                return Collections.emptyList();
            }
            List<Bookmark> result = Lists.newArrayList();
            while (stream.peek() != -1) {
                stream.mustMatch(' ');
                boolean active = stream.read() == '*';
                stream.mustMatch(' ');
                String name = stream.textUpTo(':');
                name = name.substring(0, name.lastIndexOf(' ')).trim();
                String node = stream.textUpTo('\n');
                Bookmark bookmark = new Bookmark(repo.changeset(node), name, active);
                result.add(bookmark);
            }
            return result;
        } catch (IOException e) {
View Full Code Here

     *            the changeset to graft
     */
    public GraftContext execute(Changeset changeset) {
        Repository repo = getRepository();
        repo.lock();
        HgInputStream stream = launchStream(changeset.getNode());
        try {
            if (stream.match("grafting revision ".getBytes())) {
                int rev = stream.revisionUpTo('\n');
                GraftContext ctx = new GraftContext(this, rev);
                if (!stream.isEof()) {
                    ctx.processStream(stream, true);
                }
                stream.consumeAll();
                boolean flagOrKeepDeleteConflicts = !ctx.getFlagConflicts().isEmpty()
                        || !ctx.getKeepDeleteConflicts().isEmpty();
                if (getReturnCode() != 0 && this.hasConflicts || flagOrKeepDeleteConflicts) {
                    if (flagOrKeepDeleteConflicts && ctx.getMergeConflicts().isEmpty()) {
                        // graft has actually made a new changeset,
View Full Code Here

TOP

Related Classes of com.aragost.javahg.internals.HgInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.