Mercurial > hg
comparison hgext/rebase.py @ 27744:f2b8b4e2de20
rebase: minor refactoring of _computeobsoletenotrebased
This patch is a refactoring of the code skipping obsolete changesets already
present in destination. It makes the following patches more legible.
Instead of passing all the revs to be rebased to _computeobsoletenotrebased,
we only pass the obsolete revisions of the rebaseset.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Wed, 06 Jan 2016 12:55:56 -0800 |
parents | 157675d0f600 |
children | d3a128e8604a |
comparison
equal
deleted
inserted
replaced
27743:5dcadc6c5aed | 27744:f2b8b4e2de20 |
---|---|
341 hint=_('use --keep to keep original changesets')) | 341 hint=_('use --keep to keep original changesets')) |
342 | 342 |
343 obsoletenotrebased = {} | 343 obsoletenotrebased = {} |
344 if ui.configbool('experimental', 'rebaseskipobsolete'): | 344 if ui.configbool('experimental', 'rebaseskipobsolete'): |
345 rebasesetrevs = set(rebaseset) | 345 rebasesetrevs = set(rebaseset) |
346 rebaseobsrevs = set(r for r in rebasesetrevs | |
347 if repo[r].obsolete()) | |
346 obsoletenotrebased = _computeobsoletenotrebased(repo, | 348 obsoletenotrebased = _computeobsoletenotrebased(repo, |
347 rebasesetrevs, | 349 rebaseobsrevs, |
348 dest) | 350 dest) |
349 | 351 |
350 # - plain prune (no successor) changesets are rebased | 352 # - plain prune (no successor) changesets are rebased |
351 # - split changesets are not rebased if at least one of the | 353 # - split changesets are not rebased if at least one of the |
352 # changeset resulting from the split is an ancestor of dest | 354 # changeset resulting from the split is an ancestor of dest |
1172 """ensure rebased revs stay visible (see issue4505)""" | 1174 """ensure rebased revs stay visible (see issue4505)""" |
1173 blockers = orig(repo) | 1175 blockers = orig(repo) |
1174 blockers.update(getattr(repo, '_rebaseset', ())) | 1176 blockers.update(getattr(repo, '_rebaseset', ())) |
1175 return blockers | 1177 return blockers |
1176 | 1178 |
1177 def _computeobsoletenotrebased(repo, rebasesetrevs, dest): | 1179 def _computeobsoletenotrebased(repo, rebaseobsrevs, dest): |
1178 """return a mapping obsolete => successor for all obsolete nodes to be | 1180 """return a mapping obsolete => successor for all obsolete nodes to be |
1179 rebased that have a successors in the destination | 1181 rebased that have a successors in the destination |
1180 | 1182 |
1181 obsolete => None entries in the mapping indicate nodes with no succesor""" | 1183 obsolete => None entries in the mapping indicate nodes with no succesor""" |
1182 obsoletenotrebased = {} | 1184 obsoletenotrebased = {} |
1183 | 1185 |
1184 # Build a mapping successor => obsolete nodes for the obsolete | 1186 # Build a mapping successor => obsolete nodes for the obsolete |
1185 # nodes to be rebased | 1187 # nodes to be rebased |
1186 allsuccessors = {} | 1188 allsuccessors = {} |
1187 cl = repo.changelog | 1189 cl = repo.changelog |
1188 for r in rebasesetrevs: | 1190 for r in rebaseobsrevs: |
1189 n = repo[r] | 1191 node = cl.node(r) |
1190 if n.obsolete(): | 1192 for s in obsolete.allsuccessors(repo.obsstore, [node]): |
1191 node = cl.node(r) | 1193 try: |
1192 for s in obsolete.allsuccessors(repo.obsstore, [node]): | 1194 allsuccessors[cl.rev(s)] = cl.rev(node) |
1193 try: | 1195 except LookupError: |
1194 allsuccessors[cl.rev(s)] = cl.rev(node) | 1196 pass |
1195 except LookupError: | |
1196 pass | |
1197 | 1197 |
1198 if allsuccessors: | 1198 if allsuccessors: |
1199 # Look for successors of obsolete nodes to be rebased among | 1199 # Look for successors of obsolete nodes to be rebased among |
1200 # the ancestors of dest | 1200 # the ancestors of dest |
1201 ancs = cl.ancestors([repo[dest].rev()], | 1201 ancs = cl.ancestors([repo[dest].rev()], |