Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hg.py @ 28632:a2c2dd399f3b stable
hg: perform update after pulling during clone with share (issue5103)
This is a graft of 60adda1a0188 and a4692267bc2d from the default
branch. Combined, they address a bug with pooled shared storage where
an update may not update to the most recent revision when performing
a `hg clone`.
The patches should have been written against the stable branch in
the beginning. I screwed up.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 25 Mar 2016 10:47:49 -0700 |
parents | d493d64757eb |
children | 0e330d7d9f53 |
line wrap: on
line diff
--- a/mercurial/hg.py Thu Mar 24 09:38:11 2016 -0700 +++ b/mercurial/hg.py Fri Mar 25 10:47:49 2016 -0700 @@ -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 @@ -361,7 +369,7 @@ rev=rev, update=False, stream=stream) sharerepo = repository(ui, path=sharepath) - share(ui, sharerepo, dest=dest, update=update, bookmarks=False) + share(ui, sharerepo, dest=dest, update=False, bookmarks=False) # We need to perform a pull against the dest repo to fetch bookmarks # and other non-store data that isn't shared by default. In the case of @@ -371,6 +379,8 @@ destrepo = repository(ui, path=dest) exchange.pull(destrepo, srcpeer, heads=revs) + _postshareupdate(destrepo, update) + return srcpeer, peer(ui, peeropts, dest) def clone(ui, peeropts, source, dest=None, pull=False, rev=None,