This instance will be upgraded to Heptapod 0.31.0rc on 2022-05-19 at 11:00 UTC+2 (a few minutes of down time)

test-symlinks.t 5.02 KB
Newer Older
1
#require symlink
Nicolas Dumazet's avatar
Nicolas Dumazet committed
2

3
#testcases dirstate-v1 dirstate-v2
4

5
6
7
8
9
#if dirstate-v2
  $ echo '[format]' >> $HGRCPATH
  $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
#endif

10
== tests added in 0.7 ==
Nicolas Dumazet's avatar
Nicolas Dumazet committed
11

12
  $ hg init test-symlinks-0.7; cd test-symlinks-0.7;
13
14
15
  $ touch foo; ln -s foo bar; ln -s nonexistent baz

import with add and addremove -- symlink walking should _not_ screwup.
Nicolas Dumazet's avatar
Nicolas Dumazet committed
16

17
18
19
20
21
  $ hg add
  adding bar
  adding baz
  adding foo
  $ hg forget bar baz foo
Nicolas Dumazet's avatar
Nicolas Dumazet committed
22
23
  $ hg addremove
  adding bar
24
  adding baz
Nicolas Dumazet's avatar
Nicolas Dumazet committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  adding foo

commit -- the symlink should _not_ appear added to dir state

  $ hg commit -m 'initial'

  $ touch bomb

again, symlink should _not_ show up on dir state

  $ hg addremove
  adding bomb

Assert screamed here before, should go by without consequence

  $ hg commit -m 'is there a bug?'
41
  $ cd ..
Nicolas Dumazet's avatar
Nicolas Dumazet committed
42

43
44
45

== fifo & ignore ==

Nicolas Dumazet's avatar
Nicolas Dumazet committed
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  $ hg init test; cd test;

  $ mkdir dir
  $ touch a.c dir/a.o dir/b.o

test what happens if we want to trick hg

  $ hg commit -A -m 0
  adding a.c
  adding dir/a.o
  adding dir/b.o
  $ echo "relglob:*.o" > .hgignore
  $ rm a.c
  $ rm dir/a.o
  $ rm dir/b.o
  $ mkdir dir/a.o
timeless's avatar
timeless committed
62
  $ ln -s nonexistent dir/b.o
Nicolas Dumazet's avatar
Nicolas Dumazet committed
63
64
65
66
67
68
69
70
71
72
73
74
  $ mkfifo a.c

it should show a.c, dir/a.o and dir/b.o deleted

  $ hg status
  M dir/b.o
  ! a.c
  ! dir/a.o
  ? .hgignore
  $ hg status a.c
  a.c: unsupported file type (type is fifo)
  ! a.c
75
76
77
78
  $ cd ..


== symlinks from outside the tree ==
Nicolas Dumazet's avatar
Nicolas Dumazet committed
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

test absolute path through symlink outside repo

  $ p=`pwd`
  $ hg init x
  $ ln -s x y
  $ cd x
  $ touch f
  $ hg add f
  $ hg status "$p"/y/f
  A f

try symlink outside repo to file inside

  $ ln -s x/f ../z

this should fail

  $ hg status ../z && { echo hg mistakenly exited with status 0; exit 1; } || :
98
  abort: ../z not under root '$TESTTMP/x'
99
  $ cd ..
Nicolas Dumazet's avatar
Nicolas Dumazet committed
100

101
102
103

== cloning symlinks ==
  $ hg init clone; cd clone;
Nicolas Dumazet's avatar
Nicolas Dumazet committed
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119

try cloning symlink in a subdir
1. commit a symlink

  $ mkdir -p a/b/c
  $ cd a/b/c
  $ ln -s /path/to/symlink/source demo
  $ cd ../../..
  $ hg stat
  ? a/b/c/demo
  $ hg commit -A -m 'add symlink in a/b/c subdir'
  adding a/b/c/demo

2. clone it

  $ cd ..
120
  $ hg clone clone clonedest
Nicolas Dumazet's avatar
Nicolas Dumazet committed
121
122
123
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

124
125
126

== symlink and git diffs ==

Nicolas Dumazet's avatar
Nicolas Dumazet committed
127
128
git symlink diff

