Show More
@@ -40,6 +40,8 b'' | |||
|
40 | 40 | # changegroup = ... # template when run as changegroup hook |
|
41 | 41 | # maxdiff = 300 # max lines of diffs to include (0=none, -1=all) |
|
42 | 42 | # maxsubject = 67 # truncate subject line longer than this |
|
43 | # sources = serve # notify if source of incoming changes in this list | |
|
44 | # # (serve == ssh or http, push, pull, bundle) | |
|
43 | 45 | # [email] |
|
44 | 46 | # from = user@host.com # email address to send as if none given |
|
45 | 47 | # [web] |
@@ -167,6 +169,11 b' class notifier(object):' | |||
|
167 | 169 | root=self.repo.root, |
|
168 | 170 | webroot=self.root) |
|
169 | 171 | |
|
172 | def skipsource(self, source): | |
|
173 | '''true if incoming changes from this source should be skipped.''' | |
|
174 | ok_sources = self.ui.config('notify', 'sources', 'serve').split() | |
|
175 | return source not in ok_sources | |
|
176 | ||
|
170 | 177 | def send(self, node, count): |
|
171 | 178 | '''send message.''' |
|
172 | 179 | |
@@ -210,7 +217,7 b' class notifier(object):' | |||
|
210 | 217 | msg['Message-Id'] = ('<hg.%s.%s.%s@%s>' % |
|
211 | 218 | (short(node), int(time.time()), |
|
212 | 219 | hash(self.repo.root), socket.getfqdn())) |
|
213 | msg['To'] = self.subs | |
|
220 | msg['To'] = ', '.join(self.subs) | |
|
214 | 221 | |
|
215 | 222 | msgtext = msg.as_string(0) |
|
216 | 223 | if self.ui.configbool('notify', 'test', True): |
@@ -238,13 +245,14 b' class notifier(object):' | |||
|
238 | 245 | self.sio.write(_('\ndiffs (%d lines):\n\n') % len(difflines)) |
|
239 | 246 | self.sio.write(*difflines) |
|
240 | 247 | |
|
241 | def hook(ui, repo, hooktype, node=None, **kwargs): | |
|
248 | def hook(ui, repo, hooktype, node=None, source=None, **kwargs): | |
|
242 | 249 | '''send email notifications to interested subscribers. |
|
243 | 250 | |
|
244 | 251 | if used as changegroup hook, send one email for all changesets in |
|
245 | 252 | changegroup. else send one email per changeset.''' |
|
246 | 253 | n = notifier(ui, repo, hooktype) |
|
247 |
if not n.subs: |
|
|
254 | if not n.subs or n.skipsource(source): | |
|
255 | return | |
|
248 | 256 | node = bin(node) |
|
249 | 257 | if hooktype == 'changegroup': |
|
250 | 258 | start = repo.changelog.rev(node) |
@@ -2477,7 +2477,7 b' def serve(ui, repo, **opts):' | |||
|
2477 | 2477 | continue |
|
2478 | 2478 | respond("") |
|
2479 | 2479 | |
|
2480 | r = repo.addchangegroup(fin) | |
|
2480 | r = repo.addchangegroup(fin, 'serve') | |
|
2481 | 2481 | respond(str(r)) |
|
2482 | 2482 | |
|
2483 | 2483 | optlist = ("name templates style address port ipv6" |
@@ -2701,7 +2701,7 b' def unbundle(ui, repo, fname, **opts):' | |||
|
2701 | 2701 | raise util.Abort(_("%s: unknown bundle compression type") |
|
2702 | 2702 | % fname) |
|
2703 | 2703 | gen = generator(util.filechunkiter(f, 4096)) |
|
2704 | modheads = repo.addchangegroup(util.chunkbuffer(gen)) | |
|
2704 | modheads = repo.addchangegroup(util.chunkbuffer(gen), 'unbundle') | |
|
2705 | 2705 | return postincoming(ui, repo, modheads, opts['update']) |
|
2706 | 2706 | |
|
2707 | 2707 | def undo(ui, repo): |
@@ -1079,7 +1079,7 b' class localrepository(object):' | |||
|
1079 | 1079 | cg = remote.changegroup(fetch, 'pull') |
|
1080 | 1080 | else: |
|
1081 | 1081 | cg = remote.changegroupsubset(fetch, heads, 'pull') |
|
1082 | return self.addchangegroup(cg) | |
|
1082 | return self.addchangegroup(cg, 'pull') | |
|
1083 | 1083 | |
|
1084 | 1084 | def push(self, remote, force=False, revs=None): |
|
1085 | 1085 | lock = remote.lock() |
@@ -1116,7 +1116,7 b' class localrepository(object):' | |||
|
1116 | 1116 | cg = self.changegroup(update, 'push') |
|
1117 | 1117 | else: |
|
1118 | 1118 | cg = self.changegroupsubset(update, revs, 'push') |
|
1119 | return remote.addchangegroup(cg) | |
|
1119 | return remote.addchangegroup(cg, 'push') | |
|
1120 | 1120 | |
|
1121 | 1121 | def changegroupsubset(self, bases, heads, source): |
|
1122 | 1122 | """This function generates a changegroup consisting of all the nodes |
@@ -1455,7 +1455,7 b' class localrepository(object):' | |||
|
1455 | 1455 | |
|
1456 | 1456 | return util.chunkbuffer(gengroup()) |
|
1457 | 1457 | |
|
1458 | def addchangegroup(self, source): | |
|
1458 | def addchangegroup(self, source, srctype): | |
|
1459 | 1459 | """add changegroup to repo. |
|
1460 | 1460 | returns number of heads modified or added + 1.""" |
|
1461 | 1461 | |
@@ -1469,7 +1469,7 b' class localrepository(object):' | |||
|
1469 | 1469 | if not source: |
|
1470 | 1470 | return 0 |
|
1471 | 1471 | |
|
1472 |
self.hook('prechangegroup', throw=True, source=s |
|
|
1472 | self.hook('prechangegroup', throw=True, source=srctype) | |
|
1473 | 1473 | |
|
1474 | 1474 | changesets = files = revisions = 0 |
|
1475 | 1475 | |
@@ -1534,17 +1534,17 b' class localrepository(object):' | |||
|
1534 | 1534 | % (changesets, revisions, files, heads)) |
|
1535 | 1535 | |
|
1536 | 1536 | self.hook('pretxnchangegroup', throw=True, |
|
1537 |
node=hex(self.changelog.node(cor+1)), source=s |
|
|
1537 | node=hex(self.changelog.node(cor+1)), source=srctype) | |
|
1538 | 1538 | |
|
1539 | 1539 | tr.close() |
|
1540 | 1540 | |
|
1541 | 1541 | if changesets > 0: |
|
1542 | 1542 | self.hook("changegroup", node=hex(self.changelog.node(cor+1)), |
|
1543 |
source=s |
|
|
1543 | source=srctype) | |
|
1544 | 1544 | |
|
1545 | 1545 | for i in range(cor + 1, cnr + 1): |
|
1546 | 1546 | self.hook("incoming", node=hex(self.changelog.node(i)), |
|
1547 |
source=s |
|
|
1547 | source=srctype) | |
|
1548 | 1548 | |
|
1549 | 1549 | return newheads - oldheads + 1 |
|
1550 | 1550 |
@@ -134,7 +134,7 b' class sshrepository(remoterepository):' | |||
|
134 | 134 | f = self.do_cmd("changegroup", roots=n) |
|
135 | 135 | return self.pipei |
|
136 | 136 | |
|
137 | def addchangegroup(self, cg): | |
|
137 | def addchangegroup(self, cg, source): | |
|
138 | 138 | d = self.call("addchangegroup") |
|
139 | 139 | if d: |
|
140 | 140 | raise hg.RepoError(_("push refused: %s"), d) |
General Comments 0
You need to be logged in to leave comments.
Login now