A future commit will introduce a caller from outside the module.
The function should have already been public because histedit was
calling it.
( )
| durin42 | |
| pulkit | 
| hg-reviewers | 
A future commit will introduce a caller from outside the module.
The function should have already been public because histedit was
calling it.
| Lint Skipped | 
| Unit Tests Skipped | 
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/histedit.py (4 lines) | |||
| M | mercurial/repair.py (9 lines) | 
| state.replacements = [] | state.replacements = [] | ||||
| ui.log("histedit", "%d actions to histedit", len(actions), | ui.log("histedit", "%d actions to histedit", len(actions), | ||||
| histedit_num_actions=len(actions)) | histedit_num_actions=len(actions)) | ||||
| # Create a backup so we can always abort completely. | # Create a backup so we can always abort completely. | ||||
| backupfile = None | backupfile = None | ||||
| if not obsolete.isenabled(repo, obsolete.createmarkersopt): | if not obsolete.isenabled(repo, obsolete.createmarkersopt): | ||||
| backupfile = repair._bundle(repo, [parentctxnode], [topmost], root, | backupfile = repair.backupbundle(repo, [parentctxnode], | ||||
| 'histedit') | [topmost], root, 'histedit') | ||||
| state.backupfile = backupfile | state.backupfile = backupfile | ||||
| def _getsummary(ctx): | def _getsummary(ctx): | ||||
| # a common pattern is to extract the summary but default to the empty | # a common pattern is to extract the summary but default to the empty | ||||
| # string | # string | ||||
| summary = ctx.description() or '' | summary = ctx.description() or '' | ||||
| if summary: | if summary: | ||||
| summary = summary.splitlines()[0] | summary = summary.splitlines()[0] | ||||
| discovery, | discovery, | ||||
| error, | error, | ||||
| exchange, | exchange, | ||||
| obsolete, | obsolete, | ||||
| obsutil, | obsutil, | ||||
| util, | util, | ||||
| ) | ) | ||||
| def _bundle(repo, bases, heads, node, suffix, compress=True, obsolescence=True): | def backupbundle(repo, bases, heads, node, suffix, compress=True, | ||||
| obsolescence=True): | |||||
| """create a bundle with the specified revisions as a backup""" | """create a bundle with the specified revisions as a backup""" | ||||
| backupdir = "strip-backup" | backupdir = "strip-backup" | ||||
| vfs = repo.vfs | vfs = repo.vfs | ||||
| if not vfs.isdir(backupdir): | if not vfs.isdir(backupdir): | ||||
| vfs.mkdir(backupdir) | vfs.mkdir(backupdir) | ||||
| # Include a hash of all the nodes in the filename for uniqueness | # Include a hash of all the nodes in the filename for uniqueness | ||||
| if rev in tostrip: | if rev in tostrip: | ||||
| updatebm.append(m) | updatebm.append(m) | ||||
| # create a changegroup for all the branches we need to keep | # create a changegroup for all the branches we need to keep | ||||
| backupfile = None | backupfile = None | ||||
| vfs = repo.vfs | vfs = repo.vfs | ||||
| node = nodelist[-1] | node = nodelist[-1] | ||||
| if backup: | if backup: | ||||
| backupfile = _bundle(repo, stripbases, cl.heads(), node, topic) | backupfile = backupbundle(repo, stripbases, cl.heads(), node, topic) | ||||
| repo.ui.status(_("saved backup bundle to %s\n") % | repo.ui.status(_("saved backup bundle to %s\n") % | ||||
| vfs.join(backupfile)) | vfs.join(backupfile)) | ||||
| repo.ui.log("backupbundle", "saved backup bundle to %s\n", | repo.ui.log("backupbundle", "saved backup bundle to %s\n", | ||||
| vfs.join(backupfile)) | vfs.join(backupfile)) | ||||
| tmpbundlefile = None | tmpbundlefile = None | ||||
| if saveheads: | if saveheads: | ||||
| # do not compress temporary bundle if we remove it from disk later | # do not compress temporary bundle if we remove it from disk later | ||||
| # | # | ||||
| # We do not include obsolescence, it might re-introduce prune markers | # We do not include obsolescence, it might re-introduce prune markers | ||||
| # we are trying to strip. This is harmless since the stripped markers | # we are trying to strip. This is harmless since the stripped markers | ||||
| # are already backed up and we did not touched the markers for the | # are already backed up and we did not touched the markers for the | ||||
| # saved changesets. | # saved changesets. | ||||
| tmpbundlefile = _bundle(repo, savebases, saveheads, node, 'temp', | tmpbundlefile = backupbundle(repo, savebases, saveheads, node, 'temp', | ||||
| compress=False, obsolescence=False) | compress=False, obsolescence=False) | ||||
| try: | try: | ||||
| with repo.transaction("strip") as tr: | with repo.transaction("strip") as tr: | ||||
| offset = len(tr.entries) | offset = len(tr.entries) | ||||
| tr.startgroup() | tr.startgroup() | ||||
| cl.strip(striprev, tr) | cl.strip(striprev, tr) | ||||
| stripmanifest(repo, striprev, tr, files) | stripmanifest(repo, striprev, tr, files) | ||||