129
  $ cd clonedest
Nicolas Dumazet's avatar
Nicolas Dumazet committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
  $ hg diff --git -r null:tip
  diff --git a/a/b/c/demo b/a/b/c/demo
  new file mode 120000
  --- /dev/null
  +++ b/a/b/c/demo
  @@ -0,0 +1,1 @@
  +/path/to/symlink/source
  \ No newline at end of file
  $ hg export --git tip > ../sl.diff

import git symlink diff

  $ hg rm a/b/c/demo
  $ hg commit -m'remove link'
  $ hg import ../sl.diff
  applying ../sl.diff
  $ hg diff --git -r 1:tip
  diff --git a/a/b/c/demo b/a/b/c/demo
  new file mode 120000
  --- /dev/null
  +++ b/a/b/c/demo
  @@ -0,0 +1,1 @@
  +/path/to/symlink/source
  \ No newline at end of file
154
155
156
157
158
159
160
161
162
163
164

== symlinks and addremove ==

directory moved and symlinked

  $ mkdir foo
  $ touch foo/a
  $ hg ci -Ama
  adding foo/a
  $ mv foo bar
  $ ln -s bar foo
165
166
167
168
  $ hg status
  ! foo/a
  ? bar/a
  ? foo
169
170
171
172
173
174
175

now addremove should remove old files

  $ hg addremove
  adding bar/a
  adding foo
  removing foo/a
176
177
178
179
180
181
182
183
184

commit and update back

  $ hg ci -mb
  $ hg up '.^'
  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ hg up tip
  2 files updated, 0 files merged, 1 files removed, 0 files unresolved

185
186
187
188
189
190
191
192
193
194
195
196
  $ cd ..

== root of repository is symlinked ==

  $ hg init root
  $ ln -s root link
  $ cd root
  $ echo foo > foo
  $ hg status
  ? foo
  $ hg status ../link
  ? foo
197
198
199
  $ hg add foo
  $ hg cp foo "$TESTTMP/link/bar"
  foo has not been committed yet, so no copy data will be stored for bar.
200
201
202
203
204
205
206
207
  $ cd ..


  $ hg init b
  $ cd b
  $ ln -s nothing dangling
  $ hg commit -m 'commit symlink without adding' dangling
  abort: dangling: file not tracked!
208
  [10]
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
  $ hg add dangling
  $ hg commit -m 'add symlink'

  $ hg tip -v
  changeset:   0:cabd88b706fc
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  files:       dangling
  description:
  add symlink
  
  
  $ hg manifest --debug
  2564acbe54bbbedfbf608479340b359f04597f80 644 @ dangling
224
  $ readlink.py dangling
225
226
227
228
229
  dangling -> nothing

  $ rm dangling
  $ ln -s void dangling
  $ hg commit -m 'change symlink'
230
  $ readlink.py dangling
231
232
233
234
235
236
237
  dangling -> void


modifying link

  $ rm dangling
  $ ln -s empty dangling
238
  $ readlink.py dangling
239
240
241
242
243
244
245
  dangling -> empty


reverting to rev 0:

  $ hg revert -r 0 -a
  reverting dangling
246
  $ readlink.py dangling
247
248
249
250
251
  dangling -> nothing


backups:

252
  $ readlink.py *.orig
253
254
255
256
257
258
259
260
261
262
263
264
  dangling.orig -> empty
  $ rm *.orig
  $ hg up -C
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

copies

  $ hg cp -v dangling dangling2
  copying dangling to dangling2
  $ hg st -Cmard
  A dangling2
    dangling
265
  $ readlink.py dangling dangling2
266
267
268
269
  dangling -> void
  dangling2 -> void


270
Issue995: hg copy -A incorrectly handles symbolic links
271
272
273
274
275
276
277
278
279
280
281

  $ hg up -C
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ mkdir dir
  $ ln -s dir dirlink
  $ hg ci -qAm 'add dirlink'
  $ mkdir newdir
  $ mv dir newdir/dir
  $ mv dirlink newdir/dirlink
  $ hg mv -A dirlink newdir/dirlink

kiilerix's avatar
kiilerix committed
282
  $ cd ..