mercurial/bundle2.py
changeset 46113 59fa3890d40a
parent 45942 89a2afe31e82
child 46165 41d695a08e90
equal deleted inserted replaced
46112:d6afa9c149c3 46113:59fa3890d40a
   154 import string
   154 import string
   155 import struct
   155 import struct
   156 import sys
   156 import sys
   157 
   157 
   158 from .i18n import _
   158 from .i18n import _
       
   159 from .node import (
       
   160     hex,
       
   161     nullid,
       
   162     short,
       
   163 )
   159 from . import (
   164 from . import (
   160     bookmarks,
   165     bookmarks,
   161     changegroup,
   166     changegroup,
   162     encoding,
   167     encoding,
   163     error,
   168     error,
   164     node as nodemod,
       
   165     obsolete,
   169     obsolete,
   166     phases,
   170     phases,
   167     pushkey,
   171     pushkey,
   168     pycompat,
   172     pycompat,
   169     requirements,
   173     requirements,
  2129     )
  2133     )
  2130     for book, node in bookdata:
  2134     for book, node in bookdata:
  2131         currentnode = op.repo._bookmarks.get(book)
  2135         currentnode = op.repo._bookmarks.get(book)
  2132         if currentnode != node:
  2136         if currentnode != node:
  2133             if node is None:
  2137             if node is None:
  2134                 finalmsg = msgexist % (book, nodemod.short(currentnode))
  2138                 finalmsg = msgexist % (book, short(currentnode))
  2135             elif currentnode is None:
  2139             elif currentnode is None:
  2136                 finalmsg = msgmissing % (book, nodemod.short(node))
  2140                 finalmsg = msgmissing % (book, short(node))
  2137             else:
  2141             else:
  2138                 finalmsg = msgstandard % (
  2142                 finalmsg = msgstandard % (
  2139                     book,
  2143                     book,
  2140                     nodemod.short(node),
  2144                     short(node),
  2141                     nodemod.short(currentnode),
  2145                     short(currentnode),
  2142                 )
  2146                 )
  2143             raise error.PushRaced(finalmsg)
  2147             raise error.PushRaced(finalmsg)
  2144 
  2148 
  2145 
  2149 
  2146 @parthandler(b'check:heads')
  2150 @parthandler(b'check:heads')
  2213     for expectedphase, nodes in pycompat.iteritems(phasetonodes):
  2217     for expectedphase, nodes in pycompat.iteritems(phasetonodes):
  2214         for n in nodes:
  2218         for n in nodes:
  2215             actualphase = phasecache.phase(unfi, cl.rev(n))
  2219             actualphase = phasecache.phase(unfi, cl.rev(n))
  2216             if actualphase != expectedphase:
  2220             if actualphase != expectedphase:
  2217                 finalmsg = msg % (
  2221                 finalmsg = msg % (
  2218                     nodemod.short(n),
  2222                     short(n),
  2219                     phases.phasenames[actualphase],
  2223                     phases.phasenames[actualphase],
  2220                     phases.phasenames[expectedphase],
  2224                     phases.phasenames[expectedphase],
  2221                 )
  2225                 )
  2222                 raise error.PushRaced(finalmsg)
  2226                 raise error.PushRaced(finalmsg)
  2223 
  2227 
  2358             for book, node in changes:
  2362             for book, node in changes:
  2359                 hookargs = tr.hookargs.copy()
  2363                 hookargs = tr.hookargs.copy()
  2360                 hookargs[b'pushkeycompat'] = b'1'
  2364                 hookargs[b'pushkeycompat'] = b'1'
  2361                 hookargs[b'namespace'] = b'bookmarks'
  2365                 hookargs[b'namespace'] = b'bookmarks'
  2362                 hookargs[b'key'] = book
  2366                 hookargs[b'key'] = book
  2363                 hookargs[b'old'] = nodemod.hex(bookstore.get(book, b''))
  2367                 hookargs[b'old'] = hex(bookstore.get(book, b''))
  2364                 hookargs[b'new'] = nodemod.hex(
  2368                 hookargs[b'new'] = hex(node if node is not None else b'')
  2365                     node if node is not None else b''
       
  2366                 )
       
  2367                 allhooks.append(hookargs)
  2369                 allhooks.append(hookargs)
  2368 
  2370 
  2369             for hookargs in allhooks:
  2371             for hookargs in allhooks:
  2370                 op.repo.hook(
  2372                 op.repo.hook(
  2371                     b'prepushkey', throw=True, **pycompat.strkwargs(hookargs)
  2373                     b'prepushkey', throw=True, **pycompat.strkwargs(hookargs)
  2567             oldmatcher=oldmatcher,
  2569             oldmatcher=oldmatcher,
  2568             matcher=newmatcher,
  2570             matcher=newmatcher,
  2569             fullnodes=commonnodes,
  2571             fullnodes=commonnodes,
  2570         )
  2572         )
  2571         cgdata = packer.generate(
  2573         cgdata = packer.generate(
  2572             {nodemod.nullid},
  2574             {nullid},
  2573             list(commonnodes),
  2575             list(commonnodes),
  2574             False,
  2576             False,
  2575             b'narrow_widen',
  2577             b'narrow_widen',
  2576             changelog=False,
  2578             changelog=False,
  2577         )
  2579         )