comparison mercurial/commands.py @ 4525:78b6add1f966

Add dirstate.pathto and localrepo.pathto. Every time util.pathto is called, we have to pass the repo root and the repo cwd. dirstate.pathto is a simple convenience function that knows about the root and the cwd arguments. It's still possible to pass the cwd as an optimization. localrepo.pathto is a convenience function that just calls dirstate.pathto, just like localrepo.getcwd. dirstate.pathto becomes a single point that converts most (all?) paths from the internal representation to some OS-specific relative path for display purposes.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Fri, 08 Jun 2007 23:49:12 -0300
parents 6c58139f4eaa
children cbabc9ac7424
comparison
equal deleted inserted replaced
4524:6c58139f4eaa 4525:78b6add1f966
499 # abssrc: hgsep 499 # abssrc: hgsep
500 # relsrc: ossep 500 # relsrc: ossep
501 # otarget: ossep 501 # otarget: ossep
502 def copy(origsrc, abssrc, relsrc, otarget, exact): 502 def copy(origsrc, abssrc, relsrc, otarget, exact):
503 abstarget = util.canonpath(repo.root, cwd, otarget) 503 abstarget = util.canonpath(repo.root, cwd, otarget)
504 reltarget = util.pathto(repo.root, cwd, abstarget) 504 reltarget = repo.pathto(abstarget, cwd)
505 prevsrc = targets.get(abstarget) 505 prevsrc = targets.get(abstarget)
506 src = repo.wjoin(abssrc) 506 src = repo.wjoin(abssrc)
507 target = repo.wjoin(abstarget) 507 target = repo.wjoin(abstarget)
508 if prevsrc is not None: 508 if prevsrc is not None:
509 ui.warn(_('%s: not overwriting - %s collides with %s\n') % 509 ui.warn(_('%s: not overwriting - %s collides with %s\n') %
2482 format = "%%s%s" % end 2482 format = "%%s%s" % end
2483 else: 2483 else:
2484 format = "%s %%s%s" % (char, end) 2484 format = "%s %%s%s" % (char, end)
2485 2485
2486 for f in changes: 2486 for f in changes:
2487 ui.write(format % util.pathto(repo.root, cwd, f)) 2487 ui.write(format % repo.pathto(f, cwd))
2488 if ((all or opts.get('copies')) and not opts.get('no_status')): 2488 if ((all or opts.get('copies')) and not opts.get('no_status')):
2489 copied = repo.dirstate.copied(f) 2489 copied = repo.dirstate.copied(f)
2490 if copied: 2490 if copied:
2491 ui.write(' %s%s' % (util.pathto(repo.root, cwd, copied), 2491 ui.write(' %s%s' % (repo.pathto(copied, cwd), end))
2492 end))
2493 2492
2494 def tag(ui, repo, name, rev_=None, **opts): 2493 def tag(ui, repo, name, rev_=None, **opts):
2495 """add a tag for the current or given revision 2494 """add a tag for the current or given revision
2496 2495
2497 Name a particular revision using <name>. 2496 Name a particular revision using <name>.