##// END OF EJS Templates
copy: handle rename internally...
Matt Mackall -
r5610:2493a478 default
parent child Browse files
Show More
@@ -286,13 +286,12 b' def addremove(repo, pats=[], opts={}, dr'
286 286 if not dry_run:
287 287 repo.copy(old, new)
288 288
289 def copy(ui, repo, pats, opts):
289 def copy(ui, repo, pats, opts, rename=False):
290 290 # called with the repo lock held
291 291 #
292 292 # hgsep => pathname that uses "/" to separate directories
293 293 # ossep => pathname that uses os.sep to separate directories
294 294 cwd = repo.getcwd()
295 copied = []
296 295 targets = {}
297 296 after = opts.get("after")
298 297 dryrun = opts.get("dry_run")
@@ -359,7 +358,8 b' def copy(ui, repo, pats, opts):'
359 358 return True # report a failure
360 359
361 360 if ui.verbose or not exact:
362 ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
361 action = rename and "moving" or "copying"
362 ui.status(_('%s %s to %s\n') % (action, relsrc, reltarget))
363 363
364 364 targets[abstarget] = abssrc
365 365
@@ -378,7 +378,9 b' def copy(ui, repo, pats, opts):'
378 378 repo.add([abstarget])
379 379 elif not dryrun:
380 380 repo.copy(origsrc, abstarget)
381 copied.append((abssrc, relsrc, exact))
381
382 if rename and not dryrun:
383 repo.remove([abssrc], True)
382 384
383 385 # pat: ossep
384 386 # dest ossep
@@ -482,7 +484,7 b' def copy(ui, repo, pats, opts):'
482 484 if errors:
483 485 ui.warn(_('(consider using --after)\n'))
484 486
485 return errors, copied
487 return errors
486 488
487 489 def service(opts, parentfn=None, initfn=None, runfn=None):
488 490 '''Run a command as a service.'''
@@ -454,10 +454,9 b' def copy(ui, repo, *pats, **opts):'
454 454 """
455 455 wlock = repo.wlock(False)
456 456 try:
457 errs, copied = cmdutil.copy(ui, repo, pats, opts)
457 return cmdutil.copy(ui, repo, pats, opts)
458 458 finally:
459 459 del wlock
460 return errs
461 460
462 461 def debugancestor(ui, index, rev1, rev2):
463 462 """find the ancestor revision of two revisions in a given index"""
@@ -2062,15 +2061,7 b' def rename(ui, repo, *pats, **opts):'
2062 2061 """
2063 2062 wlock = repo.wlock(False)
2064 2063 try:
2065 errs, copied = cmdutil.copy(ui, repo, pats, opts)
2066 names = []
2067 for abs, rel, exact in copied:
2068 if ui.verbose or not exact:
2069 ui.status(_('removing %s\n') % rel)
2070 names.append(abs)
2071 if not opts.get('dry_run'):
2072 repo.remove(names, True)
2073 return errs
2064 return cmdutil.copy(ui, repo, pats, opts, rename=True)
2074 2065 finally:
2075 2066 del wlock
2076 2067
@@ -1,6 +1,5 b''
1 1 adding src/a.c
2 copying src/a.c to source/a.c
3 removing src/a.c
2 moving src/a.c to source/a.c
4 3 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
5 4 ? src/a.o
6 5 merging src/a.c and source/a.c
@@ -1,10 +1,8 b''
1 1 adding a/a
2 2 adding a/b
3 3 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
4 copying a/a to b/a
5 copying a/b to b/b
6 removing a/a
7 removing a/b
4 moving a/a to b/a
5 moving a/b to b/b
8 6 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
9 7 resolving manifests
10 8 overwrite None partial False
@@ -1,7 +1,6 b''
1 1 adding a/f
2 2 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
3 copying a/f to b/f
4 removing a/f
3 moving a/f to b/f
5 4 adding a/aa/g
6 5 pulling from ../r2
7 6 searching for changes
@@ -29,14 +29,10 b' A d1/d11/e'
29 29 R d2/b
30 30 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
31 31 # rename directory d1 as d3
32 copying d1/a to d3/a
33 copying d1/b to d3/b
34 copying d1/ba to d3/ba
35 copying d1/d11/a1 to d3/d11/a1
36 removing d1/a
37 removing d1/b
38 removing d1/ba
39 removing d1/d11/a1
32 moving d1/a to d3/a
33 moving d1/b to d3/b
34 moving d1/ba to d3/ba
35 moving d1/d11/a1 to d3/d11/a1
40 36 A d3/a
41 37 d1/a
42 38 A d3/b
@@ -51,14 +47,10 b' R d1/ba'
51 47 R d1/d11/a1
52 48 4 files updated, 0 files merged, 4 files removed, 0 files unresolved
53 49 # rename --after directory d1 as d3
54 copying d1/a to d3/a
55 copying d1/b to d3/b
56 copying d1/ba to d3/ba
57 copying d1/d11/a1 to d3/d11/a1
58 removing d1/a
59 removing d1/b
60 removing d1/ba
61 removing d1/d11/a1
50 moving d1/a to d3/a
51 moving d1/b to d3/b
52 moving d1/ba to d3/ba
53 moving d1/d11/a1 to d3/d11/a1
62 54 A d3/a
63 55 d1/a
64 56 A d3/b
@@ -73,37 +65,29 b' R d1/ba'
73 65 R d1/d11/a1
74 66 4 files updated, 0 files merged, 4 files removed, 0 files unresolved
75 67 # move a directory using a relative path
76 copying ../d1/d11/a1 to d3/d11/a1
77 removing ../d1/d11/a1
68 moving ../d1/d11/a1 to d3/d11/a1
78 69 A d2/d3/d11/a1
79 70 d1/d11/a1
80 71 R d1/d11/a1
81 72 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
82 73 # move --after a directory using a relative path
83 copying ../d1/d11/a1 to d3/d11/a1
84 removing ../d1/d11/a1
74 moving ../d1/d11/a1 to d3/d11/a1
85 75 A d2/d3/d11/a1
86 76 d1/d11/a1
87 77 R d1/d11/a1
88 78 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
89 79 # move directory d1/d11 to an existing directory d2 (removes empty d1)
90 copying d1/d11/a1 to d2/d11/a1
91 removing d1/d11/a1
80 moving d1/d11/a1 to d2/d11/a1
92 81 A d2/d11/a1
93 82 d1/d11/a1
94 83 R d1/d11/a1
95 84 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
96 85 # move directories d1 and d2 to a new directory d3
97 copying d1/a to d3/d1/a
98 copying d1/b to d3/d1/b
99 copying d1/ba to d3/d1/ba
100 copying d1/d11/a1 to d3/d1/d11/a1
101 copying d2/b to d3/d2/b
102 removing d1/a
103 removing d1/b
104 removing d1/ba
105 removing d1/d11/a1
106 removing d2/b
86 moving d1/a to d3/d1/a
87 moving d1/b to d3/d1/b
88 moving d1/ba to d3/d1/ba
89 moving d1/d11/a1 to d3/d1/d11/a1
90 moving d2/b to d3/d2/b
107 91 A d3/d1/a
108 92 d1/a
109 93 A d3/d1/b
@@ -121,16 +105,11 b' R d1/d11/a1'
121 105 R d2/b
122 106 5 files updated, 0 files merged, 5 files removed, 0 files unresolved
123 107 # move --after directories d1 and d2 to a new directory d3
124 copying d1/a to d3/d1/a
125 copying d1/b to d3/d1/b
126 copying d1/ba to d3/d1/ba
127 copying d1/d11/a1 to d3/d1/d11/a1
128 copying d2/b to d3/d2/b
129 removing d1/a
130 removing d1/b
131 removing d1/ba
132 removing d1/d11/a1
133 removing d2/b
108 moving d1/a to d3/d1/a
109 moving d1/b to d3/d1/b
110 moving d1/ba to d3/d1/ba
111 moving d1/d11/a1 to d3/d1/d11/a1
112 moving d2/b to d3/d2/b
134 113 A d3/d1/a
135 114 d1/a
136 115 A d3/d1/b
@@ -150,8 +129,7 b' 5 files updated, 0 files merged, 5 files'
150 129 # move everything under directory d1 to existing directory d2, do not
151 130 # overwrite existing files (d2/b)
152 131 d2/b: not overwriting - file exists
153 copying d1/d11/a1 to d2/d11/a1
154 removing d1/d11/a1
132 moving d1/d11/a1 to d2/d11/a1
155 133 A d2/a
156 134 d1/a
157 135 A d2/ba
@@ -173,14 +151,10 b' 0 files updated, 0 files merged, 0 files'
173 151 # directory
174 152 abort: with multiple sources, destination must be an existing directory
175 153 # move every file under d1 to d2/d21 (glob)
176 copying d1/a to d2/d21/a
177 copying d1/b to d2/d21/b
178 copying d1/ba to d2/d21/ba
179 copying d1/d11/a1 to d2/d21/a1
180 removing d1/a
181 removing d1/b
182 removing d1/ba
183 removing d1/d11/a1
154 moving d1/a to d2/d21/a
155 moving d1/b to d2/d21/b
156 moving d1/ba to d2/d21/ba
157 moving d1/d11/a1 to d2/d21/a1
184 158 A d2/d21/a
185 159 d1/a
186 160 A d2/d21/a1
@@ -195,10 +169,8 b' R d1/ba'
195 169 R d1/d11/a1
196 170 4 files updated, 0 files merged, 4 files removed, 0 files unresolved
197 171 # move --after some files under d1 to d2/d21 (glob)
198 copying d1/a to d2/d21/a
199 copying d1/d11/a1 to d2/d21/a1
200 removing d1/a
201 removing d1/d11/a1
172 moving d1/a to d2/d21/a
173 moving d1/d11/a1 to d2/d21/a1
202 174 A d2/d21/a
203 175 d1/a
204 176 A d2/d21/a1
@@ -207,10 +179,8 b' R d1/a'
207 179 R d1/d11/a1
208 180 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
209 181 # move every file under d1 starting with an 'a' to d2/d21 (regexp)
210 copying d1/a to d2/d21/a
211 copying d1/d11/a1 to d2/d21/a1
212 removing d1/a
213 removing d1/d11/a1
182 moving d1/a to d2/d21/a
183 moving d1/d11/a1 to d2/d21/a1
214 184 A d2/d21/a
215 185 d1/a
216 186 A d2/d21/a1
@@ -233,9 +203,8 b' A d1/ca'
233 203 R d1/ba
234 204 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
235 205 # do not copy more than one source file to the same destination file
236 copying d1/d11/a1 to d3/d11/a1
206 moving d1/d11/a1 to d3/d11/a1
237 207 d3/b: not overwriting - d2/b collides with d1/b
238 removing d1/d11/a1
239 208 A d3/a
240 209 d1/a
241 210 A d3/b
@@ -250,14 +219,10 b' R d1/ba'
250 219 R d1/d11/a1
251 220 4 files updated, 0 files merged, 4 files removed, 0 files unresolved
252 221 # move a whole subtree with "hg rename ."
253 copying a to ../d3/d1/a
254 copying b to ../d3/d1/b
255 copying ba to ../d3/d1/ba
256 copying d11/a1 to ../d3/d1/d11/a1
257 removing a
258 removing b
259 removing ba
260 removing d11/a1
222 moving a to ../d3/d1/a
223 moving b to ../d3/d1/b
224 moving ba to ../d3/d1/ba
225 moving d11/a1 to ../d3/d1/d11/a1
261 226 A d3/d1/a
262 227 d1/a
263 228 A d3/d1/b
@@ -272,14 +237,10 b' R d1/ba'
272 237 R d1/d11/a1
273 238 4 files updated, 0 files merged, 4 files removed, 0 files unresolved
274 239 # move a whole subtree with "hg rename --after ."
275 copying a to ../d3/a
276 copying b to ../d3/b
277 copying ba to ../d3/ba
278 copying d11/a1 to ../d3/d11/a1
279 removing a
280 removing b
281 removing ba
282 removing d11/a1
240 moving a to ../d3/a
241 moving b to ../d3/b
242 moving ba to ../d3/ba
243 moving d11/a1 to ../d3/d11/a1
283 244 A d3/a
284 245 d1/a
285 246 A d3/b
@@ -294,14 +255,10 b' R d1/ba'
294 255 R d1/d11/a1
295 256 4 files updated, 0 files merged, 4 files removed, 0 files unresolved
296 257 # move the parent tree with "hg rename .."
297 copying ../a to ../../d3/a
298 copying ../b to ../../d3/b
299 copying ../ba to ../../d3/ba
300 copying a1 to ../../d3/d11/a1
301 removing ../a
302 removing ../b
303 removing ../ba
304 removing a1
258 moving ../a to ../../d3/a
259 moving ../b to ../../d3/b
260 moving ../ba to ../../d3/ba
261 moving a1 to ../../d3/d11/a1
305 262 A d3/a
306 263 d1/a
307 264 A d3/b
@@ -316,12 +273,9 b' R d1/ba'
316 273 R d1/d11/a1
317 274 4 files updated, 0 files merged, 4 files removed, 0 files unresolved
318 275 # skip removed files
319 copying d1/a to d3/a
320 copying d1/ba to d3/ba
321 copying d1/d11/a1 to d3/d11/a1
322 removing d1/a
323 removing d1/ba
324 removing d1/d11/a1
276 moving d1/a to d3/a
277 moving d1/ba to d3/ba
278 moving d1/d11/a1 to d3/d11/a1
325 279 A d3/a
326 280 d1/a
327 281 A d3/ba
General Comments 0
You need to be logged in to leave comments. Login now