Mercurial > public > mercurial-scm > hg
comparison mercurial/hg.py @ 28201:60adda1a0188
hg: extract post share update logic into own function
A future patch will introduce a new caller that needs to perform
an update. Extract the code so we don't duplicate it.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 20 Feb 2016 17:41:59 -0800 |
parents | 91a827e760df |
children | a4692267bc2d |
comparison
equal
deleted
inserted
replaced
28200:588695ccbb22 | 28201:60adda1a0188 |
---|---|
234 destvfs.write('requires', requirements) | 234 destvfs.write('requires', requirements) |
235 destvfs.write('sharedpath', sharedpath) | 235 destvfs.write('sharedpath', sharedpath) |
236 | 236 |
237 r = repository(ui, destwvfs.base) | 237 r = repository(ui, destwvfs.base) |
238 postshare(srcrepo, r, bookmarks=bookmarks) | 238 postshare(srcrepo, r, bookmarks=bookmarks) |
239 | 239 _postshareupdate(r, update, checkout=checkout) |
240 if update: | |
241 r.ui.status(_("updating working directory\n")) | |
242 if update is not True: | |
243 checkout = update | |
244 for test in (checkout, 'default', 'tip'): | |
245 if test is None: | |
246 continue | |
247 try: | |
248 uprev = r.lookup(test) | |
249 break | |
250 except error.RepoLookupError: | |
251 continue | |
252 _update(r, uprev) | |
253 | 240 |
254 def postshare(sourcerepo, destrepo, bookmarks=True): | 241 def postshare(sourcerepo, destrepo, bookmarks=True): |
255 """Called after a new shared repo is created. | 242 """Called after a new shared repo is created. |
256 | 243 |
257 The new repo only has a requirements file and pointer to the source. | 244 The new repo only has a requirements file and pointer to the source. |
269 | 256 |
270 if bookmarks: | 257 if bookmarks: |
271 fp = destrepo.vfs('shared', 'w') | 258 fp = destrepo.vfs('shared', 'w') |
272 fp.write('bookmarks\n') | 259 fp.write('bookmarks\n') |
273 fp.close() | 260 fp.close() |
261 | |
262 def _postshareupdate(repo, update, checkout=None): | |
263 """Maybe perform a working directory update after a shared repo is created. | |
264 | |
265 ``update`` can be a boolean or a revision to update to. | |
266 """ | |
267 if not update: | |
268 return | |
269 | |
270 repo.ui.status(_("updating working directory\n")) | |
271 if update is not True: | |
272 checkout = update | |
273 for test in (checkout, 'default', 'tip'): | |
274 if test is None: | |
275 continue | |
276 try: | |
277 uprev = repo.lookup(test) | |
278 break | |
279 except error.RepoLookupError: | |
280 continue | |
281 _update(repo, uprev) | |
274 | 282 |
275 def copystore(ui, srcrepo, destpath): | 283 def copystore(ui, srcrepo, destpath): |
276 '''copy files from store of srcrepo in destpath | 284 '''copy files from store of srcrepo in destpath |
277 | 285 |
278 returns destlock | 286 returns destlock |