Mercurial > hg
comparison mercurial/changegroup.py @ 22960:7c13c9404c2c
changegroup: use a copy of hookargs when invoking the changegroup hook
addchangegroup creates a runhook function that is used to invoke the
changegroup and incoming hooks, but at the time the function is called,
the contents of hookargs associated with the transaction may have been
modified externally. For instance, bundle2 code affects it with
obsolescence markers and bookmarks info.
It also creates problems when a single transaction is used with multiple
changegroups added (as per an upcoming change), whereby the contents
of hookargs are that of after adding a latter changegroup when invoking
the hook for the first changegroup.
author | Mike Hommey <mh@glandium.org> |
---|---|
date | Thu, 16 Oct 2014 15:54:53 +0900 |
parents | e2806b8613ca |
children | 01e98eba3bc1 |
comparison
equal
deleted
inserted
replaced
22959:10116463b0b1 | 22960:7c13c9404c2c |
---|---|
685 | 685 |
686 if changesets > 0: | 686 if changesets > 0: |
687 p = lambda: cl.writepending() and repo.root or "" | 687 p = lambda: cl.writepending() and repo.root or "" |
688 if 'node' not in tr.hookargs: | 688 if 'node' not in tr.hookargs: |
689 tr.hookargs['node'] = hex(cl.node(clstart)) | 689 tr.hookargs['node'] = hex(cl.node(clstart)) |
690 hookargs = dict(tr.hookargs) | |
691 else: | |
692 hookargs = dict(tr.hookargs) | |
693 hookargs['node'] = hex(cl.node(clstart)) | |
690 repo.hook('pretxnchangegroup', throw=True, source=srctype, | 694 repo.hook('pretxnchangegroup', throw=True, source=srctype, |
691 url=url, pending=p, **tr.hookargs) | 695 url=url, pending=p, **hookargs) |
692 | 696 |
693 added = [cl.node(r) for r in xrange(clstart, clend)] | 697 added = [cl.node(r) for r in xrange(clstart, clend)] |
694 publishing = repo.ui.configbool('phases', 'publish', True) | 698 publishing = repo.ui.configbool('phases', 'publish', True) |
695 if srctype in ('push', 'serve'): | 699 if srctype in ('push', 'serve'): |
696 # Old servers can not push the boundary themselves. | 700 # Old servers can not push the boundary themselves. |
722 if srctype != 'strip': | 726 if srctype != 'strip': |
723 # During strip, branchcache is invalid but coming call to | 727 # During strip, branchcache is invalid but coming call to |
724 # `destroyed` will repair it. | 728 # `destroyed` will repair it. |
725 # In other case we can safely update cache on disk. | 729 # In other case we can safely update cache on disk. |
726 branchmap.updatecache(repo.filtered('served')) | 730 branchmap.updatecache(repo.filtered('served')) |
731 | |
727 def runhooks(): | 732 def runhooks(): |
728 # These hooks run when the lock releases, not when the | 733 # These hooks run when the lock releases, not when the |
729 # transaction closes. So it's possible for the changelog | 734 # transaction closes. So it's possible for the changelog |
730 # to have changed since we last saw it. | 735 # to have changed since we last saw it. |
731 if clstart >= len(repo): | 736 if clstart >= len(repo): |
732 return | 737 return |
733 | 738 |
734 # forcefully update the on-disk branch cache | 739 # forcefully update the on-disk branch cache |
735 repo.ui.debug("updating the branch cache\n") | 740 repo.ui.debug("updating the branch cache\n") |
736 repo.hook("changegroup", source=srctype, url=url, | 741 repo.hook("changegroup", source=srctype, url=url, |
737 **tr.hookargs) | 742 **hookargs) |
738 | 743 |
739 for n in added: | 744 for n in added: |
740 repo.hook("incoming", node=hex(n), source=srctype, | 745 repo.hook("incoming", node=hex(n), source=srctype, |
741 url=url) | 746 url=url) |
742 | 747 |