comparison mercurial/commit.py @ 45328:e52031f5e046

commitctx: create the ChangingFiles object directly in the various case No need to compute all data then create the object, we can create it early and directly store data in it. We start simple by moving create higher in the function, but the end goal is to eventually move the creation inside the `_process_files` function to take advantage of the object there.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 25 Jul 2020 16:13:32 +0200
parents 6de4c5647db3
children dcbad0f17d76
comparison
equal deleted inserted replaced
45327:6de4c5647db3 45328:e52031f5e046
113 repo = ctx.repo() 113 repo = ctx.repo()
114 p1 = ctx.p1() 114 p1 = ctx.p1()
115 115
116 writechangesetcopy, writefilecopymeta = _write_copy_meta(repo) 116 writechangesetcopy, writefilecopymeta = _write_copy_meta(repo)
117 117
118 filesadded, filesremoved = None, None
119 if ctx.manifestnode(): 118 if ctx.manifestnode():
120 # reuse an existing manifest revision 119 # reuse an existing manifest revision
121 repo.ui.debug(b'reusing known manifest\n') 120 repo.ui.debug(b'reusing known manifest\n')
122 mn = ctx.manifestnode() 121 mn = ctx.manifestnode()
123 touched = ctx.files() 122 files = metadata.ChangingFiles()
123 files.update_touched(ctx.files())
124 if writechangesetcopy: 124 if writechangesetcopy:
125 filesadded = ctx.filesadded() 125 files.update_added(ctx.filesadded())
126 filesremoved = ctx.filesremoved() 126 files.update_removed(ctx.filesremoved())
127 elif not ctx.files(): 127 elif not ctx.files():
128 repo.ui.debug(b'reusing manifest from p1 (no file change)\n') 128 repo.ui.debug(b'reusing manifest from p1 (no file change)\n')
129 mn = p1.manifestnode() 129 mn = p1.manifestnode()
130 touched = [] 130 files = metadata.ChangingFiles()
131 else: 131 else:
132 r = _process_files(tr, ctx, error=error) 132 mn, touched, added, removed = _process_files(tr, ctx, error=error)
133 mn, touched, filesadded, filesremoved = r 133 files = metadata.ChangingFiles()
134 files.update_touched(touched)
135 if added:
136 files.update_added(added)
137 if removed:
138 files.update_removed(removed)
134 139
135 if origctx and origctx.manifestnode() == mn: 140 if origctx and origctx.manifestnode() == mn:
136 touched = origctx.files() 141 origfiles = origctx.files()
137 142 assert files.touched.issubset(origfiles)
138 files = metadata.ChangingFiles() 143 files.update_touched(origfiles)
139 if touched: 144
140 files.update_touched(touched)
141 if writechangesetcopy: 145 if writechangesetcopy:
142 files.update_copies_from_p1(ctx.p1copies()) 146 files.update_copies_from_p1(ctx.p1copies())
143 files.update_copies_from_p2(ctx.p2copies()) 147 files.update_copies_from_p2(ctx.p2copies())
144 if filesadded:
145 files.update_added(filesadded)
146 if filesremoved:
147 files.update_removed(filesremoved)
148 148
149 return mn, files 149 return mn, files
150 150
151 151
152 def _process_files(tr, ctx, error=False): 152 def _process_files(tr, ctx, error=False):