Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.Transaction


    assertTrue(f1.exists());
    assertFalse(f2.exists());
    assertFalse(f3.exists());
    //
    // transaction commit
    Transaction tr1 = f.create(ctx);
    File tf1 = tr1.prepare(f1);
    RepoUtils.modifyFileAppend(tf1, "2");
    tr1.done(tf1);
    File tf2 = tr1.prepare(f2);
    errorCollector.assertTrue(tf2.exists());
    RepoUtils.modifyFileAppend(tf2, "A");
    tr1.done(tf2);
    tr1.commit();
    errorCollector.assertTrue(f1.isFile());
    errorCollector.assertTrue(f2.isFile());
    errorCollector.assertEquals("12", read(f1));
    errorCollector.assertEquals("A", read(f2));
    //
    // transaction rollback
    assertFalse(f3.exists());
    Transaction tr2 = f.create(ctx);
    tf1 = tr2.prepare(f1);
    RepoUtils.modifyFileAppend(tf1, "3");
    tr2.done(tf1);
    errorCollector.assertEquals("123", read(tf1));
    tf2 = tr2.prepare(f2);
    RepoUtils.modifyFileAppend(tf2, "B");
    tr2.done(tf2);
    errorCollector.assertEquals("AB", read(tf2));
    File tf3 = tr2.prepare(f3);
    errorCollector.assertTrue(tf3.exists());
    RepoUtils.modifyFileAppend(tf3, "!");
    tr2.done(tf3);
    errorCollector.assertEquals("!", read(tf3));
    tr2.rollback();
    errorCollector.assertTrue(f1.isFile());
    errorCollector.assertTrue(f2.isFile());
    errorCollector.assertFalse(f3.isFile());
    errorCollector.assertEquals("12", read(f1));
    errorCollector.assertEquals("A", read(f2));
View Full Code Here


        dirstateBuilder.recordRemoved(p);
        progress.worked(1);
        cancellation.checkCancelled();
      }
      Transaction.Factory trFactory = implRepo.getTransactionFactory();
      Transaction tr = trFactory.create(repo);
      try {
        dirstateBuilder.serialize(tr);
        tr.commit();
      } catch (RuntimeException ex) {
        tr.rollback();
        throw ex;
      } catch (HgException ex) {
        tr.rollback();
        throw ex;
      }
      progress.worked(1);
      progress.done();
    } catch (HgRuntimeException ex) {
View Full Code Here

        worker.checkFailed();
        progress.worked(1);
        cancellation.checkCancelled();
      }
      Transaction.Factory trFactory = implRepo.getTransactionFactory();
      Transaction tr = trFactory.create(repo);
      try {
        // TODO same code in HgAddRemoveCommand and similar in HgCommitCommand
        dirstateBuilder.serialize(tr);
        tr.commit();
      } catch (RuntimeException ex) {
        tr.rollback();
        throw ex;
      } catch (HgException ex) {
        tr.rollback();
        throw ex;
      }
      progress.worked(1);
      progress.done();
    } catch (HgRuntimeException ex) {
View Full Code Here

TOP

Related Classes of org.tmatesoft.hg.internal.Transaction

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.