##// END OF EJS Templates
hooklib: fix detection of successors for changeset_obsoleted...
Joerg Sonnenberger -
r46020:04ef3810 default
parent child Browse files
Show More
@@ -122,10 +122,18 b' def _report_commit(ui, repo, ctx):'
122 122 )
123 123
124 124
125 def has_successor(repo, rev):
126 return any(
127 r for r in obsutil.allsuccessors(repo.obsstore, [rev]) if r != rev
128 )
129
130
125 131 def hook(ui, repo, hooktype, node=None, **kwargs):
126 if hooktype != b"pretxnclose":
132 if hooktype != b"txnclose":
127 133 raise error.Abort(
128 134 _(b'Unsupported hook type %r') % pycompat.bytestr(hooktype)
129 135 )
130 for rev in obsutil.getobsoleted(repo, repo.currenttransaction()):
131 _report_commit(ui, repo, repo.unfiltered()[rev])
136 for rev in obsutil.getobsoleted(repo, changes=kwargs['changes']):
137 ctx = repo.unfiltered()[rev]
138 if not has_successor(repo, ctx.node()):
139 _report_commit(ui, repo, ctx)
@@ -13,6 +13,7 b' from .i18n import _'
13 13 from . import (
14 14 diffutil,
15 15 encoding,
16 error,
16 17 node as nodemod,
17 18 phases,
18 19 pycompat,
@@ -481,14 +482,23 b' def geteffectflag(source, successors):'
481 482 return effects
482 483
483 484
484 def getobsoleted(repo, tr):
485 """return the set of pre-existing revisions obsoleted by a transaction"""
485 def getobsoleted(repo, tr=None, changes=None):
486 """return the set of pre-existing revisions obsoleted by a transaction
487
488 Either the transaction or changes item of the transaction (for hooks)
489 must be provided, but not both.
490 """
491 if (tr is None) == (changes is None):
492 e = b"exactly one of tr and changes must be provided"
493 raise error.ProgrammingError(e)
486 494 torev = repo.unfiltered().changelog.index.get_rev
487 495 phase = repo._phasecache.phase
488 496 succsmarkers = repo.obsstore.successors.get
489 497 public = phases.public
490 addedmarkers = tr.changes[b'obsmarkers']
491 origrepolen = tr.changes[b'origrepolen']
498 if changes is None:
499 changes = tr.changes
500 addedmarkers = changes[b'obsmarkers']
501 origrepolen = changes[b'origrepolen']
492 502 seenrevs = set()
493 503 obsoleted = set()
494 504 for mark in addedmarkers:
@@ -24,7 +24,7 b''
24 24 $ cat <<EOF >> b/.hg/hgrc
25 25 > [hooks]
26 26 > incoming.notify = python:hgext.notify.hook
27 > pretxnclose.changeset_obsoleted = python:hgext.hooklib.changeset_obsoleted.hook
27 > txnclose.changeset_obsoleted = python:hgext.hooklib.changeset_obsoleted.hook
28 28 > EOF
29 29 $ hg --cwd b pull ../a | "$PYTHON" $TESTDIR/unwrap-message-id.py
30 30 pulling from ../a
@@ -72,6 +72,8 b''
72 72 pushing to ../b
73 73 searching for changes
74 74 no changes found
75 1 new obsolescence markers
76 obsoleted 1 changesets
75 77 Subject: changeset abandoned
76 78 In-reply-to: <hg.81c297828fd2d5afaadf2775a6a71b74143b6451dfaac09fac939e9107a50d01@example.com>
77 79 Message-Id: <hg.d6329e9481594f0f3c8a84362b3511318bfbce50748ab1123f909eb6fbcab018@example.com>
@@ -80,5 +82,33 b''
80 82 To: baz@example.com
81 83
82 84 This changeset has been abandoned.
85
86 Check that known changesets with known successors do not result in a mail.
87
88 $ hg init c
89 $ hg init d
90 $ cat <<EOF >> d/.hg/hgrc
91 > [hooks]
92 > incoming.notify = python:hgext.notify.hook
93 > txnclose.changeset_obsoleted = python:hgext.hooklib.changeset_obsoleted.hook
94 > EOF
95 $ hg --cwd c debugbuilddag '.:parent.*parent'
96 $ hg --cwd c push ../d -r 1
97 pushing to ../d
98 searching for changes
99 adding changesets
100 adding manifests
101 adding file changes
102 added 2 changesets with 0 changes to 0 files
103 $ hg --cwd c debugobsolete $(hg --cwd c log -T '{node}' -r 1) $(hg --cwd c log -T '{node}' -r 2)
83 104 1 new obsolescence markers
84 105 obsoleted 1 changesets
106 $ hg --cwd c push ../d | "$PYTHON" $TESTDIR/unwrap-message-id.py
107 pushing to ../d
108 searching for changes
109 adding changesets
110 adding manifests
111 adding file changes
112 added 1 changesets with 0 changes to 0 files (+1 heads)
113 1 new obsolescence markers
114 obsoleted 1 changesets
General Comments 0
You need to be logged in to leave comments. Login now