Skip to content

Commit ea0f526

Browse files
committed
support nondescructive argument to deactivate
--HG-- rename : README.rst => README.txt
1 parent 8a5ecfd commit ea0f526

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

README.rst renamed to README.txt

File renamed without changes.

docs/source/history.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Dev
66

77
- Add support for ksh. Thanks to Doug Latornell for doing the
88
research on what needed to be changed.
9-
- Switch to ``tempfile`` command for creating temporary hook files.
109
- Test import of virtualenvwrapper.hook_loader on startup and report
1110
the error in a way that should help the user figure out how to fix
1211
it (issue #33).
@@ -15,6 +14,8 @@ Dev
1514
created (issue #30).
1615
- Added hooks around :ref:`command-cpvirtualenv`.
1716
- Made deactivation more robust, especially under ksh.
17+
- Use Python's ``tempfile`` module for creating temporary filenames
18+
safely and portably.
1819

1920
2.0.2
2021

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import sys
1616

1717
try:
18-
long_description = open('README.rst', 'rt').read()
18+
long_description = open('README.txt', 'rt').read()
1919
except IOError:
2020
long_description = ''
2121

tests/test_cp.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ setUp () {
1515
}
1616

1717
tearDown() {
18+
if type deactivate >/dev/null 2>&1
19+
then
20+
deactivate
21+
fi
1822
rm -rf "$WORKON_HOME"
1923
}
2024

@@ -73,7 +77,6 @@ GLOBAL postcpvirtualenv"
7377
assertSame "$expected" "$output"
7478
rm -f "$WORKON_HOME/premkvirtualenv"
7579
rm -f "$WORKON_HOME/postmkvirtualenv"
76-
deactivate
7780
}
7881

7982
. "$test_dir/shunit2"

virtualenvwrapper.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,6 @@ workon () {
240240
virtualenvwrapper_original_deactivate=`typeset -f deactivate | sed 's/deactivate/virtualenv_deactivate/g'`
241241
eval "$virtualenvwrapper_original_deactivate"
242242
unset -f deactivate >/dev/null 2>&1
243-
# virtualenvwrapper_saved_deactivate=$(virtualenvwrapper_tempfile)
244-
# $(typeset -f deactivate | sed 's/deactivate/original_deactivate/g' > $virtualenvwrapper_saved_deactivate)
245-
# echo "original_deactivate" >> $virtualenvwrapper_saved_deactivate
246-
# echo "SAVED: \"$virtualenvwrapper_saved_deactivate\""
247-
# cat $virtualenvwrapper_saved_deactivate
248243

249244
# Replace the deactivate() function with a wrapper.
250245
eval 'deactivate () {
@@ -257,14 +252,16 @@ workon () {
257252
old_env=$(basename "$VIRTUAL_ENV")
258253
259254
# Call the original function.
260-
#source "$virtualenvwrapper_saved_deactivate"
261-
#rm -f "$virtualenvwrapper_saved_deactivate"
262-
virtualenv_deactivate
255+
virtualenv_deactivate $1
263256
264257
virtualenvwrapper_run_hook "post_deactivate" "$old_env"
265258
266-
# Remove this function
267-
unset -f deactivate
259+
if [ ! "$1" = "nondestructive" ]
260+
then
261+
# Remove this function
262+
unset -f virtualenv_deactivate
263+
unset -f deactivate
264+
fi
268265
269266
}'
270267

0 commit comments

Comments
 (0)