File: test-git-import

package info (click to toggle)
mercurial 1.6.4-1%2Bdeb6u1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 17,928 kB
  • ctags: 6,062
  • sloc: python: 44,238; sh: 20,985; tcl: 3,578; ansic: 2,557; lisp: 1,412; makefile: 176; xml: 15
file content (247 lines) | stat: -rwxr-xr-x 4,315 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

. $TESTDIR/helpers.sh

hg init a
cd a

echo % new file
hg import -d "1000000 0" -mnew - <<EOF
diff --git a/new b/new
new file mode 100644
index 0000000..7898192
--- /dev/null
+++ b/new
@@ -0,0 +1 @@
+a
EOF
hg tip -q

echo % new empty file
hg import -d "1000000 0" -mempty - <<EOF
diff --git a/empty b/empty
new file mode 100644
EOF
hg tip -q
hg locate empty

echo % chmod +x
hg import -d "1000000 0" -msetx - <<EOF
diff --git a/new b/new
old mode 100644
new mode 100755
EOF
hg tip -q

test -x new || echo failed

echo % copy
hg import -d "1000000 0" -mcopy - <<EOF
diff --git a/new b/copy
old mode 100755
new mode 100644
similarity index 100%
copy from new
copy to copy
diff --git a/new b/copyx
similarity index 100%
copy from new
copy to copyx
EOF
hg tip -q

if "$TESTDIR/hghave" -q execbit; then
    test -f copy -a ! -x copy || echo failed
    test -x copyx || echo failed
else
    test -f copy || echo failed
fi
cat copy
hg cat copy

echo % rename
hg import -d "1000000 0" -mrename - <<EOF
diff --git a/copy b/rename
similarity index 100%
rename from copy
rename to rename
EOF
hg tip -q

hg locate

echo % delete
hg import -d "1000000 0" -mdelete - <<EOF
diff --git a/copyx b/copyx
deleted file mode 100755
index 7898192..0000000
--- a/copyx
+++ /dev/null
@@ -1 +0,0 @@
-a
EOF
hg tip -q

hg locate
test -f copyx && echo failed || true

echo % regular diff
hg import -d "1000000 0" -mregular - <<EOF
diff --git a/rename b/rename
index 7898192..72e1fe3 100644
--- a/rename
+++ b/rename
@@ -1 +1,5 @@
 a
+a
+a
+a
+a
EOF
hg tip -q

echo % copy and modify
hg import -d "1000000 0" -mcopymod - <<EOF
diff --git a/rename b/copy2
similarity index 80%
copy from rename
copy to copy2
index 72e1fe3..b53c148 100644
--- a/rename
+++ b/copy2
@@ -1,5 +1,5 @@
 a
 a
-a
+b
 a
 a
EOF
hg tip -q

hg cat copy2

echo % rename and modify
hg import -d "1000000 0" -mrenamemod - <<EOF
diff --git a/copy2 b/rename2
similarity index 80%
rename from copy2
rename to rename2
index b53c148..8f81e29 100644
--- a/copy2
+++ b/rename2
@@ -1,5 +1,5 @@
 a
 a
 b
-a
+c
 a
EOF
hg tip -q

hg locate copy2
hg cat rename2

echo % one file renamed multiple times
hg import -d "1000000 0" -mmultirenames - <<EOF
diff --git a/rename2 b/rename3
rename from rename2
rename to rename3
diff --git a/rename2 b/rename3-2
rename from rename2
rename to rename3-2
EOF
hg tip -q
hg log -vr. --template '{rev} {files} / {file_copies}\n'

hg locate rename2 rename3 rename3-2
hg cat rename3
echo
hg cat rename3-2

echo foo > foo
hg add foo
hg ci -m 'add foo'
echo % binary files and regular patch hunks
hg import -d "1000000 0" -m binaryregular - <<EOF
diff --git a/binary b/binary
new file mode 100644
index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
GIT binary patch
literal 4
Lc\${NkU|;|M00aO5

diff --git a/foo b/foo2
rename from foo
rename to foo2
EOF
hg tip -q
cat foo2
hg manifest --debug | grep binary

echo % many binary files
hg import -d "1000000 0" -m multibinary - <<EOF
diff --git a/mbinary1 b/mbinary1
new file mode 100644
index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
GIT binary patch
literal 4
Lc\${NkU|;|M00aO5

diff --git a/mbinary2 b/mbinary2
new file mode 100644
index 0000000000000000000000000000000000000000..112363ac1917b417ffbd7f376ca786a1e5fa7490
GIT binary patch
literal 5
Mc\${NkU|\`?^000jF3jhEB

EOF
hg tip -q
hg manifest --debug | grep mbinary

echo % filenames with spaces
hg import -d "1000000 0" -m spaces - <<EOF
diff --git a/foo bar b/foo bar
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/foo bar	
@@ -0,0 +1 @@
+foo
EOF
hg tip -q
cat "foo bar"

echo % copy then modify the original file
hg import -d "1000000 0" -m copy-mod-orig - <<EOF
diff --git a/foo2 b/foo2
index 257cc56..fe08ec6 100644
--- a/foo2
+++ b/foo2
@@ -1 +1,2 @@
 foo
+new line
diff --git a/foo2 b/foo3
similarity index 100%
copy from foo2
copy to foo3
EOF
hg tip -q
cat foo3

echo % move text file and patch as binary
echo a > text2
hg ci -Am0
hg import -d "1000000 0" -m rename-as-binary - <<"EOF"
diff --git a/text2 b/binary2
rename from text2
rename to binary2
index 78981922613b2afb6025042ff6bd878ac1994e85..10efcb362e9f3b3420fcfbfc0e37f3dc16e29757
GIT binary patch
literal 5
Mc$`b*O5$Pw00T?_*Z=?k

EOF
cat binary2 | repr
hg st --copies --change .