Show More
@@ -96,7 +96,7 b' class changelog(revlog.revlog):' | |||
|
96 | 96 | fp = self.opener(self.indexfile, 'a') |
|
97 | 97 | fp.write("".join(self._delaybuf)) |
|
98 | 98 | fp.close() |
|
99 |
|
|
|
99 | self._delaybuf = [] | |
|
100 | 100 | # split when we're done |
|
101 | 101 | self.checkinlinesize(tr) |
|
102 | 102 | |
@@ -115,6 +115,31 b' class changelog(revlog.revlog):' | |||
|
115 | 115 | # otherwise, divert to memory |
|
116 | 116 | return appender(fp, self._delaybuf) |
|
117 | 117 | |
|
118 | def readpending(self, file): | |
|
119 | r = revlog.revlog(self.opener, file) | |
|
120 | self.index = r.index | |
|
121 | self.nodemap = r.nodemap | |
|
122 | self._chunkcache = r._chunkcache | |
|
123 | ||
|
124 | def writepending(self): | |
|
125 | "create a file containing the unfinalized state for pretxnchangegroup" | |
|
126 | if self._delaybuf: | |
|
127 | # make a temporary copy of the index | |
|
128 | fp1 = self._realopener(self.indexfile) | |
|
129 | fp2 = self._realopener(self.indexfile + ".a", "w") | |
|
130 | fp2.write(fp1.read()) | |
|
131 | # add pending data | |
|
132 | fp2.write("".join(self._delaybuf)) | |
|
133 | fp2.close() | |
|
134 | # switch modes so finalize can simply rename | |
|
135 | self._delaybuf = [] | |
|
136 | self._delayname = fp1.name | |
|
137 | ||
|
138 | if self._delayname: | |
|
139 | return True | |
|
140 | ||
|
141 | return False | |
|
142 | ||
|
118 | 143 | def checkinlinesize(self, tr, fp=None): |
|
119 | 144 | if self.opener == self._delayopener: |
|
120 | 145 | return |
@@ -70,7 +70,13 b' def _pythonhook(ui, repo, name, hname, f' | |||
|
70 | 70 | |
|
71 | 71 | def _exthook(ui, repo, name, cmd, args, throw): |
|
72 | 72 | ui.note(_("running hook %s: %s\n") % (name, cmd)) |
|
73 | env = dict([('HG_' + k.upper(), v) for k, v in args.iteritems()]) | |
|
73 | ||
|
74 | env = {} | |
|
75 | for k, v in args.iteritems(): | |
|
76 | if callable(v): | |
|
77 | v = v() | |
|
78 | env['HG_' + k.upper()] = v | |
|
79 | ||
|
74 | 80 | if repo: |
|
75 | 81 | cwd = repo.root |
|
76 | 82 | else: |
@@ -88,6 +88,10 b' class localrepository(repo.repository):' | |||
|
88 | 88 | def __getattr__(self, name): |
|
89 | 89 | if name == 'changelog': |
|
90 | 90 | self.changelog = changelog.changelog(self.sopener) |
|
91 | if 'HG_PENDING' in os.environ: | |
|
92 | p = os.environ['HG_PENDING'] | |
|
93 | if p.startswith(self.root): | |
|
94 | self.changelog.readpending('00changelog.i.a') | |
|
91 | 95 | self.sopener.defversion = self.changelog.version |
|
92 | 96 | return self.changelog |
|
93 | 97 | if name == 'manifest': |
@@ -955,10 +959,13 b' class localrepository(repo.repository):' | |||
|
955 | 959 | raise util.Abort(_("empty commit message")) |
|
956 | 960 | text = '\n'.join(lines) |
|
957 | 961 | |
|
962 | self.changelog.delayupdate() | |
|
958 | 963 | n = self.changelog.add(mn, changed + removed, text, trp, p1, p2, |
|
959 | 964 | user, wctx.date(), extra) |
|
965 | p = lambda: self.changelog.writepending() and self.root or "" | |
|
960 | 966 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
|
961 | parent2=xp2) | |
|
967 | parent2=xp2, pending=p) | |
|
968 | self.changelog.finalize(trp) | |
|
962 | 969 | tr.close() |
|
963 | 970 | |
|
964 | 971 | if self.branchcache: |
@@ -2034,9 +2041,6 b' class localrepository(repo.repository):' | |||
|
2034 | 2041 | revisions += len(fl) - o |
|
2035 | 2042 | files += 1 |
|
2036 | 2043 | |
|
2037 | # make changelog see real files again | |
|
2038 | cl.finalize(trp) | |
|
2039 | ||
|
2040 | 2044 | newheads = len(self.changelog.heads()) |
|
2041 | 2045 | heads = "" |
|
2042 | 2046 | if oldheads and newheads != oldheads: |
@@ -2047,9 +2051,13 b' class localrepository(repo.repository):' | |||
|
2047 | 2051 | % (changesets, revisions, files, heads)) |
|
2048 | 2052 | |
|
2049 | 2053 | if changesets > 0: |
|
2054 | p = lambda: self.changelog.writepending() and self.root or "" | |
|
2050 | 2055 | self.hook('pretxnchangegroup', throw=True, |
|
2051 | 2056 | node=hex(self.changelog.node(cor+1)), source=srctype, |
|
2052 | url=url) | |
|
2057 | url=url, pending=p) | |
|
2058 | ||
|
2059 | # make changelog see real files again | |
|
2060 | cl.finalize(trp) | |
|
2053 | 2061 | |
|
2054 | 2062 | tr.close() |
|
2055 | 2063 | finally: |
@@ -46,6 +46,9 b' if url.startswith("file:"):' | |||
|
46 | 46 | elif url.startswith("remote:http"): |
|
47 | 47 | os.environ["HG_URL"] = "remote:http" |
|
48 | 48 | |
|
49 | if "HG_PENDING" in os.environ: | |
|
50 | os.environ["HG_PENDING"] = os.environ["HG_PENDING"] and "true" | |
|
51 | ||
|
49 | 52 | out.write("%s hook: " % name) |
|
50 | 53 | for v in env: |
|
51 | 54 | out.write("%s=%s " % (v, os.environ[v])) |
@@ -1,18 +1,18 b'' | |||
|
1 | 1 | precommit hook: HG_PARENT1=0000000000000000000000000000000000000000 |
|
2 | pretxncommit hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 | |
|
2 | pretxncommit hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=true | |
|
3 | 3 | 0:29b62aeb769f |
|
4 | 4 | commit hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 |
|
5 | 5 | commit.b hook: HG_NODE=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PARENT1=0000000000000000000000000000000000000000 |
|
6 | 6 | updating working directory |
|
7 | 7 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
8 | 8 | precommit hook: HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
9 | pretxncommit hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
|
9 | pretxncommit hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PENDING=true | |
|
10 | 10 | 1:b702efe96888 |
|
11 | 11 | commit hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
12 | 12 | commit.b hook: HG_NODE=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
13 | 13 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
14 | 14 | precommit hook: HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
15 | pretxncommit hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b | |
|
15 | pretxncommit hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b HG_PENDING=true | |
|
16 | 16 | 2:1324a5531bac |
|
17 | 17 | commit hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
|
18 | 18 | commit.b hook: HG_NODE=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT1=29b62aeb769fdf78d8d9c5f28b017f76d7ef824b |
@@ -20,7 +20,7 b' created new head' | |||
|
20 | 20 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
21 | 21 | (branch merge, don't forget to commit) |
|
22 | 22 | precommit hook: HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 |
|
23 | pretxncommit hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 | |
|
23 | pretxncommit hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 HG_PENDING=true | |
|
24 | 24 | 3:4c52fb2e4022 |
|
25 | 25 | commit hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 |
|
26 | 26 | commit.b hook: HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_PARENT1=1324a5531bac09b329c3845d35ae6a7526874edb HG_PARENT2=b702efe9688826e3a91283852b328b84dbf37bc2 |
@@ -43,7 +43,7 b' added 3 changesets with 2 changes to 2 f' | |||
|
43 | 43 | (run 'hg update' to get a working copy) |
|
44 | 44 | pretag hook: HG_LOCAL=0 HG_NODE=4c52fb2e402287dd5dc052090682536c8406c321 HG_TAG=a |
|
45 | 45 | precommit hook: HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 |
|
46 | pretxncommit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 | |
|
46 | pretxncommit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 HG_PENDING=true | |
|
47 | 47 | 4:8ea2ef7ad3e8 |
|
48 | 48 | commit hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 |
|
49 | 49 | commit.b hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PARENT1=4c52fb2e402287dd5dc052090682536c8406c321 |
@@ -58,9 +58,9 b' pretag.forbid hook: HG_LOCAL=1 HG_NODE=8' | |||
|
58 | 58 | abort: pretag.forbid hook exited with status 1 |
|
59 | 59 | 4:8ea2ef7ad3e8 |
|
60 | 60 | precommit hook: HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 |
|
61 | pretxncommit hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 | |
|
61 | pretxncommit hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=true | |
|
62 | 62 | 5:fad284daf8c0 |
|
63 | pretxncommit.forbid hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 | |
|
63 | pretxncommit.forbid hook: HG_NODE=fad284daf8c032148abaffcd745dafeceefceb61 HG_PARENT1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=true | |
|
64 | 64 | transaction abort! |
|
65 | 65 | rollback completed |
|
66 | 66 | abort: pretxncommit.forbid1 hook exited with status 1 |
@@ -80,7 +80,7 b' pulling from ../a' | |||
|
80 | 80 | searching for changes |
|
81 | 81 | abort: prechangegroup.forbid hook exited with status 1 |
|
82 | 82 | 4:8ea2ef7ad3e8 |
|
83 | pretxnchangegroup.forbid hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_SOURCE=pull HG_URL=file: | |
|
83 | pretxnchangegroup.forbid hook: HG_NODE=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 HG_PENDING=true HG_SOURCE=pull HG_URL=file: | |
|
84 | 84 | pulling from ../a |
|
85 | 85 | searching for changes |
|
86 | 86 | adding changesets |
General Comments 0
You need to be logged in to leave comments.
Login now