equal
deleted
inserted
replaced
284 '(%d%% similar)\n') % |
284 '(%d%% similar)\n') % |
285 (oldrel, newrel, score * 100)) |
285 (oldrel, newrel, score * 100)) |
286 if not dry_run: |
286 if not dry_run: |
287 repo.copy(old, new) |
287 repo.copy(old, new) |
288 |
288 |
289 def copy(ui, repo, pats, opts): |
289 def copy(ui, repo, pats, opts, rename=False): |
290 # called with the repo lock held |
290 # called with the repo lock held |
291 # |
291 # |
292 # hgsep => pathname that uses "/" to separate directories |
292 # hgsep => pathname that uses "/" to separate directories |
293 # ossep => pathname that uses os.sep to separate directories |
293 # ossep => pathname that uses os.sep to separate directories |
294 cwd = repo.getcwd() |
294 cwd = repo.getcwd() |
295 copied = [] |
|
296 targets = {} |
295 targets = {} |
297 after = opts.get("after") |
296 after = opts.get("after") |
298 dryrun = opts.get("dry_run") |
297 dryrun = opts.get("dry_run") |
299 |
298 |
300 def walkpat(pat): |
299 def walkpat(pat): |
357 ui.warn(_('%s: cannot copy - %s\n') % |
356 ui.warn(_('%s: cannot copy - %s\n') % |
358 (relsrc, inst.strerror)) |
357 (relsrc, inst.strerror)) |
359 return True # report a failure |
358 return True # report a failure |
360 |
359 |
361 if ui.verbose or not exact: |
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 targets[abstarget] = abssrc |
364 targets[abstarget] = abssrc |
365 |
365 |
366 # fix up dirstate |
366 # fix up dirstate |
367 origsrc = repo.dirstate.copied(abssrc) or abssrc |
367 origsrc = repo.dirstate.copied(abssrc) or abssrc |
376 % (repo.pathto(origsrc, cwd), reltarget)) |
376 % (repo.pathto(origsrc, cwd), reltarget)) |
377 if abstarget not in repo.dirstate and not dryrun: |
377 if abstarget not in repo.dirstate and not dryrun: |
378 repo.add([abstarget]) |
378 repo.add([abstarget]) |
379 elif not dryrun: |
379 elif not dryrun: |
380 repo.copy(origsrc, abstarget) |
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 # pat: ossep |
385 # pat: ossep |
384 # dest ossep |
386 # dest ossep |
385 # srcs: list of (hgsep, hgsep, ossep, bool) |
387 # srcs: list of (hgsep, hgsep, ossep, bool) |
386 # return: function that takes hgsep and returns ossep |
388 # return: function that takes hgsep and returns ossep |
480 errors += 1 |
482 errors += 1 |
481 |
483 |
482 if errors: |
484 if errors: |
483 ui.warn(_('(consider using --after)\n')) |
485 ui.warn(_('(consider using --after)\n')) |
484 |
486 |
485 return errors, copied |
487 return errors |
486 |
488 |
487 def service(opts, parentfn=None, initfn=None, runfn=None): |
489 def service(opts, parentfn=None, initfn=None, runfn=None): |
488 '''Run a command as a service.''' |
490 '''Run a command as a service.''' |
489 |
491 |
490 if opts['daemon'] and not opts['daemon_pipefds']: |
492 if opts['daemon'] and not opts['daemon_pipefds']: |