annotate src/org/tmatesoft/hg/core/HgAddRemoveCommand.java @ 709:497e697636fc

Report merged lines as changed block if possible, not as a sequence of added/deleted blocks. To facilitate access to merge parent lines AddBlock got mergeLineAt() method that reports index of the line in the second parent (if any), while insertedAt() has been changed to report index in the first parent always
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 21 Aug 2013 16:23:27 +0200
parents b4242b7e7dfe
children
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
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
21 import org.tmatesoft.hg.internal.DirstateBuilder;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 import org.tmatesoft.hg.internal.DirstateReader;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 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
24 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
25 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
26 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
27 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
28 import org.tmatesoft.hg.repo.HgRuntimeException;
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
29 import org.tmatesoft.hg.util.CancelSupport;
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
30 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
31 import org.tmatesoft.hg.util.Path;
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
32 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
33
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 * Schedule files for addition and removal
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
36 * 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
37 *
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 * @since 1.1
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
39 * @author Artem Tikhomirov
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
40 * @author TMate Software Ltd.
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
41 */
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 public class HgAddRemoveCommand extends HgAbstractCommand<HgAddRemoveCommand> {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
44 private final HgRepository repo;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45 private final LinkedHashSet<Path> toAdd, toRemove;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47 public HgAddRemoveCommand(HgRepository hgRepo) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 repo = hgRepo;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 toAdd = new LinkedHashSet<Path>();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 toRemove = new LinkedHashSet<Path>();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
51 }
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 * 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
55 *
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
56 * @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
57 * @return <code>this</code> for convenience
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
58 */
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
59 public HgAddRemoveCommand add(Path... paths) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60 if (paths == null) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 throw new IllegalArgumentException();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
62 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 for (Path p : paths) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
64 toRemove.remove(p);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
65 toAdd.add(p);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
66 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
67 return this;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
68 }
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 * 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
72 *
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
73 * @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
74 * @return <code>this</code> for convenience
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
75 */
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
76 public HgAddRemoveCommand remove(Path... paths) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
77 if (paths == null) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
78 throw new IllegalArgumentException();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80 for (Path p : paths) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
81 toAdd.remove(p);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
82 toRemove.add(p);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84 return this;
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
85 }
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 public HgAddRemoveCommand addAll() {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88 throw Internals.notImplemented();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
89 }
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 public HgAddRemoveCommand forget(Path path) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
92 throw Internals.notImplemented();
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
93 }
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 * Perform scheduled addition/removal
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
97 *
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
98 * @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
99 * @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
100 * @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
101 */
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
102 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
103 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
104 wdLock.acquire();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
105 try {
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
106 final ProgressSupport progress = getProgressSupport(null);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
107 final CancelSupport cancellation = getCancelSupport(null, true);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
108 cancellation.checkCancelled();
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
109 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
110 Internals implRepo = Internals.getInstance(repo);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
111 final DirstateBuilder dirstateBuilder = new DirstateBuilder(implRepo);
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
112 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
113 progress.worked(1);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
114 cancellation.checkCancelled();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
115 for (Path p : toAdd) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
116 dirstateBuilder.recordAdded(p, Flags.RegularFile, -1);
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
117 progress.worked(1);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
118 cancellation.checkCancelled();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
119 }
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
120 for (Path p : toRemove) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
121 dirstateBuilder.recordRemoved(p);
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
122 progress.worked(1);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
123 cancellation.checkCancelled();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
124 }
705
b4242b7e7dfe Merge command: implement conflict resolution alternatives
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 617
diff changeset
125 Transaction.Factory trFactory = implRepo.getTransactionFactory();
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 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
127 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
128 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
129 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
130 } 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
131 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
132 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
133 } 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
134 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
135 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
136 }
581
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
137 progress.worked(1);
0890628ed51e Progress/cancel support in new commands
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 529
diff changeset
138 progress.done();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
139 } catch (HgRuntimeException ex) {
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
140 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
141 } 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
142 wdLock.release();
529
95bdcf75e71e Command to schedule addition/removal of repository files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
143 }
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 }