fbamend: add unhide command for easy unhiding of commits

Summary:
This command helps the user to bring back the commits to life with an explicit
command - wihtout the need to change working copy parent or create bookmarks.

Test Plan: see test

Reviewers: #fbhgext, durham, kulshrax, quark

Reviewed By: #fbhgext, quark

Subscribers: ryanmce

Differential Revision: https://phab.mercurial-scm.org/D179
This commit is contained in:
Mateusz Kwapich 2017-07-27 03:39:01 -07:00
parent ad3ecb91d5
commit 89aa9cf5dd
2 changed files with 41 additions and 0 deletions

View File

@ -14,6 +14,7 @@ from mercurial import (
cmdutil,
error,
hg,
extensions,
obsolete,
registrar,
scmutil,
@ -78,3 +79,20 @@ def hide(ui, repo, *revs, **opts):
if len(bmchanges) > 0:
ui.status(_('%i bookmarks removed\n') % len(bmchanges))
@command('^unhide', [('r', 'rev', [], _("revisions to unhide"))])
def unhide(ui, repo, *revs, **opts):
"""unhide changesets and their ancestors
"""
unfi = repo.unfiltered()
revs = list(revs) + opts.pop('rev', [])
revs = set(scmutil.revrange(unfi, revs))
ctxs = unfi.set("::(%ld) & obsolete()", revs)
with repo.wlock(), repo.lock(), repo.transaction('unhide'):
try:
inhibit = extensions.find('inhibit')
inhibit.revive(ctxs, operation='unhide')
except KeyError:
raise error.Abort(_('cannot unhide - inhibit extension '
'is not enabled'))

View File

@ -1,6 +1,7 @@
$ cat >> $HGRCPATH << EOF
> [extensions]
> fbamend=$TESTDIR/../hgext3rd/fbamend
> inhibit=$TESTDIR/../hgext3rd/inhibit.py
> drawdag=$RUNTESTDIR/drawdag.py
> [experimental]
> evolution = createmarkers, allowunstable
@ -60,3 +61,25 @@ Hide multiple commits with bookmarks on them, hide wc parent
$ hg log -G -T '{rev} {desc} {bookmarks}\n'
@ 0 A
Unhide stuff
$ hg unhide 2
$ hg log -G -T '{rev} {desc} {bookmarks}\n'
o 2 C
|
o 1 B
|
@ 0 A
$ hg unhide -r 4 -r 3
$ hg log -G -T '{rev} {desc} {bookmarks}\n'
o 4 E
|
| o 3 D
| |
o | 2 C
|/
o 1 B
|
@ 0 A