##// END OF EJS Templates
commitctx: extract all the manual logic to process the files...
marmoute -
r45794:0c468fef default
parent child Browse files
Show More
@@ -84,66 +84,10 b' def commitctx(repo, ctx, error=False, or'
84 mn = p1.manifestnode()
84 mn = p1.manifestnode()
85 files = []
85 files = []
86 else:
86 else:
87 m1ctx = p1.manifestctx()
87 mn, files, added, removed = _process_files(tr, ctx, error=error)
88 m2ctx = p2.manifestctx()
89 mctx = m1ctx.copy()
90
91 m = mctx.read()
92 m1 = m1ctx.read()
93 m2 = m2ctx.read()
94
95 # check in files
96 added = []
97 files_added = []
98 removed = list(ctx.removed())
99 touched = []
100 linkrev = len(repo)
101 repo.ui.note(_(b"committing files:\n"))
102 uipathfn = scmutil.getuipathfn(repo)
103 for f in sorted(ctx.modified() + ctx.added()):
104 repo.ui.note(uipathfn(f) + b"\n")
105 try:
106 fctx = ctx[f]
107 if fctx is None:
108 removed.append(f)
109 else:
110 added.append(f)
111 m[f], is_touched = _filecommit(
112 repo, fctx, m1, m2, linkrev, tr, writefilecopymeta,
113 )
114 if is_touched:
115 touched.append(f)
116 if is_touched == 'added':
117 files_added.append(f)
118 m.setflag(f, fctx.flags())
119 except OSError:
120 repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f))
121 raise
122 except IOError as inst:
123 errcode = getattr(inst, 'errno', errno.ENOENT)
124 if error or errcode and errcode != errno.ENOENT:
125 repo.ui.warn(
126 _(b"trouble committing %s!\n") % uipathfn(f)
127 )
128 raise
129
130 # update manifest
131 removed = [f for f in removed if f in m1 or f in m2]
132 drop = sorted([f for f in removed if f in m])
133 for f in drop:
134 del m[f]
135 if p2.rev() != nullrev:
136 rf = metadata.get_removal_filter(ctx, (p1, p2, m1, m2))
137 removed = [f for f in removed if not rf(f)]
138
139 touched.extend(removed)
140
141 files = touched
142 mn = _commit_manifest(tr, linkrev, ctx, mctx, files, added, drop)
143
144 if writechangesetcopy:
88 if writechangesetcopy:
145 filesremoved = removed
89 filesremoved = removed
146 filesadded = files_added
90 filesadded = added
147
91
148 if not writefilecopymeta:
92 if not writefilecopymeta:
149 # If writing only to changeset extras, use None to indicate that
93 # If writing only to changeset extras, use None to indicate that
@@ -192,6 +136,71 b' def commitctx(repo, ctx, error=False, or'
192 return n
136 return n
193
137
194
138
139 def _process_files(tr, ctx, error=False):
140 repo = ctx.repo()
141 p1 = ctx.p1()
142 p2 = ctx.p2()
143
144 writechangesetcopy, writefilecopymeta = _write_copy_meta(repo)
145
146 m1ctx = p1.manifestctx()
147 m2ctx = p2.manifestctx()
148 mctx = m1ctx.copy()
149
150 m = mctx.read()
151 m1 = m1ctx.read()
152 m2 = m2ctx.read()
153
154 # check in files
155 added = []
156 filesadded = []
157 removed = list(ctx.removed())
158 touched = []
159 linkrev = len(repo)
160 repo.ui.note(_(b"committing files:\n"))
161 uipathfn = scmutil.getuipathfn(repo)
162 for f in sorted(ctx.modified() + ctx.added()):
163 repo.ui.note(uipathfn(f) + b"\n")
164 try:
165 fctx = ctx[f]
166 if fctx is None:
167 removed.append(f)
168 else:
169 added.append(f)
170 m[f], is_touched = _filecommit(
171 repo, fctx, m1, m2, linkrev, tr, writefilecopymeta,
172 )
173 if is_touched:
174 touched.append(f)
175 if is_touched == 'added':
176 filesadded.append(f)
177 m.setflag(f, fctx.flags())
178 except OSError:
179 repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f))
180 raise
181 except IOError as inst:
182 errcode = getattr(inst, 'errno', errno.ENOENT)
183 if error or errcode and errcode != errno.ENOENT:
184 repo.ui.warn(_(b"trouble committing %s!\n") % uipathfn(f))
185 raise
186
187 # update manifest
188 removed = [f for f in removed if f in m1 or f in m2]
189 drop = sorted([f for f in removed if f in m])
190 for f in drop:
191 del m[f]
192 if p2.rev() != nullrev:
193 rf = metadata.get_removal_filter(ctx, (p1, p2, m1, m2))
194 removed = [f for f in removed if not rf(f)]
195
196 touched.extend(removed)
197
198 files = touched
199 mn = _commit_manifest(tr, linkrev, ctx, mctx, files, added, drop)
200
201 return mn, files, filesadded, removed
202
203
195 def _filecommit(
204 def _filecommit(
196 repo, fctx, manifest1, manifest2, linkrev, tr, includecopymeta,
205 repo, fctx, manifest1, manifest2, linkrev, tr, includecopymeta,
197 ):
206 ):
General Comments 0
You need to be logged in to leave comments. Login now