# HG changeset patch # User Pierre-Yves David # Date 1340714109 -7200 # Node ID 5eecfda0a5c748c0e89f3ad09419eea93923912e # Parent 2d0dc5c18489522b586d8c9172945fa544531a17 obsolete: enable rebase --keep again We still never strip anything. But using --keep on the command line dos not lay marker. diff -r 2d0dc5c18489 -r 5eecfda0a5c7 docs/obs-implementation.rst --- a/docs/obs-implementation.rst Tue Jun 26 12:24:04 2012 +0200 +++ b/docs/obs-implementation.rst Tue Jun 26 14:35:09 2012 +0200 @@ -200,7 +200,7 @@ * Use secret phase to remove from discovery obsolete and unstable changeset (to be improved soon) -* alter rebase to use obsolete marker instead of stripping. (XXX break --keep for now) +* alter rebase to use obsolete marker instead of stripping. * Have an experimental mq-like extension to rewrite history (more on that later) diff -r 2d0dc5c18489 -r 5eecfda0a5c7 hgext/obsolete.py --- a/hgext/obsolete.py Tue Jun 26 12:24:04 2012 +0200 +++ b/hgext/obsolete.py Tue Jun 26 14:35:09 2012 +0200 @@ -318,9 +318,8 @@ return newrev def cmdrebase(orig, ui, repo, *args, **kwargs): - if kwargs.get('keep', False): - raise util.Abort(_('rebase --keep option is unsupported with obsolete ' - 'extension'), hint=_("see 'hg help obsolete'")) + + reallykeep = kwargs.get('keep', False) kwargs = dict(kwargs) kwargs['keep'] = True @@ -335,38 +334,39 @@ repo._rebasetarget = None try: res = orig(ui, repo, *args, **kwargs) - # Filter nullmerge or unrebased entries - repo._rebasestate = dict(p for p in repo._rebasestate.iteritems() - if p[1] >= 0) - if not res and not kwargs.get('abort') and repo._rebasestate: - # Rebased revisions are assumed to be descendants of - # targetrev. If a source revision is mapped to targetrev - # or to another rebased revision, it must have been - # removed. - targetrev = repo[repo._rebasetarget].rev() - newrevs = set([targetrev]) - replacements = {} - for rev, newrev in sorted(repo._rebasestate.items()): - oldnode = repo[rev].node() - if newrev not in newrevs: - newnode = repo[newrev].node() - newrevs.add(newrev) + if not reallykeep: + # Filter nullmerge or unrebased entries + repo._rebasestate = dict(p for p in repo._rebasestate.iteritems() + if p[1] >= 0) + if not res and not kwargs.get('abort') and repo._rebasestate: + # Rebased revisions are assumed to be descendants of + # targetrev. If a source revision is mapped to targetrev + # or to another rebased revision, it must have been + # removed. + targetrev = repo[repo._rebasetarget].rev() + newrevs = set([targetrev]) + replacements = {} + for rev, newrev in sorted(repo._rebasestate.items()): + oldnode = repo[rev].node() + if newrev not in newrevs: + newnode = repo[newrev].node() + newrevs.add(newrev) + else: + newnode = nullid + replacements[oldnode] = newnode + + if kwargs.get('collapse'): + newnodes = set(n for n in replacements.values() if n != nullid) + if newnodes: + # Collapsing into more than one revision? + assert len(newnodes) == 1, newnodes + newnode = newnodes.pop() + else: + newnode = nullid + repo.addcollapsedobsolete(replacements, newnode) else: - newnode = nullid - replacements[oldnode] = newnode - - if kwargs.get('collapse'): - newnodes = set(n for n in replacements.values() if n != nullid) - if newnodes: - # Collapsing into more than one revision? - assert len(newnodes) == 1, newnodes - newnode = newnodes.pop() - else: - newnode = nullid - repo.addcollapsedobsolete(replacements, newnode) - else: - for oldnode, newnode in replacements.iteritems(): - repo.addobsolete(newnode, oldnode) + for oldnode, newnode in replacements.iteritems(): + repo.addobsolete(newnode, oldnode) return res finally: delattr(repo, '_rebasestate') diff -r 2d0dc5c18489 -r 5eecfda0a5c7 tests/test-obsolete-rebase.t --- a/tests/test-obsolete-rebase.t Tue Jun 26 12:24:04 2012 +0200 +++ b/tests/test-obsolete-rebase.t Tue Jun 26 14:35:09 2012 +0200 @@ -30,11 +30,43 @@ created new head $ echo e > e $ hg ci -Am adde e - $ hg rebase -d 1 -r . --detach --keep - abort: rebase --keep option is unsupported with obsolete extension - (see 'hg help obsolete') - [255] - $ hg rebase -d 1 -r . --detach + $ hg rebase -d 1 -r 3 --detach --keep + $ glog + @ 4:9c5494949763@default(draft) adde + | + | o 3:98e4a024635e@default(draft) adde + | | + | o 2:102a90ea7b4a@default(draft) addb + | | + o | 1:540395c44225@default(draft) changea + |/ + o 0:07f494440405@default(draft) adda + + $ glog --hidden + @ 4:9c5494949763@default(draft) adde + | + | o 3:98e4a024635e@default(draft) adde + | | + | o 2:102a90ea7b4a@default(draft) addb + | | + o | 1:540395c44225@default(draft) changea + |/ + o 0:07f494440405@default(draft) adda + + $ hg debugsuccessors + $ hg --config extensions.hgext.mq= strip tip + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + saved backup bundle to $TESTTMP/repo/.hg/strip-backup/9c5494949763-backup.hg + $ hg rebase -d 1 -r 3 --detach + $ glog + @ 4:9c5494949763@default(draft) adde + | + | o 2:102a90ea7b4a@default(draft) addb + | | + o | 1:540395c44225@default(draft) changea + |/ + o 0:07f494440405@default(draft) adda + $ glog --hidden @ 4:9c5494949763@default(draft) adde |