hgext/narrow/narrowbundle2.py
changeset 40868 109a267acc1e
parent 40867 0d50bfcd8f65
child 41076 8ecb17b7f432
equal deleted inserted replaced
40867:0d50bfcd8f65 40868:109a267acc1e
    18 from mercurial import (
    18 from mercurial import (
    19     bundle2,
    19     bundle2,
    20     changegroup,
    20     changegroup,
    21     error,
    21     error,
    22     exchange,
    22     exchange,
       
    23     localrepo,
    23     narrowspec,
    24     narrowspec,
    24     repair,
    25     repair,
    25     repository,
    26     repository,
    26     util,
    27     util,
    27     wireprototypes,
    28     wireprototypes,
   177                 _('unexpected changespec node chunk type: %s') % chunksignal)
   178                 _('unexpected changespec node chunk type: %s') % chunksignal)
   178         chunksignal = changegroup.readexactly(inpart, 4)
   179         chunksignal = changegroup.readexactly(inpart, 4)
   179 
   180 
   180     if clkills:
   181     if clkills:
   181         # preserve bookmarks that repair.strip() would otherwise strip
   182         # preserve bookmarks that repair.strip() would otherwise strip
   182         bmstore = repo._bookmarks
   183         op._bookmarksbackup = repo._bookmarks
   183         class dummybmstore(dict):
   184         class dummybmstore(dict):
   184             def applychanges(self, repo, tr, changes):
   185             def applychanges(self, repo, tr, changes):
   185                 pass
   186                 pass
   186         repo._bookmarks = dummybmstore()
   187         localrepo.localrepository._bookmarks.set(repo, dummybmstore())
   187         chgrpfile = repair.strip(op.ui, repo, list(clkills), backup=True,
   188         chgrpfile = repair.strip(op.ui, repo, list(clkills), backup=True,
   188                                  topic='widen')
   189                                  topic='widen')
   189         repo._bookmarks = bmstore
       
   190         if chgrpfile:
   190         if chgrpfile:
   191             op._widen_uninterr = repo.ui.uninterruptable()
   191             op._widen_uninterr = repo.ui.uninterruptable()
   192             op._widen_uninterr.__enter__()
   192             op._widen_uninterr.__enter__()
   193             # presence of _widen_bundle attribute activates widen handler later
   193             # presence of _widen_bundle attribute activates widen handler later
   194             op._widen_bundle = chgrpfile
   194             op._widen_bundle = chgrpfile
   268     origcghandler = bundle2.parthandlermapping['changegroup']
   268     origcghandler = bundle2.parthandlermapping['changegroup']
   269     def wrappedcghandler(op, inpart):
   269     def wrappedcghandler(op, inpart):
   270         origcghandler(op, inpart)
   270         origcghandler(op, inpart)
   271         if util.safehasattr(op, '_widen_bundle'):
   271         if util.safehasattr(op, '_widen_bundle'):
   272             handlechangegroup_widen(op, inpart)
   272             handlechangegroup_widen(op, inpart)
       
   273         if util.safehasattr(op, '_bookmarksbackup'):
       
   274             localrepo.localrepository._bookmarks.set(op.repo,
       
   275                                                      op._bookmarksbackup)
       
   276             del op._bookmarksbackup
       
   277 
   273     wrappedcghandler.params = origcghandler.params
   278     wrappedcghandler.params = origcghandler.params
   274     bundle2.parthandlermapping['changegroup'] = wrappedcghandler
   279     bundle2.parthandlermapping['changegroup'] = wrappedcghandler