Mercurial > hg
annotate mercurial/treediscovery.py @ 38931:5caee9f923ae stable
hgweb: catch ParseError that's raised by revset.match()
Some queries, like the demonstrated "first(::)", fail earlier than we call
mfunc(), and that results in a "500 Internal Server Error". To prevent it,
revset.match() also needs to be in a try-except block.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 09 Aug 2018 13:04:52 +0800 |
parents | 2f5c622fcb73 |
children | e7aa113b14f7 |
rev | line source |
---|---|
11313
0bb14798cd07
discovery: fix description line
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11301
diff
changeset
|
1 # discovery.py - protocol changeset discovery functions |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
2 # |
11313
0bb14798cd07
discovery: fix description line
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11301
diff
changeset
|
3 # Copyright 2010 Matt Mackall <mpm@selenic.com> |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
4 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8210
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
7 |
25987
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
8 from __future__ import absolute_import |
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
9 |
25113
0ca8410ea345
util: drop alias for collections.deque
Martin von Zweigbergk <martinvonz@google.com>
parents:
20225
diff
changeset
|
10 import collections |
25987
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
11 |
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
12 from .i18n import _ |
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
13 from .node import ( |
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
14 nullid, |
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
15 short, |
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
16 ) |
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
17 from . import ( |
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
18 error, |
c6d049a5de43
treediscovery: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25113
diff
changeset
|
19 ) |
8109
496ae1ea4698
switch lock releasing in the core from gc to explicit
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
8108
diff
changeset
|
20 |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
21 def findcommonincoming(repo, remote, heads=None, force=False): |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
22 """Return a tuple (common, fetch, heads) used to identify the common |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
23 subset of nodes between repo and remote. |
2601
00fc88b0b256
move most of tag code to localrepository class.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2581
diff
changeset
|
24 |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
25 "common" is a list of (at least) the heads of the common subset. |
14164
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
26 "fetch" is a list of roots of the nodes that would be incoming, to be |
cb98fed52495
discovery: add new set-based discovery
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14073
diff
changeset
|
27 supplied to changegroupsubset. |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
28 "heads" is either the supplied heads, or else the remote's heads. |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
29 """ |
14073
72c84f24b420
discovery: drop findoutgoing and simplify findcommonincoming's api
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
13742
diff
changeset
|
30 |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16834
diff
changeset
|
31 knownnode = repo.changelog.hasnode |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
32 search = [] |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
33 fetch = set() |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
34 seen = set() |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
35 seenbranch = set() |
12761
11c3c77da62a
discovery: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12760
diff
changeset
|
36 base = set() |
5657
47915bf68c44
Properly check tag's existence as a local/global tag when removing it.
Osku Salerma <osku@iki.fi>
parents:
5637
diff
changeset
|
37 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
38 if not heads: |
37634
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
39 with remote.commandexecutor() as e: |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
40 heads = e.callcommand('heads', {}).result() |
343 | 41 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
42 if repo.changelog.tip() == nullid: |
12761
11c3c77da62a
discovery: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12760
diff
changeset
|
43 base.add(nullid) |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
44 if heads != [nullid]: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
45 return [nullid], [nullid], list(heads) |
14199
e3dd3dcd6059
treediscovery: fix regression when run against older repos (issue2793)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14164
diff
changeset
|
46 return [nullid], [], heads |
3826
b3b868113d24
fix encoding conversion of branch names when mq is loaded
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3803
diff
changeset
|
47 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
48 # assume we're closer to the tip than the root |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
49 # and start by examining the heads |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
50 repo.ui.status(_("searching for changes\n")) |
6121
7336aeff1a1d
automatically update the branch cache when tip changes
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
6120
diff
changeset
|
51 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
52 unknown = [] |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
53 for h in heads: |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16834
diff
changeset
|
54 if not knownnode(h): |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
55 unknown.append(h) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
56 else: |
12761
11c3c77da62a
discovery: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12760
diff
changeset
|
57 base.add(h) |
7654
816b708f23af
store all heads of a branch in the branch cache
John Mulligan <phlogistonjohn@asynchrono.us>
parents:
7644
diff
changeset
|
58 |
14199
e3dd3dcd6059
treediscovery: fix regression when run against older repos (issue2793)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14164
diff
changeset
|
59 if not unknown: |
e3dd3dcd6059
treediscovery: fix regression when run against older repos (issue2793)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14164
diff
changeset
|
60 return list(base), [], list(heads) |
e3dd3dcd6059
treediscovery: fix regression when run against older repos (issue2793)
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
14164
diff
changeset
|
61 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
62 req = set(unknown) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
63 reqcnt = 0 |
38400
2f5c622fcb73
treediscovery: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
37634
diff
changeset
|
64 progress = repo.ui.makeprogress(_('searching'), unit=_('queries')) |
3417
028fff46a4ac
Add branchtags function with cache
Matt Mackall <mpm@selenic.com>
parents:
3377
diff
changeset
|
65 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
66 # search through remote branches |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
67 # a 'branch' here is a linear segment of history, with four parts: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
68 # head, root, first parent, second parent |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
69 # (a branch always has two parents (or none) by definition) |
37634
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
70 with remote.commandexecutor() as e: |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
71 branches = e.callcommand('branches', {'nodes': unknown}).result() |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
72 |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
73 unknown = collections.deque(branches) |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
74 while unknown: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
75 r = [] |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
76 while unknown: |
16803
107a3270a24a
cleanup: use the deque type where appropriate
Bryan O'Sullivan <bryano@fb.com>
parents:
14698
diff
changeset
|
77 n = unknown.popleft() |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
78 if n[0] in seen: |
8954
e67e5b60e55f
Branch heads should not include "heads" that are ancestors of other heads.
Brendan Cully <brendan@kublai.com>
parents:
8916
diff
changeset
|
79 continue |
1806
a2c69737e65e
Automatic nesting into running transactions in the same repository.
mason@suse.com
parents:
1802
diff
changeset
|
80 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
81 repo.ui.debug("examining %s:%s\n" |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
82 % (short(n[0]), short(n[1]))) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
83 if n[0] == nullid: # found the end of the branch |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
84 pass |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
85 elif n in seenbranch: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
86 repo.ui.debug("branch already found\n") |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
87 continue |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16834
diff
changeset
|
88 elif n[1] and knownnode(n[1]): # do we know the base? |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
89 repo.ui.debug("found incomplete branch %s:%s\n" |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
90 % (short(n[0]), short(n[1]))) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
91 search.append(n[0:2]) # schedule branch range for scanning |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
92 seenbranch.add(n) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
93 else: |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
94 if n[1] not in seen and n[1] not in fetch: |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16834
diff
changeset
|
95 if knownnode(n[2]) and knownnode(n[3]): |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
96 repo.ui.debug("found new changeset %s\n" % |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
97 short(n[1])) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
98 fetch.add(n[1]) # earliest unknown |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
99 for p in n[2:4]: |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16834
diff
changeset
|
100 if knownnode(p): |
12761
11c3c77da62a
discovery: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12760
diff
changeset
|
101 base.add(p) # latest known |
1531
2ba8bf7defda
add localrepo.wlock for protecting the dirstate
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1516
diff
changeset
|
102 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
103 for p in n[2:4]: |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16834
diff
changeset
|
104 if p not in req and not knownnode(p): |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
105 r.append(p) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
106 req.add(p) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
107 seen.add(n[0]) |
1716
ef8cd889a78b
Refactor excessive merge detection, add test
Matt Mackall <mpm@selenic.com>
parents:
1713
diff
changeset
|
108 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
109 if r: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
110 reqcnt += 1 |
38400
2f5c622fcb73
treediscovery: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
37634
diff
changeset
|
111 progress.increment() |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
112 repo.ui.debug("request %d: %s\n" % |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
113 (reqcnt, " ".join(map(short, r)))) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
114 for p in xrange(0, len(r), 10): |
37634
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
115 with remote.commandexecutor() as e: |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
116 branches = e.callcommand('branches', { |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
117 'nodes': r[p:p + 10], |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
118 }).result() |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
119 |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
120 for b in branches: |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
121 repo.ui.debug("received %s:%s\n" % |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
122 (short(b[0]), short(b[1]))) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
123 unknown.append(b) |
8404
a2bc39ade36b
commit: move 'nothing changed' test into commit()
Matt Mackall <mpm@selenic.com>
parents:
8403
diff
changeset
|
124 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
125 # do binary search on the branches we found |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
126 while search: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
127 newsearch = [] |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
128 reqcnt += 1 |
38400
2f5c622fcb73
treediscovery: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
37634
diff
changeset
|
129 progress.increment() |
37634
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
130 |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
131 with remote.commandexecutor() as e: |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
132 between = e.callcommand('between', {'pairs': search}).result() |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
133 |
0ed11f9368fd
treediscovery: switch to command executor interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26587
diff
changeset
|
134 for n, l in zip(search, between): |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
135 l.append(n[1]) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
136 p = n[0] |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
137 f = 1 |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
138 for i in l: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
139 repo.ui.debug("narrowing %d:%d %s\n" % (f, len(l), short(i))) |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16834
diff
changeset
|
140 if knownnode(i): |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
141 if f <= 2: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
142 repo.ui.debug("found new branch changeset %s\n" % |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
143 short(p)) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
144 fetch.add(p) |
12761
11c3c77da62a
discovery: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12760
diff
changeset
|
145 base.add(i) |
4915
97b734fb9c6f
Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents:
4914
diff
changeset
|
146 else: |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
147 repo.ui.debug("narrowed branch search to %s:%s\n" |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
148 % (short(p), short(i))) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
149 newsearch.append((p, i)) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
150 break |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
151 p, f = i, f * 2 |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
152 search = newsearch |
9150
09a1ee498756
localrepo: add destroyed() method for strip/rollback to use (issue548).
Greg Ward <greg-hg@gerg.ca>
parents:
9149
diff
changeset
|
153 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
154 # sanity check our fetch list |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
155 for f in fetch: |
20225
d2704c48f417
discovery: stop using nodemap for membership testing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16834
diff
changeset
|
156 if knownnode(f): |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
157 raise error.RepoError(_("already have changeset ") |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
158 + short(f[:4])) |
4912
312c845edef5
simplify dirstate fixups in repo.status()
Matt Mackall <mpm@selenic.com>
parents:
4910
diff
changeset
|
159 |
12761
11c3c77da62a
discovery: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12760
diff
changeset
|
160 base = list(base) |
11c3c77da62a
discovery: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12760
diff
changeset
|
161 if base == [nullid]: |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
162 if force: |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
163 repo.ui.warn(_("warning: repository is unrelated\n")) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
164 else: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25987
diff
changeset
|
165 raise error.Abort(_("repository is unrelated")) |
4372
4ddc6d374265
localrepository.status: only acquire wlock if actually needed.
Bryan O'Sullivan <bos@serpentine.com>
parents:
4335
diff
changeset
|
166 |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
167 repo.ui.debug("found new changesets starting at " + |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
168 " ".join([short(f) for f in fetch]) + "\n") |
2661
5c10b7ed3411
status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2621
diff
changeset
|
169 |
38400
2f5c622fcb73
treediscovery: use progress helper
Martin von Zweigbergk <martinvonz@google.com>
parents:
37634
diff
changeset
|
170 progress.complete() |
11301
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
171 repo.ui.debug("%d total queries\n" % reqcnt) |
3d0591a66118
move discovery methods from localrepo into new discovery module
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
11230
diff
changeset
|
172 |
12761
11c3c77da62a
discovery: use set instead of dict
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
12760
diff
changeset
|
173 return base, list(fetch), heads |