diff 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
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -501,7 +501,7 @@ def docopy(ui, repo, pats, opts, wlock):
     # otarget: ossep
     def copy(origsrc, abssrc, relsrc, otarget, exact):
         abstarget = util.canonpath(repo.root, cwd, otarget)
-        reltarget = util.pathto(repo.root, cwd, abstarget)
+        reltarget = repo.pathto(abstarget, cwd)
         prevsrc = targets.get(abstarget)
         src = repo.wjoin(abssrc)
         target = repo.wjoin(abstarget)
@@ -2484,12 +2484,11 @@ def status(ui, repo, *pats, **opts):
             format = "%s %%s%s" % (char, end)
 
         for f in changes:
-            ui.write(format % util.pathto(repo.root, cwd, f))
+            ui.write(format % repo.pathto(f, cwd))
             if ((all or opts.get('copies')) and not opts.get('no_status')):
                 copied = repo.dirstate.copied(f)
                 if copied:
-                    ui.write('  %s%s' % (util.pathto(repo.root, cwd, copied),
-                                         end))
+                    ui.write('  %s%s' % (repo.pathto(copied, cwd), end))
 
 def tag(ui, repo, name, rev_=None, **opts):
     """add a tag for the current or given revision