mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
allowunstable: remove the extension
Summary: allowunstable is no longer used. So remove it. Test Plan: arc unit Reviewers: #mercurial, stash Reviewed By: stash Subscribers: mjpieters, medson Differential Revision: https://phabricator.intern.facebook.com/D5258845 Signature: t1:5258845:1497602890:4b9c7cffc2132df0a7059fe2fdbeddf3e21c1875
This commit is contained in:
parent
be7ac42b50
commit
a6c7fc128f
@ -1,110 +0,0 @@
|
||||
# allowunstable.py - allow certain commands to create unstable changesets
|
||||
#
|
||||
# Copyright 2016 Facebook, Inc.
|
||||
#
|
||||
# This software may be used and distributed according to the terms of the
|
||||
# GNU General Public License version 2 or any later version.
|
||||
"""enables the creation of unstable changesets for supported commands
|
||||
|
||||
Wraps several commands to temporarily add the `allowunstable` value to the
|
||||
`experimental.evolution` configuration option for the duration of command
|
||||
execution. This lets those commands create unstable changesets and
|
||||
thereby allows them be used on changesets in the middle of a stack.
|
||||
|
||||
This extension is intended as a stopgap measure. Ideally, we would just
|
||||
enable allowunstable globally, but it is unclear if doing so would break
|
||||
any other extensions or functionality. Until that is determined, this
|
||||
extension allows allowunstable to be selectively rolled out while keeping
|
||||
all of the wrapping required to do so in one place.
|
||||
"""
|
||||
|
||||
from mercurial import extensions
|
||||
from mercurial import obsolete
|
||||
|
||||
def extsetup(ui):
|
||||
# Allow the creation of unstable changesets during histedit.
|
||||
try:
|
||||
histedit = extensions.find('histedit')
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
extensions.wrapfunction(histedit, '_histedit', allowunstable)
|
||||
extensions.wrapfunction(histedit, '_histedit',
|
||||
setcreatemarkersop('histedit'))
|
||||
|
||||
# Allow the creation of unstable changesets during split/fold.
|
||||
try:
|
||||
evolve = extensions.find('evolve')
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
if '^split' in evolve.cmdtable:
|
||||
extensions.wrapcommand(evolve.cmdtable, 'split', allowunstable)
|
||||
extensions.wrapcommand(evolve.cmdtable, 'split',
|
||||
setcreatemarkersop('split'))
|
||||
if '^fold|squash' in evolve.cmdtable:
|
||||
extensions.wrapcommand(evolve.cmdtable, 'fold', allowunstable)
|
||||
extensions.wrapcommand(evolve.cmdtable, 'fold',
|
||||
setcreatemarkersop('fold'))
|
||||
|
||||
# Allow the creation of unstable changesets during record.
|
||||
try:
|
||||
record = extensions.find('record')
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
extensions.wrapcommand(record.cmdtable, 'record', allowunstable)
|
||||
extensions.wrapcommand(record.cmdtable, 'record',
|
||||
setcreatemarkersop('amend'))
|
||||
|
||||
# Allow the creation of unstable changesets during rebase.
|
||||
# (Required to use -r without --keep in the middle of a stack.)
|
||||
# No need to set operation name since tweakdefaults does this already.
|
||||
try:
|
||||
rebase = extensions.find('rebase')
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
extensions.wrapcommand(rebase.cmdtable, 'rebase', allowunstable)
|
||||
|
||||
# In addition to wrapping the user-facing command, we also need to
|
||||
# wrap the rebase.rebase() function itself so that extensions that
|
||||
# call it directly will work correctly.
|
||||
extensions.wrapfunction(rebase, 'rebase', allowunstable)
|
||||
|
||||
def allowunstable(orig, ui, repo, *args, **kwargs):
|
||||
"""Wrap a function with the signature orig(ui, repo, *args, **kwargs)
|
||||
to temporarily allow the creation of unstable changesets for the
|
||||
duration of a call to the fuction.
|
||||
"""
|
||||
config = set(repo.ui.configlist('experimental', 'evolution'))
|
||||
|
||||
# Do nothing if the creation of obsmarkers is disabled.
|
||||
if obsolete.createmarkersopt not in config:
|
||||
return orig(ui, repo, *args, **kwargs)
|
||||
|
||||
config.add(obsolete.allowunstableopt)
|
||||
overrides = {('experimental', 'evolution'): config}
|
||||
with repo.ui.configoverride(overrides, 'allowunstable'):
|
||||
return orig(ui, repo, *args, **kwargs)
|
||||
|
||||
def setcreatemarkersop(operation):
|
||||
"""Return a wrapper function that sets the 'operation' field in the
|
||||
metadata of obsmarkers created by the wrapped function to the given
|
||||
operation name. Relies on the tweakdefaults extension to wrap
|
||||
obsolete.createmarkers() to use a global config option to
|
||||
get the operation name.
|
||||
"""
|
||||
try:
|
||||
tweakdefaults = extensions.find('tweakdefaults')
|
||||
except KeyError:
|
||||
# Return a no-op wrapper if there's no tweakdefaults extension.
|
||||
return lambda orig, *args, **kwargs: orig(*args, **kwargs)
|
||||
|
||||
def wrapper(orig, ui, repo, *args, **kwargs):
|
||||
overrides = {(tweakdefaults.globaldata,
|
||||
tweakdefaults.createmarkersoperation): operation}
|
||||
with repo.ui.configoverride(overrides, 'allowunstable'):
|
||||
return orig(ui, repo, *args, **kwargs)
|
||||
|
||||
return wrapper
|
@ -1,98 +0,0 @@
|
||||
Set up test environment.
|
||||
$ . $TESTDIR/require-ext.sh evolve
|
||||
$ extpath=`dirname $TESTDIR`
|
||||
$ cp $extpath/hgext3rd/allowunstable.py $TESTTMP # use $TESTTMP substitution in message
|
||||
$ cat >> $HGRCPATH << EOF
|
||||
> [extensions]
|
||||
> allowunstable=$TESTTMP/allowunstable.py
|
||||
> directaccess=$TESTDIR/../hgext3rd/directaccess.py
|
||||
> evolve=
|
||||
> histedit=
|
||||
> inhibit=$TESTDIR/../hgext3rd/inhibit.py
|
||||
> rebase=
|
||||
> record=
|
||||
> [experimental]
|
||||
> evolution = createmarkers
|
||||
> [ui]
|
||||
> interactive = true
|
||||
> EOF
|
||||
$ showgraph() {
|
||||
> hg log -r '(::.)::' --graph -T "{rev} {desc|firstline}" | sed \$d
|
||||
> }
|
||||
$ reset() {
|
||||
> cd ..
|
||||
> rm -rf allowunstable
|
||||
> hg init allowunstable
|
||||
> cd allowunstable
|
||||
> }
|
||||
$ hg init allowunstable && cd allowunstable
|
||||
$ hg debugbuilddag +5
|
||||
|
||||
Test that we can perform a splits and histedits in the middle of a stack.
|
||||
Since these are interactive commands, just ensure that we don't get
|
||||
an error message.
|
||||
$ hg up 2
|
||||
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
$ hg split
|
||||
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
$ hg histedit
|
||||
|
||||
Test that we can perform a fold in the middle of a stack.
|
||||
$ hg up 2
|
||||
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
$ hg fold --from ".^"
|
||||
2 changesets folded
|
||||
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
$ showgraph
|
||||
@ 5 r1
|
||||
|
|
||||
| o 4 r4
|
||||
| |
|
||||
| o 3 r3
|
||||
| |
|
||||
| o 2 r2
|
||||
| |
|
||||
| o 1 r1
|
||||
|/
|
||||
o 0 r0
|
||||
|
||||
Test that we can perform a rebase in the middle of a stack.
|
||||
$ hg rebase -r 3 -d 5
|
||||
rebasing 3:2dc09a01254d "r3"
|
||||
note: rebase of 3:2dc09a01254d created no changes to commit
|
||||
1 new unstable changesets
|
||||
$ showgraph
|
||||
@ 5 r1
|
||||
|
|
||||
| o 4 r4
|
||||
| |
|
||||
| x 3 r3
|
||||
| |
|
||||
| o 2 r2
|
||||
| |
|
||||
| o 1 r1
|
||||
|/
|
||||
o 0 r0
|
||||
|
||||
Test that we can perform `hg record --amend` in the middle of a stack.
|
||||
$ reset
|
||||
$ hg debugbuilddag +3
|
||||
$ hg up 1
|
||||
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
$ touch foo
|
||||
$ hg add foo
|
||||
$ hg record --amend << EOF
|
||||
> y
|
||||
> EOF
|
||||
diff --git a/foo b/foo
|
||||
new file mode 100644
|
||||
examine changes to 'foo'? [Ynesfdaq?] y
|
||||
|
||||
$ showgraph
|
||||
@ 4 r1
|
||||
|
|
||||
| o 2 r2
|
||||
| |
|
||||
| o 1 r1
|
||||
|/
|
||||
o 0 r0
|
@ -1,17 +1,13 @@
|
||||
Set up test environment.
|
||||
$ extpath=`dirname $TESTDIR`
|
||||
$ cp $extpath/hgext3rd/allowunstable.py $TESTTMP
|
||||
$ cp $extpath/hgext3rd/debuginhibit.py $TESTTMP
|
||||
$ cat >> $HGRCPATH << EOF
|
||||
> [extensions]
|
||||
> allowunstable=$TESTTMP/allowunstable.py
|
||||
> debuginhibit=$TESTTMP/debuginhibit.py
|
||||
> debuginhibit=$TESTDIR/../hgext3rd/debuginhibit.py
|
||||
> directaccess=$TESTDIR/../hgext3rd/directaccess.py
|
||||
> fbamend=$TESTDIR/../hgext3rd/fbamend
|
||||
> inhibit=$TESTDIR/../hgext3rd/inhibit.py
|
||||
> rebase=
|
||||
> [experimental]
|
||||
> evolution = createmarkers
|
||||
> evolution = createmarkers, allowunstable
|
||||
> EOF
|
||||
$ showgraph() {
|
||||
> hg log --graph -T "{rev} {desc|firstline}" | sed \$d
|
||||
|
@ -1,19 +1,14 @@
|
||||
$ extpath=`dirname $TESTDIR`
|
||||
$ cp $extpath/hgext3rd/allowunstable.py $TESTTMP
|
||||
$ cp $extpath/hgext3rd/smartlog.py $TESTTMP
|
||||
$ cp $extpath/hgext3rd/tweakdefaults.py $TESTTMP
|
||||
$ cat >> $HGRCPATH << EOF
|
||||
> [extensions]
|
||||
> allowunstable=$TESTTMP/allowunstable.py
|
||||
> directaccess=$TESTDIR/../hgext3rd/directaccess.py
|
||||
> fbamend=$TESTDIR/../hgext3rd/fbamend
|
||||
> histedit=
|
||||
> inhibit=$TESTDIR/../hgext3rd/inhibit.py
|
||||
> rebase=
|
||||
> smartlog=$TESTTMP/smartlog.py
|
||||
> tweakdefaults=$TESTTMP/tweakdefaults.py
|
||||
> smartlog=$TESTDIR/../hgext3rd/smartlog.py
|
||||
> tweakdefaults=$TESTDIR/../hgext3rd/tweakdefaults.py
|
||||
> [experimental]
|
||||
> evolution = createmarkers
|
||||
> evolution = createmarkers, allowunstable
|
||||
> allowdivergence = on
|
||||
> [ui]
|
||||
> interactive = true
|
||||
|
Loading…
Reference in New Issue
Block a user