comparison mercurial/repair.py @ 41100:399010051cf4

strip: extract code to create strip backup We will reuse this for soft stripping.
author Boris Feld <boris.feld@octobus.net>
date Wed, 02 Jan 2019 05:01:15 +0100
parents e80329a3952c
children f04e0ca04099
comparison
equal deleted inserted replaced
41099:e80329a3952c 41100:399010051cf4
166 for m in bm: 166 for m in bm:
167 rev = repo[bm[m]].rev() 167 rev = repo[bm[m]].rev()
168 if rev in tostrip: 168 if rev in tostrip:
169 updatebm.append(m) 169 updatebm.append(m)
170 170
171 # backup the changeset we are about to strip
172 backupfile = None 171 backupfile = None
173 node = nodelist[-1] 172 node = nodelist[-1]
174 if backup: 173 if backup:
175 backupfile = backupbundle(repo, stripbases, cl.heads(), node, topic) 174 backupfile = _createstripbackup(repo, stripbases, node, topic)
176 repo.ui.status(_("saved backup bundle to %s\n") %
177 vfs.join(backupfile))
178 repo.ui.log("backupbundle", "saved backup bundle to %s\n",
179 vfs.join(backupfile))
180 # create a changegroup for all the branches we need to keep 175 # create a changegroup for all the branches we need to keep
181 tmpbundlefile = None 176 tmpbundlefile = None
182 if saveheads: 177 if saveheads:
183 # do not compress temporary bundle if we remove it from disk later 178 # do not compress temporary bundle if we remove it from disk later
184 # 179 #
268 repo.destroyed() 263 repo.destroyed()
269 # return the backup file path (or None if 'backup' was False) so 264 # return the backup file path (or None if 'backup' was False) so
270 # extensions can use it 265 # extensions can use it
271 return backupfile 266 return backupfile
272 267
268 def _createstripbackup(repo, stripbases, node, topic):
269 # backup the changeset we are about to strip
270 vfs = repo.vfs
271 cl = repo.changelog
272 backupfile = backupbundle(repo, stripbases, cl.heads(), node, topic)
273 repo.ui.status(_("saved backup bundle to %s\n") %
274 vfs.join(backupfile))
275 repo.ui.log("backupbundle", "saved backup bundle to %s\n",
276 vfs.join(backupfile))
277 return backupfile
278
273 def safestriproots(ui, repo, nodes): 279 def safestriproots(ui, repo, nodes):
274 """return list of roots of nodes where descendants are covered by nodes""" 280 """return list of roots of nodes where descendants are covered by nodes"""
275 torev = repo.unfiltered().changelog.rev 281 torev = repo.unfiltered().changelog.rev
276 revs = set(torev(n) for n in nodes) 282 revs = set(torev(n) for n in nodes)
277 # tostrip = wanted - unsafe = wanted - ancestors(orphaned) 283 # tostrip = wanted - unsafe = wanted - ancestors(orphaned)