Mercurial > hg4j
annotate src/org/tmatesoft/hg/core/HgPushCommand.java @ 653:629a7370554c
Tests for recent changes in HgParentChildMap and RepositoryComparator (outgoing to respect drafts and Issue 47)
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 03 Jul 2013 14:38:30 +0200 |
parents | cd77bf51b562 |
children | 12a4f60ea972 |
rev | line source |
---|---|
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013 TMate Software Ltd |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.core; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import java.io.File; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import java.io.IOException; |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
21 import java.util.ArrayList; |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 import java.util.List; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import org.tmatesoft.hg.internal.BundleGenerator; |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
25 import org.tmatesoft.hg.internal.Internals; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
26 import org.tmatesoft.hg.internal.PhasesHelper; |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 import org.tmatesoft.hg.internal.RepositoryComparator; |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
28 import org.tmatesoft.hg.internal.RevisionSet; |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
29 import org.tmatesoft.hg.repo.HgBookmarks; |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 import org.tmatesoft.hg.repo.HgBundle; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 import org.tmatesoft.hg.repo.HgChangelog; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 import org.tmatesoft.hg.repo.HgInternals; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 import org.tmatesoft.hg.repo.HgInvalidStateException; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 import org.tmatesoft.hg.repo.HgLookup; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 import org.tmatesoft.hg.repo.HgParentChildMap; |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
36 import org.tmatesoft.hg.repo.HgPhase; |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 import org.tmatesoft.hg.repo.HgRemoteRepository; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 import org.tmatesoft.hg.repo.HgRepository; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 import org.tmatesoft.hg.repo.HgRuntimeException; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 import org.tmatesoft.hg.util.CancelledException; |
653
629a7370554c
Tests for recent changes in HgParentChildMap and RepositoryComparator (outgoing to respect drafts and Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
652
diff
changeset
|
41 import org.tmatesoft.hg.util.LogFacility.Severity; |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
42 import org.tmatesoft.hg.util.Outcome; |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
43 import org.tmatesoft.hg.util.Pair; |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 import org.tmatesoft.hg.util.ProgressSupport; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 /** |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 * |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 * @author Artem Tikhomirov |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 * @author TMate Software Ltd. |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 */ |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 public class HgPushCommand extends HgAbstractCommand<HgPushCommand> { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 private final HgRepository repo; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 private HgRemoteRepository remoteRepo; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 public HgPushCommand(HgRepository hgRepo) { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 repo = hgRepo; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 } |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 public HgPushCommand destination(HgRemoteRepository hgRemote) { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
61 remoteRepo = hgRemote; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
62 return this; |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 } |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 public void execute() throws HgRemoteConnectionException, HgIOException, CancelledException, HgLibraryFailureException { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 final ProgressSupport progress = getProgressSupport(null); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
67 try { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
68 progress.start(100); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
69 // |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 // find out missing |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
71 // TODO refactor same code in HgOutgoingCommand #getComparator and #getParentHelper |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
72 final HgChangelog clog = repo.getChangelog(); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
73 final HgParentChildMap<HgChangelog> parentHelper = new HgParentChildMap<HgChangelog>(clog); |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
74 parentHelper.init(); |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
75 final Internals implRepo = HgInternals.getImplementationRepo(repo); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
76 final PhasesHelper phaseHelper = new PhasesHelper(implRepo, parentHelper); |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 final RepositoryComparator comparator = new RepositoryComparator(parentHelper, remoteRepo); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
78 comparator.compare(new ProgressSupport.Sub(progress, 50), getCancelSupport(null, true)); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
79 List<Nodeid> l = comparator.getLocalOnlyRevisions(); |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
80 final RevisionSet outgoing; |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
81 if (phaseHelper.isCapableOfPhases() && phaseHelper.withSecretRoots()) { |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
82 RevisionSet secret = phaseHelper.allSecret(); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
83 outgoing = new RevisionSet(l).subtract(secret); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
84 } else { |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
85 outgoing = new RevisionSet(l); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
86 } |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 // |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
88 // prepare bundle |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
89 BundleGenerator bg = new BundleGenerator(implRepo); |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
90 File bundleFile = bg.create(outgoing.asList()); |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
91 progress.worked(20); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
92 HgBundle b = new HgLookup(repo.getSessionContext()).loadBundle(bundleFile); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
93 // |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 // send changes |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
95 remoteRepo.unbundle(b, comparator.getRemoteHeads()); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
96 progress.worked(20); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
97 // |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
98 // update phase information |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
99 if (phaseHelper.isCapableOfPhases()) { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
100 RevisionSet presentSecret = phaseHelper.allSecret(); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
101 RevisionSet presentDraft = phaseHelper.allDraft(); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
102 RevisionSet secretLeft, draftLeft; |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
103 HgRemoteRepository.Phases remotePhases = remoteRepo.getPhases(); |
652
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
104 RevisionSet remoteDrafts = knownRemoteDrafts(remotePhases, parentHelper, outgoing, presentSecret); |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
105 if (remotePhases.isPublishingServer()) { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
106 // although it's unlikely outgoing would affect secret changesets, |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
107 // it doesn't hurt to check secret roots along with draft ones |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
108 secretLeft = presentSecret.subtract(outgoing); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
109 draftLeft = presentDraft.subtract(outgoing); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
110 } else { |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
111 // shall merge local and remote phase states |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
112 // revisions that cease to be secret (gonna become Public), e.g. someone else pushed them |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
113 RevisionSet secretGone = presentSecret.intersect(remoteDrafts); |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
114 // parents of those remote drafts are public, mark them as public locally, too |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
115 RevisionSet remotePublic = presentSecret.ancestors(secretGone, parentHelper); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
116 secretLeft = presentSecret.subtract(secretGone).subtract(remotePublic); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
117 /* |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
118 * Revisions grow from left to right (parents to the left, children to the right) |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
119 * |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
120 * I: Set of local is subset of remote |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
121 * |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
122 * local draft |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
123 * --o---r---o---l---o-- |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
124 * remote draft |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
125 * |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
126 * Remote draft roots shall be updated |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
127 * |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
128 * |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
129 * II: Set of local is superset of remote |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
130 * |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
131 * local draft |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
132 * --o---l---o---r---o-- |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
133 * remote draft |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
134 * |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
135 * Local draft roots shall be updated |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
136 */ |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
137 RevisionSet sharedDraft = presentDraft.intersect(remoteDrafts); // (I: ~presentDraft; II: ~remoteDraft |
652
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
138 // XXX do I really need sharedDrafts here? why not ancestors(remoteDrafts)? |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
139 RevisionSet localDraftRemotePublic = presentDraft.ancestors(sharedDraft, parentHelper); // I: 0; II: those treated public on remote |
652
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
140 // remoteDrafts are local revisions known as draft@remote |
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
141 // remoteDraftsLocalPublic - revisions that would cease to be listed as draft on remote |
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
142 RevisionSet remoteDraftsLocalPublic = remoteDrafts.ancestors(sharedDraft, parentHelper); |
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
143 RevisionSet remoteDraftsLeft = remoteDrafts.subtract(remoteDraftsLocalPublic); |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
144 // forget those deemed public by remote (drafts shared by both remote and local are ok to stay) |
652
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
145 RevisionSet combinedDraft = presentDraft.union(remoteDraftsLeft); |
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
146 draftLeft = combinedDraft.subtract(localDraftRemotePublic); |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
147 } |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
148 final RevisionSet newDraftRoots = draftLeft.roots(parentHelper); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
149 final RevisionSet newSecretRoots = secretLeft.roots(parentHelper); |
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
150 phaseHelper.updateRoots(newDraftRoots.asList(), newSecretRoots.asList()); |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
151 // |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
152 // if there's a remote draft root that points to revision we know is public |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
153 RevisionSet remoteDraftsLocalPublic = remoteDrafts.subtract(draftLeft).subtract(secretLeft); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
154 if (!remoteDraftsLocalPublic.isEmpty()) { |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
155 // foreach remoteDraftsLocallyPublic.heads() do push Draft->Public |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
156 for (Nodeid n : remoteDraftsLocalPublic.heads(parentHelper)) { |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
157 try { |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
158 Outcome upo = remoteRepo.updatePhase(HgPhase.Draft, HgPhase.Public, n); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
159 if (!upo.isOk()) { |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
160 implRepo.getLog().dump(getClass(), Severity.Info, "Failed to update remote phase, reason: %s", upo.getMessage()); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
161 } |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
162 } catch (HgRemoteConnectionException ex) { |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
163 implRepo.getLog().dump(getClass(), Severity.Error, ex, String.format("Failed to update phase of %s", n.shortNotation())); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
164 } |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
165 } |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
166 } |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
167 } |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
168 progress.worked(5); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
169 // |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
170 // update bookmark information |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
171 HgBookmarks localBookmarks = repo.getBookmarks(); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
172 if (!localBookmarks.getAllBookmarks().isEmpty()) { |
649
e79cf9a8130b
Push: phase4 - update local and remote phase information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
646
diff
changeset
|
173 for (Pair<String,Nodeid> bm : remoteRepo.getBookmarks()) { |
646
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
174 Nodeid localRevision = localBookmarks.getRevision(bm.first()); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
175 if (localRevision == null || !parentHelper.knownNode(bm.second())) { |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
176 continue; |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
177 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
178 // we know both localRevision and revision of remote bookmark, |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
179 // need to make sure we don't push older revision than it's at the server |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
180 if (parentHelper.isChild(bm.second(), localRevision)) { |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
181 remoteRepo.updateBookmark(bm.first(), bm.second(), localRevision); |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
182 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
183 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
184 } |
3b7d51ed4c65
Push: phase3 - update matching remote bookmarks
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
645
diff
changeset
|
185 // XXX WTF is obsolete in namespaces key?? |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
186 progress.worked(5); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
187 } catch (IOException ex) { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
188 throw new HgIOException(ex.getMessage(), null); // XXX not a nice idea to throw IOException from BundleGenerator#create |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
189 } catch (HgRepositoryNotFoundException ex) { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
190 final HgInvalidStateException e = new HgInvalidStateException("Failed to load a just-created bundle"); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
191 e.initCause(ex); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
192 throw new HgLibraryFailureException(e); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
193 } catch (HgRuntimeException ex) { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
194 throw new HgLibraryFailureException(ex); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
195 } finally { |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
196 progress.done(); |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
197 } |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
198 } |
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
199 |
652
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
200 private RevisionSet knownRemoteDrafts(HgRemoteRepository.Phases remotePhases, HgParentChildMap<HgChangelog> parentHelper, RevisionSet outgoing, RevisionSet localSecret) { |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
201 ArrayList<Nodeid> knownRemoteDraftRoots = new ArrayList<Nodeid>(); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
202 for (Nodeid rdr : remotePhases.draftRoots()) { |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
203 if (parentHelper.knownNode(rdr)) { |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
204 knownRemoteDraftRoots.add(rdr); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
205 } |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
206 } |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
207 // knownRemoteDraftRoots + childrenOf(knownRemoteDraftRoots) is everything remote may treat as Draft |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
208 RevisionSet remoteDrafts = new RevisionSet(knownRemoteDraftRoots); |
652
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
209 RevisionSet localChildren = remoteDrafts.children(parentHelper); |
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
210 // we didn't send any local secret revision |
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
211 localChildren = localChildren.subtract(localSecret); |
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
212 // draft roots are among remote drafts |
cd77bf51b562
Push: tests. Commit respects phases.new-commit setting. Fix outgoing when changes are not children of common (Issue 47)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
650
diff
changeset
|
213 remoteDrafts = remoteDrafts.union(localChildren); |
650
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
214 // 1) outgoing.children gives all local revisions accessible from outgoing. |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
215 // 2) outgoing.roots.children is equivalent with smaller intermediate set, the way we build |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
216 // childrenOf doesn't really benefits from that. |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
217 RevisionSet localChildrenNotSent = outgoing.children(parentHelper).subtract(outgoing); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
218 // remote shall know only what we've sent, subtract revisions we didn't actually sent |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
219 remoteDrafts = remoteDrafts.subtract(localChildrenNotSent); |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
220 return remoteDrafts; |
3b275cc2d2aa
Push: phase4 - settle local and remote phases, push updated phases regardless of server publishing state, do not push secret changesets
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
649
diff
changeset
|
221 } |
645
14dac192aa26
Push: phase2 - upload bundle with changes to remote server
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
222 } |