Mercurial > hg
changeset 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 | 588695ccbb22 |
children | a4692267bc2d |
files | mercurial/hg.py |
diffstat | 1 files changed, 22 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hg.py Sat Feb 20 15:54:09 2016 -0800 +++ b/mercurial/hg.py Sat Feb 20 17:41:59 2016 -0800 @@ -236,20 +236,7 @@ r = repository(ui, destwvfs.base) postshare(srcrepo, r, bookmarks=bookmarks) - - if update: - r.ui.status(_("updating working directory\n")) - if update is not True: - checkout = update - for test in (checkout, 'default', 'tip'): - if test is None: - continue - try: - uprev = r.lookup(test) - break - except error.RepoLookupError: - continue - _update(r, uprev) + _postshareupdate(r, update, checkout=checkout) def postshare(sourcerepo, destrepo, bookmarks=True): """Called after a new shared repo is created. @@ -272,6 +259,27 @@ fp.write('bookmarks\n') fp.close() +def _postshareupdate(repo, update, checkout=None): + """Maybe perform a working directory update after a shared repo is created. + + ``update`` can be a boolean or a revision to update to. + """ + if not update: + return + + repo.ui.status(_("updating working directory\n")) + if update is not True: + checkout = update + for test in (checkout, 'default', 'tip'): + if test is None: + continue + try: + uprev = repo.lookup(test) + break + except error.RepoLookupError: + continue + _update(repo, uprev) + def copystore(ui, srcrepo, destpath): '''copy files from store of srcrepo in destpath