##// 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 files, matchfn, anypats = matchpats(repo, pats, opts, globbed=globbed,
145 files, matchfn, anypats = matchpats(repo, pats, opts, globbed=globbed,
146 default=default)
146 default=default)
147 exact = dict.fromkeys(files)
147 exact = dict.fromkeys(files)
148 cwd = repo.getcwd()
148 for src, fn in repo.walk(node=node, files=files, match=matchfn,
149 for src, fn in repo.walk(node=node, files=files, match=matchfn,
149 badmatch=badmatch):
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 def findrenames(repo, added=None, removed=None, threshold=0.5):
153 def findrenames(repo, added=None, removed=None, threshold=0.5):
153 '''find renamed files -- yields (before, after, score) tuples'''
154 '''find renamed files -- yields (before, after, score) tuples'''
@@ -501,7 +501,7 b' def docopy(ui, repo, pats, opts, wlock):'
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)
@@ -2484,12 +2484,11 b' def status(ui, repo, *pats, **opts):'
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
@@ -44,6 +44,11 b' class dirstate(object):'
44 # we're outside the repo. return an absolute path.
44 # we're outside the repo. return an absolute path.
45 return cwd
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 def hgignore(self):
52 def hgignore(self):
48 '''return the contents of .hgignore files as a list of patterns.
53 '''return the contents of .hgignore files as a list of patterns.
49
54
@@ -403,9 +408,8 b' class dirstate(object):'
403 elif stat.S_ISFIFO(st.st_mode): kind = _('fifo')
408 elif stat.S_ISFIFO(st.st_mode): kind = _('fifo')
404 elif stat.S_ISSOCK(st.st_mode): kind = _('socket')
409 elif stat.S_ISSOCK(st.st_mode): kind = _('socket')
405 elif stat.S_ISDIR(st.st_mode): kind = _('directory')
410 elif stat.S_ISDIR(st.st_mode): kind = _('directory')
406 self.ui.warn(_('%s: unsupported file type (type is %s)\n') % (
411 self.ui.warn(_('%s: unsupported file type (type is %s)\n')
407 util.pathto(self.root, self.getcwd(), f),
412 % (self.pathto(f), kind))
408 kind))
409 return False
413 return False
410
414
411 def walk(self, files=None, match=util.always, badmatch=None):
415 def walk(self, files=None, match=util.always, badmatch=None):
@@ -513,9 +517,8 b' class dirstate(object):'
513 break
517 break
514 if not found:
518 if not found:
515 if inst.errno != errno.ENOENT or not badmatch:
519 if inst.errno != errno.ENOENT or not badmatch:
516 self.ui.warn('%s: %s\n' % (
520 self.ui.warn('%s: %s\n' % (self.pathto(ff),
517 util.pathto(self.root, self.getcwd(), ff),
521 inst.strerror))
518 inst.strerror))
519 elif badmatch and badmatch(ff) and imatch(nf):
522 elif badmatch and badmatch(ff) and imatch(nf):
520 yield 'b', ff, None
523 yield 'b', ff, None
521 continue
524 continue
@@ -505,6 +505,9 b' class localrepository(repo.repository):'
505 def getcwd(self):
505 def getcwd(self):
506 return self.dirstate.getcwd()
506 return self.dirstate.getcwd()
507
507
508 def pathto(self, f, cwd=None):
509 return self.dirstate.pathto(f, cwd)
510
508 def wfile(self, f, mode='r'):
511 def wfile(self, f, mode='r'):
509 return self.wopener(f, mode)
512 return self.wopener(f, mode)
510
513
@@ -888,8 +891,8 b' class localrepository(repo.repository):'
888 if match(fn):
891 if match(fn):
889 yield 'b', fn
892 yield 'b', fn
890 else:
893 else:
891 self.ui.warn(_('%s: No such file in rev %s\n') % (
894 self.ui.warn(_('%s: No such file in rev %s\n')
892 util.pathto(self.root, self.getcwd(), fn), short(node)))
895 % (self.pathto(fn), short(node)))
893 else:
896 else:
894 for src, fn in self.dirstate.walk(files, match, badmatch=badmatch):
897 for src, fn in self.dirstate.walk(files, match, badmatch=badmatch):
895 yield src, fn
898 yield src, fn
General Comments 0
You need to be logged in to leave comments. Login now