annotate test/org/tmatesoft/hg/test/TestRepositoryLock.java @ 631:8a5cdcb27b8f

AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 30 May 2013 15:24:17 +0200
parents 5e0313485eef
children
rev   line source
615
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2013 TMate Software Ltd
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.test;
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19 import java.io.File;
631
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
20 import java.util.HashMap;
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
21 import java.util.Map;
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
22 import java.util.concurrent.CountDownLatch;
615
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 import org.junit.Assert;
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 import org.junit.Test;
631
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
26 import org.tmatesoft.hg.core.HgStatusCommand;
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
27 import org.tmatesoft.hg.internal.BasicSessionContext;
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
28 import org.tmatesoft.hg.internal.DataAccessProvider;
615
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 import org.tmatesoft.hg.repo.HgLookup;
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 import org.tmatesoft.hg.repo.HgRepository;
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31 import org.tmatesoft.hg.repo.HgRepositoryLock;
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 /**
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 *
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 * @author Artem Tikhomirov
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 * @author TMate Software Ltd.
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 */
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 public class TestRepositoryLock {
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40 @Test
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 public void testWorkingDirLock() throws Exception {
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 File repoLoc = RepoUtils.cloneRepoToTempLocation("log-1", "test-wc-lock", false);
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43 // turn off lock timeout, to fail fast
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44 File hgrc = new File(repoLoc, ".hg/hgrc");
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45 RepoUtils.createFile(hgrc, "[ui]\ntimeout=0\n"); // or 1
616
5e0313485eef encode directories as demanded by fncache format
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 615
diff changeset
46 final OutputParser.Stub p = new OutputParser.Stub();
5e0313485eef encode directories as demanded by fncache format
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 615
diff changeset
47 ExecHelper eh = new ExecHelper(p, repoLoc);
615
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 HgRepository hgRepo = new HgLookup().detect(repoLoc);
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 final HgRepositoryLock wdLock = hgRepo.getWorkingDirLock();
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 try {
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
51 wdLock.acquire();
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
52 eh.run("hg", "tag", "tag-aaa");
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53 Assert.assertNotSame(0 /*returns 0 on success*/, eh.getExitValue());
616
5e0313485eef encode directories as demanded by fncache format
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 615
diff changeset
54 Assert.assertTrue(p.result().toString().contains("abort"));
615
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
55 } finally {
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
56 wdLock.release();
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
57 }
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
58 }
631
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
59
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
60 public static void main(String[] args) throws Exception {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
61 Map<String, Object> po = new HashMap<String, Object>();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
62 po.put(DataAccessProvider.CFG_PROPERTY_MAPIO_LIMIT, 0);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
63 final HgLookup hgLookup = new HgLookup(new BasicSessionContext(po , null));
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
64 final File rebaseFromRepoLoc = RepoUtils.cloneRepoToTempLocation(new File("/temp/hg/junit-test-repos/test-annotate"), "repo-lock-remote", false, true);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
65 final File rebaseToRepoLoc = RepoUtils.cloneRepoToTempLocation(rebaseFromRepoLoc, "repo-lock-local", false, true);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
66 final File remoteChanges = new File(rebaseFromRepoLoc, "file1");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
67 //
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
68 // create commit in the "local" repository that will be rebased on top of changes
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
69 // pulled from "remote repository"
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
70 File localChanges = new File(rebaseToRepoLoc, "file-new");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
71 if (localChanges.exists()) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
72 RepoUtils.modifyFileAppend(localChanges, "whatever");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
73 } else {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
74 RepoUtils.createFile(localChanges, "whatever");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
75 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
76 commit(rebaseToRepoLoc, "local change");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
77 //
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
78 final int rebaseRevisionCount = 70;
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
79 final CountDownLatch latch = new CountDownLatch(2);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
80 Runnable r1 = new Runnable() {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
81 public void run() {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
82 for (int i = 0; i < rebaseRevisionCount; i++) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
83 commitPullRebaseNative(rebaseFromRepoLoc, rebaseToRepoLoc, remoteChanges);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
84 sleep(500, 1000);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
85 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
86 latch.countDown();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
87 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
88 };
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
89 Runnable r2 = new Runnable() {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
90 public void run() {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
91 for (int i = 0; i < 100; i++) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
92 readWithHg4J(hgLookup, rebaseToRepoLoc);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
93 sleep(800, 400);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
94 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
95 latch.countDown();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
96 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
97 };
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
98 new Thread(r1, "pull-rebase-thread").start();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
99 new Thread(r2, "hg4j-read-thread").start();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
100 latch.await();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
101 System.out.println("DONE.");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
102 // now `hg log` in rebaseToRepoLoc shall show
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
103 // all rebaseRevisionCount revisions from rebaseFromRepoLoc + 1 more, "local change", on top of them
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
104 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
105
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
106 private static int count = 0;
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
107
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
108 private static void commitPullRebaseNative(final File rebaseFromRepoLoc, final File rebaseToRepoLoc, final File rebaseFromChanges) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
109 try {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
110 OutputParser.Stub p = new OutputParser.Stub();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
111 final ExecHelper eh = new ExecHelper(p, rebaseToRepoLoc);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
112 RepoUtils.modifyFileAppend(rebaseFromChanges, "Change #" + count++);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
113 commit(rebaseFromRepoLoc, "remote change");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
114 p.reset();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
115 eh.run("hg", "--traceback", "pull", rebaseFromRepoLoc.toString());
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
116 if (eh.getExitValue() != 0) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
117 System.out.println(p.result());
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
118 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
119 Assert.assertEquals(0, eh.getExitValue());
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
120 p.reset();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
121 eh.run("hg", "--traceback", "--config", "extensions.hgext.rebase=", "rebase");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
122 if (eh.getExitValue() != 0) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
123 System.out.println(p.result());
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
124 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
125 System.out.print("X");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
126 Assert.assertEquals(0, eh.getExitValue());
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
127 } catch (RuntimeException ex) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
128 throw ex;
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
129 } catch (Exception ex) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
130 ex.printStackTrace();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
131 throw new RuntimeException(null, ex);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
132 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
133 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
134
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
135 private static void readWithHg4J(final HgLookup hgLookup, final File repoLoc) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
136 try {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
137 System.out.print("(");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
138 final long start = System.nanoTime();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
139 HgRepository hgRepo = hgLookup.detect(repoLoc);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
140 final HgRepositoryLock wcLock = hgRepo.getWorkingDirLock();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
141 final HgRepositoryLock storeLock = hgRepo.getStoreLock();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
142 wcLock.acquire();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
143 System.out.print(".");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
144 storeLock.acquire();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
145 System.out.print(".");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
146 try {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
147 new HgStatusCommand(hgRepo).execute(new TestStatus.StatusCollector());
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
148 System.out.printf("%d ms)\n", (System.nanoTime() - start) / 1000000);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
149 } finally {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
150 storeLock.release();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
151 wcLock.release();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
152 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
153 } catch (RuntimeException ex) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
154 throw ex;
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
155 } catch (Exception ex) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
156 ex.printStackTrace();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
157 throw new RuntimeException(null, ex);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
158 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
159 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
160
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
161 private static void commit(File repoLoc, String message) throws Exception {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
162 OutputParser.Stub p = new OutputParser.Stub();
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
163 final ExecHelper eh = new ExecHelper(p, repoLoc);
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
164 eh.run("hg", "commit", "--addremove", "-m", "\"" + message + "\"");
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
165 if (eh.getExitValue() != 0) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
166 System.out.println(p.result());
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
167 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
168 Assert.assertEquals(0, eh.getExitValue());
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
169 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
170
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
171 private static void sleep(int msBase, int msDelta) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
172 try {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
173 Thread.sleep(msBase + Math.round(Math.random() * msDelta));
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
174 } catch (InterruptedException ex) {
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
175 // IGNORE
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
176 }
8a5cdcb27b8f AIOOBE in HgManifest.RevisionMapper. Provide more details about exception context. Create lock file atomically. Test concurrent pull-rebase and read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 616
diff changeset
177 }
615
84104448a0bf Test for repository locks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
178 }