Mercurial > jhg
annotate src/org/tmatesoft/hg/internal/AddRevInspector.java @ 663:46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 10 Jul 2013 16:41:49 +0200 |
parents | 4fd317a2fecf |
children | ae2d439fbed3 |
rev | line source |
---|---|
660
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013 TMate Software Ltd |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.internal; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
663
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
19 import java.io.IOException; |
660
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import java.util.HashMap; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 import java.util.Set; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 import org.tmatesoft.hg.core.HgIOException; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import org.tmatesoft.hg.core.Nodeid; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 import org.tmatesoft.hg.repo.HgBundle; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 import org.tmatesoft.hg.repo.HgBundle.GroupElement; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 import org.tmatesoft.hg.repo.HgDataFile; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 import org.tmatesoft.hg.repo.HgInvalidControlFileException; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 import org.tmatesoft.hg.repo.HgRepository; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 import org.tmatesoft.hg.repo.HgRuntimeException; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 import org.tmatesoft.hg.util.Pair; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 /** |
663
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
34 * FIXME pretty much alike HgCloneCommand.WriteDownMate, shall converge |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
35 * |
660
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 * @author Artem Tikhomirov |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 * @author TMate Software Ltd. |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 */ |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 public final class AddRevInspector implements HgBundle.Inspector { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 private final Internals repo; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 private final Transaction tr; |
663
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
42 private final FNCacheFile.Mediator fncache; |
660
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 private Set<Nodeid> added; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 private RevlogStreamWriter revlog; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 private RevMap clogRevs; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 private RevMap revlogRevs; |
663
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
47 private HgDataFile fileNode; |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
48 private boolean newFile = false; |
660
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 public AddRevInspector(Internals implRepo, Transaction transaction) { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 repo = implRepo; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 tr = transaction; |
663
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
53 fncache = new FNCacheFile.Mediator(implRepo); |
660
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 public void changelogStart() throws HgRuntimeException { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 RevlogStream rs = repo.getImplAccess().getChangelogStream(); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 revlog = new RevlogStreamWriter(repo, rs, tr); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 revlogRevs = clogRevs = new RevMap(rs); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
61 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
62 public void changelogEnd() throws HgRuntimeException { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 revlog = null; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 revlogRevs = null; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 added = clogRevs.added(); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
67 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
68 public void manifestStart() throws HgRuntimeException { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
69 RevlogStream rs = repo.getImplAccess().getManifestStream(); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 revlog = new RevlogStreamWriter(repo, rs, tr); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
71 revlogRevs = new RevMap(rs); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
72 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
74 public void manifestEnd() throws HgRuntimeException { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 revlog = null; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 revlogRevs = null; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
78 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
79 public void fileStart(String name) throws HgRuntimeException { |
663
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
80 fileNode = repo.getRepo().getFileNode(name); |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
81 newFile = !fileNode.exists(); |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
82 RevlogStream rs = repo.getImplAccess().getStream(fileNode); |
660
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
83 revlog = new RevlogStreamWriter(repo, rs, tr); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
84 revlogRevs = new RevMap(rs); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 public void fileEnd(String name) throws HgRuntimeException { |
663
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
88 if (newFile) { |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
89 fncache.registerNew(fileNode.getPath(), revlog.getRevlogStream()); |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
90 } |
660
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
91 revlog = null; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
92 revlogRevs = null; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
93 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
95 public boolean element(GroupElement ge) throws HgRuntimeException { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
96 assert clogRevs != null; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
97 assert revlogRevs != null; |
663
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
98 if (revlog.getRevlogStream().findRevisionIndex(ge.node()) != HgRepository.BAD_REVISION) { |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
99 // HgRemoteRepository.getChanges(common) builds a bundle that includes these common |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
100 // revisions. Hence, shall not add these common (i.e. known locally) revisions |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
101 // once again |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
102 return true; |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
103 } |
660
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
104 try { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
105 Pair<Integer, Nodeid> newRev = revlog.addPatchRevision(ge, clogRevs, revlogRevs); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
106 revlogRevs.update(newRev.first(), newRev.second()); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 return true; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
108 } catch (HgIOException ex) { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
109 throw new HgInvalidControlFileException(ex, true); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
110 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
113 public RevisionSet addedChangesets() { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 return new RevisionSet(added); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
115 } |
663
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
116 |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
117 public void done() throws IOException { |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
118 fncache.complete(); |
46b56864b483
Pull: phase2 - update phases from remote, fncache with added files. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
660
diff
changeset
|
119 } |
660
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
120 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
121 private static class RevMap implements RevlogStreamWriter.RevisionToIndexMap { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
122 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
123 private final RevlogStream revlog; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 private HashMap<Nodeid, Integer> added = new HashMap<Nodeid, Integer>(); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 public RevMap(RevlogStream revlogStream) { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
127 revlog = revlogStream; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
129 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
130 public int revisionIndex(Nodeid revision) { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
131 Integer a = added.get(revision); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
132 if (a != null) { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 return a; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 int f = revlog.findRevisionIndex(revision); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 return f == HgRepository.BAD_REVISION ? HgRepository.NO_REVISION : f; |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
137 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
138 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
139 public void update(Integer revIndex, Nodeid rev) { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
140 added.put(rev, revIndex); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
141 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
142 |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
143 Set<Nodeid> added() { |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
144 return added.keySet(); |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
145 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
146 } |
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
147 } |