annotate src/org/tmatesoft/hg/core/HgAddRemoveCommand.java @ 626:5afc7eedb3dd v1.1rc1

@since, TODOs. Tests: add 1 sec to deal with fs timestamp granularity on linux
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 21 May 2013 19:30:12 +0200
parents 65c01508f002
children b4242b7e7dfe
rev   line source
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2013 TMate Software Ltd
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15 * contact TMate Software at support@hg4j.com
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.core;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
19 import java.util.LinkedHashSet;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20
617
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
21 import org.tmatesoft.hg.internal.COWTransaction;
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 import org.tmatesoft.hg.internal.DirstateBuilder;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 import org.tmatesoft.hg.internal.DirstateReader;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 import org.tmatesoft.hg.internal.Internals;
617
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
25 import org.tmatesoft.hg.internal.Transaction;
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 import org.tmatesoft.hg.repo.HgManifest.Flags;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 import org.tmatesoft.hg.repo.HgRepository;
617
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
28 import org.tmatesoft.hg.repo.HgRepositoryLock;
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 import org.tmatesoft.hg.repo.HgRuntimeException;
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
30 import org.tmatesoft.hg.util.CancelSupport;
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
31 import org.tmatesoft.hg.util.CancelledException;
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
32 import org.tmatesoft.hg.util.Path;
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
33 import org.tmatesoft.hg.util.ProgressSupport;
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
35 /**
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 * Schedule files for addition and removal
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 * XXX and, perhaps, forget() functionality shall be here as well?
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 *
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 * @since 1.1
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40 * @author Artem Tikhomirov
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 * @author TMate Software Ltd.
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 */
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43 public class HgAddRemoveCommand extends HgAbstractCommand<HgAddRemoveCommand> {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45 private final HgRepository repo;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46 private final LinkedHashSet<Path> toAdd, toRemove;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 public HgAddRemoveCommand(HgRepository hgRepo) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 repo = hgRepo;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 toAdd = new LinkedHashSet<Path>();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
51 toRemove = new LinkedHashSet<Path>();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
52 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
54 /**
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
55 * Schedule specified files to get listed in dirstate as added
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
56 *
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
57 * @param paths files to mark as added, additive
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
58 * @return <code>this</code> for convenience
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
59 */
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60 public HgAddRemoveCommand add(Path... paths) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 if (paths == null) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
62 throw new IllegalArgumentException();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
64 for (Path p : paths) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
65 toRemove.remove(p);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
66 toAdd.add(p);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
67 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
68 return this;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
69 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
70
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
71 /**
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
72 * Schedule specified files to be marked as removed
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
73 *
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
74 * @param paths files to mark as removed, additive
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
75 * @return <code>this</code> for convenience
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
76 */
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
77 public HgAddRemoveCommand remove(Path... paths) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
78 if (paths == null) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79 throw new IllegalArgumentException();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
81 for (Path p : paths) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
82 toAdd.remove(p);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 toRemove.add(p);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
85 return this;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
86 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
87
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88 public HgAddRemoveCommand addAll() {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
89 throw Internals.notImplemented();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
90 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
91
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
92 public HgAddRemoveCommand forget(Path path) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
93 throw Internals.notImplemented();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
94 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
95
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
96 /**
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
97 * Perform scheduled addition/removal
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
98 *
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
99 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state
617
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
100 * @throws HgRepositoryLockException if failed to lock the repo for modifications
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
101 * @throws CancelledException if execution of the command was cancelled
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
102 */
617
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
103 public void execute() throws HgException, HgRepositoryLockException, CancelledException {
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
104 final HgRepositoryLock wdLock = repo.getWorkingDirLock();
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
105 wdLock.acquire();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
106 try {
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
107 final ProgressSupport progress = getProgressSupport(null);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
108 final CancelSupport cancellation = getCancelSupport(null, true);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
109 cancellation.checkCancelled();
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
110 progress.start(2 + toAdd.size() + toRemove.size());
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
111 Internals implRepo = Internals.getInstance(repo);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
112 final DirstateBuilder dirstateBuilder = new DirstateBuilder(implRepo);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
113 dirstateBuilder.fillFrom(new DirstateReader(implRepo, new Path.SimpleSource()));
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
114 progress.worked(1);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
115 cancellation.checkCancelled();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
116 for (Path p : toAdd) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
117 dirstateBuilder.recordAdded(p, Flags.RegularFile, -1);
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
118 progress.worked(1);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
119 cancellation.checkCancelled();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
120 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
121 for (Path p : toRemove) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
122 dirstateBuilder.recordRemoved(p);
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
123 progress.worked(1);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
124 cancellation.checkCancelled();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
125 }
617
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
126 Transaction.Factory trFactory = new COWTransaction.Factory();
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
127 Transaction tr = trFactory.create(repo);
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
128 try {
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
129 dirstateBuilder.serialize(tr);
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
130 tr.commit();
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
131 } catch (RuntimeException ex) {
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
132 tr.rollback();
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
133 throw ex;
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
134 } catch (HgException ex) {
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
135 tr.rollback();
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
136 throw ex;
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
137 }
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
138 progress.worked(1);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
139 progress.done();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
140 } catch (HgRuntimeException ex) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
141 throw new HgLibraryFailureException(ex);
617
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
142 } finally {
65c01508f002 Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 613
diff changeset
143 wdLock.release();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
144 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
145 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
146 }