mercurial/hg.py
changeset 52725 0f2268783c11
parent 52645 4cb75772818d
equal deleted inserted replaced
52724:5c37a03ccfb3 52725:0f2268783c11
    11 import os
    11 import os
    12 import posixpath
    12 import posixpath
    13 import shutil
    13 import shutil
    14 import stat
    14 import stat
    15 import typing
    15 import typing
    16 import weakref
       
    17 
    16 
    18 from .i18n import _
    17 from .i18n import _
    19 from .node import (
    18 from .node import (
    20     hex,
    19     hex,
    21     sha1nodeconstants,
    20     sha1nodeconstants,
   948             # make the peer aware that is it already locked
   947             # make the peer aware that is it already locked
   949             #
   948             #
   950             # important:
   949             # important:
   951             #
   950             #
   952             #    We still need to release that lock at the end of the function
   951             #    We still need to release that lock at the end of the function
   953             destpeer.local()._lockref = weakref.ref(destlock)
   952             if destrepo.dirstate._dirty:
   954             destpeer.local()._wlockref = weakref.ref(destwlock)
   953                 msg = "dirstate dirty after stream clone"
   955             # dirstate also needs to be copied because `_wlockref` has a reference
   954                 raise error.ProgrammingError(msg)
   956             # to it: this dirstate is saved to disk when the wlock is released
   955             destwlock = destpeer.local().wlock(steal_from=destwlock)
   957             destpeer.local().dirstate = destrepo.dirstate
   956             destlock = destpeer.local().lock(steal_from=destlock)
   958 
   957 
   959             srcrepo.hook(
   958             srcrepo.hook(
   960                 b'outgoing', source=b'clone', node=srcrepo.nodeconstants.nullhex
   959                 b'outgoing',
       
   960                 source=b'clone',
       
   961                 node=srcrepo.nodeconstants.nullhex,
   961             )
   962             )
   962         else:
   963         else:
   963             try:
   964             try:
   964                 # only pass ui when no srcrepo
   965                 # only pass ui when no srcrepo
   965                 destpeer = peer(
   966                 destpeer = peer(
  1119                 _update(destrepo, uprev)
  1120                 _update(destrepo, uprev)
  1120                 if update in destrepo._bookmarks:
  1121                 if update in destrepo._bookmarks:
  1121                     bookmarks.activate(destrepo, update)
  1122                     bookmarks.activate(destrepo, update)
  1122             if destlock is not None:
  1123             if destlock is not None:
  1123                 release(destlock)
  1124                 release(destlock)
       
  1125                 destlock = None
  1124             if destwlock is not None:
  1126             if destwlock is not None:
  1125                 release(destlock)
  1127                 release(destwlock)
       
  1128                 destwlock = None
  1126             # here is a tiny windows were someone could end up writing the
  1129             # here is a tiny windows were someone could end up writing the
  1127             # repository before the cache are sure to be warm. This is "fine"
  1130             # repository before the cache are sure to be warm. This is "fine"
  1128             # as the only "bad" outcome would be some slowness. That potential
  1131             # as the only "bad" outcome would be some slowness. That potential
  1129             # slowness already affect reader.
  1132             # slowness already affect reader.
  1130             with destrepo.lock():
  1133             with destrepo.lock():