1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
|
Tests for experimental.removeemptydirs
$ cat >> pwd.py << EOF
> import os
> try:
> print(os.getcwd())
> except OSError:
> print("<directory is no longer accessible>")
> EOF
$ NO_RM=--config=experimental.removeemptydirs=0
$ DO_RM=--config=experimental.removeemptydirs=1
$ isdir() { if [ -d $1 ]; then echo yes; else echo no; fi }
$ isfile() { if [ -f $1 ]; then echo yes; else echo no; fi }
`hg rm` of the last file in a directory:
$ hg init hgrm
$ cd hgrm
$ mkdir somedir
$ echo hi > somedir/foo
$ hg ci -qAm foo
$ isdir somedir
yes
$ hg rm somedir/foo
$ isdir somedir
no
$ hg revert -qa
$ isdir somedir
yes
$ hg $NO_RM rm somedir/foo
$ isdir somedir
yes
$ ls somedir
$ cd $TESTTMP
`hg mv` of the last file in a directory:
$ hg init hgmv
$ cd hgmv
$ mkdir somedir
$ mkdir destdir
$ echo hi > somedir/foo
$ hg ci -qAm foo
$ isdir somedir
yes
$ hg mv somedir/foo destdir/foo
$ isdir somedir
no
$ hg revert -qa
(revert doesn't get rid of destdir/foo?)
$ rm destdir/foo
$ isdir somedir
yes
$ hg $NO_RM mv somedir/foo destdir/foo
$ isdir somedir
yes
$ ls somedir
$ cd $TESTTMP
Updating to a commit that doesn't have the directory:
$ hg init hgupdate
$ cd hgupdate
$ echo hi > r0
$ hg ci -qAm r0
$ mkdir somedir
$ echo hi > somedir/foo
$ hg ci -qAm r1
$ isdir somedir
yes
$ hg co -q -r ".^"
$ isdir somedir
no
$ hg co -q tip
$ isdir somedir
yes
$ hg $NO_RM co -q -r ".^"
$ isdir somedir
yes
$ ls somedir
$ cd $TESTTMP
Rebasing across a commit that doesn't have the directory, from inside the
directory:
$ hg init hgrebase
$ cd hgrebase
$ echo hi > r0
$ hg ci -qAm r0
$ mkdir somedir
$ echo hi > somedir/foo
$ hg ci -qAm first_rebase_source
$ hg $NO_RM co -q -r ".^"
$ echo hi > somedir/bar
$ hg ci -qAm first_rebase_dest
$ hg $NO_RM co -q -r ".^"
$ echo hi > somedir/baz
$ hg ci -qAm second_rebase_dest
$ hg co -qr 'desc(first_rebase_source)'
$ cd $TESTTMP/hgrebase/somedir
$ hg --config extensions.rebase= rebase -qr . -d 'desc(first_rebase_dest)'
current directory was removed (rmcwd !)
(consider changing to repo root: $TESTTMP/hgrebase) (rmcwd !)
$ cd $TESTTMP/hgrebase/somedir
(The current node is the rebased first_rebase_source on top of
first_rebase_dest)
This should not output anything about current directory being removed:
$ hg $NO_RM --config extensions.rebase= rebase -qr . -d 'desc(second_rebase_dest)'
$ cd $TESTTMP
Histediting across a commit that doesn't have the directory, from inside the
directory (reordering nodes):
A directory with the right pass exists at the end of the run, but it is a
different directory than the current one.
Windows is not affected
$ hg init hghistedit
$ cd hghistedit
$ echo hi > r0
$ hg ci -qAm r0
$ echo hi > r1
$ hg ci -qAm r1
$ echo hi > r2
$ hg ci -qAm r2
$ mkdir somedir
$ echo hi > somedir/foo
$ hg ci -qAm migrating_revision
$ cat > histedit_commands <<EOF
> pick 89079fab8aee 0 r0
> pick e6d271df3142 1 r1
> pick 89e25aa83f0f 3 migrating_revision
> pick b550aa12d873 2 r2
> EOF
$ cd $TESTTMP/hghistedit/somedir
$ hg $DO_RM --config extensions.histedit= histedit -q --commands ../histedit_commands
current directory was removed (no-windows !)
(consider changing to repo root: $TESTTMP/hghistedit) (no-windows !)
$ ls -A $TESTTMP/hghistedit/
.hg
histedit_commands
r0
r1
r2
somedir
#if windows
$ "$PYTHON" "$TESTTMP/pwd.py"
$TESTTMP/hghistedit/somedir
$ ls -A $TESTTMP/hghistedit/somedir
foo
$ ls -A
foo
#else
$ echo ${PWD} # no-pwd-check
$TESTTMP/hghistedit/somedir
$ "$PYTHON" "$TESTTMP/pwd.py"
<directory is no longer accessible>
$ ls -A $TESTTMP/hghistedit/somedir
foo
$ ls -A || true
ls: .: $ENOENT$ (?)
#endif
Get out of the doomed directory
$ cd $TESTTMP/hghistedit
chdir: error retrieving current directory: getcwd: cannot access parent directories: $ENOENT$ (?)
$ hg files --rev . | grep somedir/
somedir/foo
$ cat > histedit_commands <<EOF
> pick 89079fab8aee 0 r0
> pick 7c7a22c6009f 3 migrating_revision
> pick e6d271df3142 1 r1
> pick 40a53c2d4276 2 r2
> EOF
$ cd $TESTTMP/hghistedit/somedir
$ hg $NO_RM --config extensions.histedit= histedit -q --commands ../histedit_commands
Regardless of system, we should always get a 'yes' here.
$ isfile foo
yes
$ cd $TESTTMP
This is essentially the exact test from issue5826, just cleaned up a little:
$ hg init issue5826_withrm
$ cd issue5826_withrm
Let's only turn this on for this repo so that we don't contaminate later tests.
$ cat >> .hg/hgrc <<EOF
> [extensions]
> histedit =
> EOF
Commit three revisions that each create a directory:
$ mkdir foo
$ touch foo/bar
$ hg commit -qAm "add foo"
$ mkdir bar
$ touch bar/bar
$ hg commit -qAm "add bar"
$ mkdir baz
$ touch baz/bar
$ hg commit -qAm "add baz"
Enter the first directory:
$ cd foo
Histedit doing 'pick, pick, fold':
#if rmcwd
$ hg histedit --commands - <<EOF
> pick 6274c77c93c3 1 add bar
> pick ff70a87b588f 0 add foo
> fold 9992bb0ac0db 2 add baz
> EOF
current directory was removed
(consider changing to repo root: $TESTTMP/issue5826_withrm)
abort: $ENOENT$
[255]
Go back to the repo root after losing it as part of that operation:
$ cd $TESTTMP/issue5826_withrm
Note the lack of a non-zero exit code from this function - it exits
successfully, but doesn't really do anything.
$ hg histedit --continue
9992bb0ac0db: cannot fold - working copy is not a descendant of previous commit 5c806432464a
saved backup bundle to $TESTTMP/issue5826_withrm/.hg/strip-backup/ff70a87b588f-e94f9789-histedit.hg
$ hg log -T '{rev}:{node|short} {desc}\n'
2:94e3f9fae1d6 fold-temp-revision 9992bb0ac0db
1:5c806432464a add foo
0:d17db4b0303a add bar
#else
$ cd $TESTTMP/issue5826_withrm
$ hg histedit --commands - <<EOF
> pick 6274c77c93c3 1 add bar
> pick ff70a87b588f 0 add foo
> fold 9992bb0ac0db 2 add baz
> EOF
saved backup bundle to $TESTTMP/issue5826_withrm/.hg/strip-backup/5c806432464a-cd4c8d86-histedit.hg
$ hg log -T '{rev}:{node|short} {desc}\n'
1:b9eddaa97cbc add foo
***
add baz
0:d17db4b0303a add bar
#endif
Now test that again with experimental.removeemptydirs=false:
$ hg init issue5826_norm
$ cd issue5826_norm
Let's only turn this on for this repo so that we don't contaminate later tests.
$ cat >> .hg/hgrc <<EOF
> [extensions]
> histedit =
> [experimental]
> removeemptydirs = false
> EOF
Commit three revisions that each create a directory:
$ mkdir foo
$ touch foo/bar
$ hg commit -qAm "add foo"
$ mkdir bar
$ touch bar/bar
$ hg commit -qAm "add bar"
$ mkdir baz
$ touch baz/bar
$ hg commit -qAm "add baz"
Enter the first directory:
$ cd foo
Histedit doing 'pick, pick, fold':
$ hg histedit --commands - <<EOF
> pick 6274c77c93c3 1 add bar
> pick ff70a87b588f 0 add foo
> fold 9992bb0ac0db 2 add baz
> EOF
saved backup bundle to $TESTTMP/issue5826_withrm/issue5826_norm/.hg/strip-backup/5c806432464a-cd4c8d86-histedit.hg
Note the lack of a 'cd' being necessary here, and we don't need to 'histedit
--continue'
$ hg log -T '{rev}:{node|short} {desc}\n'
1:b9eddaa97cbc add foo
***
add baz
0:d17db4b0303a add bar
$ cd $TESTTMP
|