##// END OF EJS Templates
Add dirstate.pathto and localrepo.pathto....
Alexis S. L. Carvalho -
r4525:78b6add1 default
parent child Browse files
Show More
@@ -145,9 +145,10 b' def walk(repo, pats=[], opts={}, node=No'
145 145 files, matchfn, anypats = matchpats(repo, pats, opts, globbed=globbed,
146 146 default=default)
147 147 exact = dict.fromkeys(files)
148 cwd = repo.getcwd()
148 149 for src, fn in repo.walk(node=node, files=files, match=matchfn,
149 150 badmatch=badmatch):
150 yield src, fn, util.pathto(repo.root, repo.getcwd(), fn), fn in exact
151 yield src, fn, repo.pathto(fn, cwd), fn in exact
151 152
152 153 def findrenames(repo, added=None, removed=None, threshold=0.5):
153 154 '''find renamed files -- yields (before, after, score) tuples'''
@@ -501,7 +501,7 b' def docopy(ui, repo, pats, opts, wlock):'
501 501 # otarget: ossep
502 502 def copy(origsrc, abssrc, relsrc, otarget, exact):
503 503 abstarget = util.canonpath(repo.root, cwd, otarget)
504 reltarget = util.pathto(repo.root, cwd, abstarget)
504 reltarget = repo.pathto(abstarget, cwd)
505 505 prevsrc = targets.get(abstarget)
506 506 src = repo.wjoin(abssrc)
507 507 target = repo.wjoin(abstarget)
@@ -2484,12 +2484,11 b' def status(ui, repo, *pats, **opts):'
2484 2484 format = "%s %%s%s" % (char, end)
2485 2485
2486 2486 for f in changes:
2487 ui.write(format % util.pathto(repo.root, cwd, f))
2487 ui.write(format % repo.pathto(f, cwd))
2488 2488 if ((all or opts.get('copies')) and not opts.get('no_status')):
2489 2489 copied = repo.dirstate.copied(f)
2490 2490 if copied:
2491 ui.write(' %s%s' % (util.pathto(repo.root, cwd, copied),
2492 end))
2491 ui.write(' %s%s' % (repo.pathto(copied, cwd), end))
2493 2492
2494 2493 def tag(ui, repo, name, rev_=None, **opts):
2495 2494 """add a tag for the current or given revision
@@ -44,6 +44,11 b' class dirstate(object):'
44 44 # we're outside the repo. return an absolute path.
45 45 return cwd
46 46
47 def pathto(self, f, cwd=None):
48 if cwd is None:
49 cwd = self.getcwd()
50 return util.pathto(self.root, cwd, f)
51
47 52 def hgignore(self):
48 53 '''return the contents of .hgignore files as a list of patterns.
49 54
@@ -403,9 +408,8 b' class dirstate(object):'
403 408 elif stat.S_ISFIFO(st.st_mode): kind = _('fifo')
404 409 elif stat.S_ISSOCK(st.st_mode): kind = _('socket')
405 410 elif stat.S_ISDIR(st.st_mode): kind = _('directory')
406 self.ui.warn(_('%s: unsupported file type (type is %s)\n') % (
407 util.pathto(self.root, self.getcwd(), f),
408 kind))
411 self.ui.warn(_('%s: unsupported file type (type is %s)\n')
412 % (self.pathto(f), kind))
409 413 return False
410 414
411 415 def walk(self, files=None, match=util.always, badmatch=None):
@@ -513,8 +517,7 b' class dirstate(object):'
513 517 break
514 518 if not found:
515 519 if inst.errno != errno.ENOENT or not badmatch:
516 self.ui.warn('%s: %s\n' % (
517 util.pathto(self.root, self.getcwd(), ff),
520 self.ui.warn('%s: %s\n' % (self.pathto(ff),
518 521 inst.strerror))
519 522 elif badmatch and badmatch(ff) and imatch(nf):
520 523 yield 'b', ff, None
@@ -505,6 +505,9 b' class localrepository(repo.repository):'
505 505 def getcwd(self):
506 506 return self.dirstate.getcwd()
507 507
508 def pathto(self, f, cwd=None):
509 return self.dirstate.pathto(f, cwd)
510
508 511 def wfile(self, f, mode='r'):
509 512 return self.wopener(f, mode)
510 513
@@ -888,8 +891,8 b' class localrepository(repo.repository):'
888 891 if match(fn):
889 892 yield 'b', fn
890 893 else:
891 self.ui.warn(_('%s: No such file in rev %s\n') % (
892 util.pathto(self.root, self.getcwd(), fn), short(node)))
894 self.ui.warn(_('%s: No such file in rev %s\n')
895 % (self.pathto(fn), short(node)))
893 896 else:
894 897 for src, fn in self.dirstate.walk(files, match, badmatch=badmatch):
895 898 yield src, fn
General Comments 0
You need to be logged in to leave comments. Login now