Mercurial > jhg
annotate src/org/tmatesoft/hg/internal/AddRevInspector.java @ 660:4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Tue, 09 Jul 2013 21:46:45 +0200 | 
| parents | |
| children | 46b56864b483 | 
| 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 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
19 import java.util.HashMap; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
20 import java.util.Set; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
21 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
22 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
 | 
23 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
 | 
24 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
 | 
25 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
 | 
26 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
 | 
27 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
 | 
28 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
 | 
29 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
 | 
30 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
 | 
31 | 
| 
 
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 * @author Artem Tikhomirov | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
34 * @author TMate Software Ltd. | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
35 */ | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
36 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
 | 
37 private final Internals repo; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
38 private final Transaction tr; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
39 private Set<Nodeid> added; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
40 private RevlogStreamWriter revlog; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
41 private RevMap clogRevs; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
42 private RevMap revlogRevs; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
43 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
44 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
 | 
45 repo = implRepo; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
46 tr = transaction; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
47 } | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
48 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
49 public void changelogStart() throws HgRuntimeException { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
50 // TODO Auto-generated method stub | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
51 RevlogStream rs = repo.getImplAccess().getChangelogStream(); | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
52 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
 | 
53 revlogRevs = clogRevs = new RevMap(rs); | 
| 
 
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 changelogEnd() throws HgRuntimeException { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
57 revlog = null; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
58 revlogRevs = null; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
59 added = clogRevs.added(); | 
| 
 
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 manifestStart() throws HgRuntimeException { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
63 RevlogStream rs = repo.getImplAccess().getManifestStream(); | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
64 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
 | 
65 revlogRevs = new RevMap(rs); | 
| 
 
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 manifestEnd() throws HgRuntimeException { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
69 revlog = null; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
70 revlogRevs = null; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
71 } | 
| 
 
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 public void fileStart(String name) throws HgRuntimeException { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
74 HgDataFile df = repo.getRepo().getFileNode(name); | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
75 RevlogStream rs = repo.getImplAccess().getStream(df); | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
76 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
 | 
77 revlogRevs = new RevMap(rs); | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
78 // FIXME collect new files and update fncache | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
79 } | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
80 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
81 public void fileEnd(String name) throws HgRuntimeException { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
82 revlog = null; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
83 revlogRevs = null; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
84 } | 
| 
 
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 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
 | 
87 assert clogRevs != null; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
88 assert revlogRevs != null; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
89 try { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
90 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
 | 
91 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
 | 
92 return true; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
93 } catch (HgIOException ex) { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
94 throw new HgInvalidControlFileException(ex, true); | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
95 } | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
96 } | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
97 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
98 public RevisionSet addedChangesets() { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
99 return new RevisionSet(added); | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
100 } | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
101 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
102 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
 | 
103 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
104 private final RevlogStream revlog; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
105 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
 | 
106 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
107 public RevMap(RevlogStream revlogStream) { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
108 revlog = revlogStream; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
109 } | 
| 
 
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 public int revisionIndex(Nodeid revision) { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
112 Integer a = added.get(revision); | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
113 if (a != null) { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
114 return a; | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
115 } | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
116 int f = revlog.findRevisionIndex(revision); | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
117 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
 | 
118 } | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
119 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
120 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
 | 
121 added.put(rev, revIndex); | 
| 
 
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 | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
124 Set<Nodeid> added() { | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
125 return added.keySet(); | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
126 } | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
127 } | 
| 
 
4fd317a2fecf
Pull: phase1 get remote changes and add local revisions
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
128 } | 
