Mercurial > hg
comparison mercurial/exchange.py @ 20466:233623d58c9a
push: move discovery in its own function
Now that every necessary information is held in the `pushoperation` object, we
can extract the discovery logic to it's own function.
This changeset is pure code movement only.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Thu, 30 Jan 2014 21:05:29 -0800 |
parents | 170f71061069 |
children | ef880ced6d07 |
comparison
equal
deleted
inserted
replaced
20465:170f71061069 | 20466:233623d58c9a |
---|---|
76 # unbundle assumes local user cannot lock remote repo (new ssh | 76 # unbundle assumes local user cannot lock remote repo (new ssh |
77 # servers, http servers). | 77 # servers, http servers). |
78 | 78 |
79 if not pushop.remote.canpush(): | 79 if not pushop.remote.canpush(): |
80 raise util.Abort(_("destination does not support push")) | 80 raise util.Abort(_("destination does not support push")) |
81 unfi = pushop.repo.unfiltered() | |
82 # get local lock as we might write phase data | 81 # get local lock as we might write phase data |
83 locallock = None | 82 locallock = None |
84 try: | 83 try: |
85 locallock = pushop.repo.lock() | 84 locallock = pushop.repo.lock() |
86 pushop.locallocked = True | 85 pushop.locallocked = True |
98 lock = None | 97 lock = None |
99 unbundle = pushop.remote.capable('unbundle') | 98 unbundle = pushop.remote.capable('unbundle') |
100 if not unbundle: | 99 if not unbundle: |
101 lock = pushop.remote.lock() | 100 lock = pushop.remote.lock() |
102 try: | 101 try: |
103 # discovery | 102 _pushdiscovery(pushop) |
104 fci = discovery.findcommonincoming | |
105 commoninc = fci(unfi, pushop.remote, force=pushop.force) | |
106 common, inc, remoteheads = commoninc | |
107 fco = discovery.findcommonoutgoing | |
108 outgoing = fco(unfi, pushop.remote, onlyheads=pushop.revs, | |
109 commoninc=commoninc, force=pushop.force) | |
110 pushop.outgoing = outgoing | |
111 pushop.remoteheads = remoteheads | |
112 pushop.incoming = inc | |
113 | |
114 if _pushcheckoutgoing(pushop): | 103 if _pushcheckoutgoing(pushop): |
115 _pushchangeset(pushop) | 104 _pushchangeset(pushop) |
116 _pushsyncphase(pushop) | 105 _pushsyncphase(pushop) |
117 _pushobsolete(pushop) | 106 _pushobsolete(pushop) |
118 finally: | 107 finally: |
122 if locallock is not None: | 111 if locallock is not None: |
123 locallock.release() | 112 locallock.release() |
124 | 113 |
125 _pushbookmark(pushop) | 114 _pushbookmark(pushop) |
126 return pushop.ret | 115 return pushop.ret |
116 | |
117 def _pushdiscovery(pushop): | |
118 # discovery | |
119 unfi = pushop.repo.unfiltered() | |
120 fci = discovery.findcommonincoming | |
121 commoninc = fci(unfi, pushop.remote, force=pushop.force) | |
122 common, inc, remoteheads = commoninc | |
123 fco = discovery.findcommonoutgoing | |
124 outgoing = fco(unfi, pushop.remote, onlyheads=pushop.revs, | |
125 commoninc=commoninc, force=pushop.force) | |
126 pushop.outgoing = outgoing | |
127 pushop.remoteheads = remoteheads | |
128 pushop.incoming = inc | |
127 | 129 |
128 def _pushcheckoutgoing(pushop): | 130 def _pushcheckoutgoing(pushop): |
129 outgoing = pushop.outgoing | 131 outgoing = pushop.outgoing |
130 unfi = pushop.repo.unfiltered() | 132 unfi = pushop.repo.unfiltered() |
131 if not outgoing.missing: | 133 if not outgoing.missing: |