Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGb38c7304974f: absorb: let scmutil.cleanupnodes() take care of setting phase
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/absorb.py (8 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Feb 27 2019, 7:34 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz |
the commit is a clone from ctx, with a (optionally) different p1, and | the commit is a clone from ctx, with a (optionally) different p1, and | ||||
different file contents replaced by memworkingcopy. | different file contents replaced by memworkingcopy. | ||||
""" | """ | ||||
parents = p1 and (p1, node.nullid) | parents = p1 and (p1, node.nullid) | ||||
extra = ctx.extra() | extra = ctx.extra() | ||||
if self._useobsolete and self.ui.configbool('absorb', 'add-noise'): | if self._useobsolete and self.ui.configbool('absorb', 'add-noise'): | ||||
extra['absorb_source'] = ctx.hex() | extra['absorb_source'] = ctx.hex() | ||||
mctx = overlaycontext(memworkingcopy, ctx, parents, extra=extra) | mctx = overlaycontext(memworkingcopy, ctx, parents, extra=extra) | ||||
# preserve phase | |||||
with mctx.repo().ui.configoverride({ | |||||
('phases', 'new-commit'): ctx.phase()}): | |||||
return mctx.commit() | return mctx.commit() | ||||
@util.propertycache | @util.propertycache | ||||
def _useobsolete(self): | def _useobsolete(self): | ||||
"""() -> bool""" | """() -> bool""" | ||||
return obsolete.isenabled(self.repo, obsolete.createmarkersopt) | return obsolete.isenabled(self.repo, obsolete.createmarkersopt) | ||||
def _cleanupoldcommits(self): | def _cleanupoldcommits(self): | ||||
replacements = {k: ([v] if v is not None else []) | replacements = {k: ([v] if v is not None else []) | ||||
for k, v in self.replacemap.iteritems()} | for k, v in self.replacemap.iteritems()} | ||||
if replacements: | if replacements: | ||||
scmutil.cleanupnodes(self.repo, replacements, operation='absorb') | scmutil.cleanupnodes(self.repo, replacements, operation='absorb', | ||||
fixphase=True) | |||||
def _parsechunk(hunk): | def _parsechunk(hunk): | ||||
"""(crecord.uihunk or patch.recordhunk) -> (path, (a1, a2, [bline]))""" | """(crecord.uihunk or patch.recordhunk) -> (path, (a1, a2, [bline]))""" | ||||
if type(hunk) not in (crecord.uihunk, patch.recordhunk): | if type(hunk) not in (crecord.uihunk, patch.recordhunk): | ||||
return None, None | return None, None | ||||
path = hunk.header.filename() | path = hunk.header.filename() | ||||
a1 = hunk.fromline + len(hunk.before) - 1 | a1 = hunk.fromline + len(hunk.before) - 1 | ||||
# remove before and after context | # remove before and after context |