24 from mercurial import base85 |
24 from mercurial import base85 |
25 from mercurial import commands |
25 from mercurial import commands |
26 from mercurial import extensions |
26 from mercurial import extensions |
27 from mercurial import node |
27 from mercurial import node |
28 from mercurial import obsolete |
28 from mercurial import obsolete |
|
29 from mercurial import exchange |
29 from mercurial import revset |
30 from mercurial import revset |
30 from mercurial.i18n import _ |
31 from mercurial.i18n import _ |
31 |
32 |
32 _strategies = { |
33 _strategies = { |
33 'stock': obsolete.syncpush, |
34 'stock': exchange._pushobsolete, |
34 } |
35 } |
35 |
36 |
36 def _strategy(name, default=False): |
37 def _strategy(name, default=False): |
37 def inner(func): |
38 def inner(func): |
38 _strategies[name] = func |
39 _strategies[name] = func |
39 if default: |
40 if default: |
40 _strategies[None] = func |
41 _strategies[None] = func |
41 return func |
42 return func |
42 return inner |
43 return inner |
43 |
44 |
44 def syncpushwrapper(orig, repo, remote): |
45 def _pushobsoletewrapper(orig, pushop): |
45 stratfn = _strategies[repo.ui.config('obsolete', 'syncstrategy')] |
46 stratfn = _strategies[pushop.repo.ui.config('obsolete', 'syncstrategy')] |
46 return stratfn(repo, remote) |
47 return stratfn(pushop) |
47 |
48 |
48 extensions.wrapfunction(obsolete, 'syncpush', syncpushwrapper) |
49 extensions.wrapfunction(exchange, '_pushobsolete', _pushobsoletewrapper) |
49 |
|
50 def _getoutgoing(): |
|
51 f = sys._getframe(4) |
|
52 return f.f_locals['outgoing'] |
|
53 |
|
54 |
50 |
55 def _precursors(repo, s): |
51 def _precursors(repo, s): |
56 """Precursor of a changeset""" |
52 """Precursor of a changeset""" |
57 cs = set() |
53 cs = set() |
58 nm = repo.changelog.nodemap |
54 nm = repo.changelog.nodemap |
71 |
67 |
72 revset.symbols['_fastobs_precursors'] = _revsetprecursors |
68 revset.symbols['_fastobs_precursors'] = _revsetprecursors |
73 |
69 |
74 |
70 |
75 @_strategy('boxfill', default=True) |
71 @_strategy('boxfill', default=True) |
76 def boxfill(repo, remote): |
72 def boxfill(pushop): |
77 """The "fill in the box" strategy from the 2.6 sprint. |
73 """The "fill in the box" strategy from the 2.6 sprint. |
78 |
74 |
79 See the notes[0] from the 2.6 sprint for what "fill in the box" |
75 See the notes[0] from the 2.6 sprint for what "fill in the box" |
80 means here. It's a fairly subtle algorithm, which may have |
76 means here. It's a fairly subtle algorithm, which may have |
81 surprising behavior at times, but was the least-bad option |
77 surprising behavior at times, but was the least-bad option |
82 proposed at the sprint. |
78 proposed at the sprint. |
83 |
79 |
84 [0]: https://bitbucket.org/durin42/2.6sprint-notes/src/tip/mercurial26-obsstore-rev.1398.txt |
80 [0]: https://bitbucket.org/durin42/2.6sprint-notes/src/tip/mercurial26-obsstore-rev.1398.txt |
85 """ |
81 """ |
86 outgoing = _getoutgoing() |
82 repo = pushop.repo |
87 urepo = repo.unfiltered() |
83 remote = pushop.remote |
|
84 outgoing = pushop.outgoing |
|
85 urepo = pushop.repo.unfiltered() |
88 # need to collect obsolete markers which list any of |
86 # need to collect obsolete markers which list any of |
89 # outgoing.missing as a successor (transitively), as well as any |
87 # outgoing.missing as a successor (transitively), as well as any |
90 # kill markers for dead nodes descended from any of the precursors |
88 # kill markers for dead nodes descended from any of the precursors |
91 # of outgoing.missing. |
89 # of outgoing.missing. |
92 boxedges = urepo.revs( |
90 boxedges = urepo.revs( |