Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 7787:b8d750daadde
Introduce HG_PREPEND to solve pretxn races
- add writepending to flush delayed writes to separate file
- add support in hooks for lazy evaluation of callable parameters
- add HG_PENDING to pretxn hooks
- call writepending if hook is used
- pass repo root to hook environment
- if HG_PENDING = repo root, we're in pretxn hook
- read pending data to make pending changesets visible
- filter HG_PENDING in tests/printenv.py
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 16 Feb 2009 19:35:07 -0600 |
parents | b7ac53f7b061 |
children | 6d99ff7b79b5 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Sun Jan 18 19:59:51 2009 +0100 +++ b/mercurial/localrepo.py Mon Feb 16 19:35:07 2009 -0600 @@ -88,6 +88,10 @@ def __getattr__(self, name): if name == 'changelog': self.changelog = changelog.changelog(self.sopener) + if 'HG_PENDING' in os.environ: + p = os.environ['HG_PENDING'] + if p.startswith(self.root): + self.changelog.readpending('00changelog.i.a') self.sopener.defversion = self.changelog.version return self.changelog if name == 'manifest': @@ -955,10 +959,13 @@ raise util.Abort(_("empty commit message")) text = '\n'.join(lines) + self.changelog.delayupdate() n = self.changelog.add(mn, changed + removed, text, trp, p1, p2, user, wctx.date(), extra) + p = lambda: self.changelog.writepending() and self.root or "" self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, - parent2=xp2) + parent2=xp2, pending=p) + self.changelog.finalize(trp) tr.close() if self.branchcache: @@ -2034,9 +2041,6 @@ revisions += len(fl) - o files += 1 - # make changelog see real files again - cl.finalize(trp) - newheads = len(self.changelog.heads()) heads = "" if oldheads and newheads != oldheads: @@ -2047,9 +2051,13 @@ % (changesets, revisions, files, heads)) if changesets > 0: + p = lambda: self.changelog.writepending() and self.root or "" self.hook('pretxnchangegroup', throw=True, node=hex(self.changelog.node(cor+1)), source=srctype, - url=url) + url=url, pending=p) + + # make changelog see real files again + cl.finalize(trp) tr.close() finally: