##// END OF EJS Templates
fix the cat command...
Benoit Boissinot -
r1582:63799b01 default
parent child Browse files
Show More
@@ -0,0 +1,18 b''
1 #!/bin/sh
2 #
3 mkdir t
4 cd t
5 hg init
6 echo 0 > a
7 echo 0 > b
8 hg ci -A -m m -d "0 0"
9 hg rm a
10 hg cat a
11 sleep 1 # make sure mtime is changed
12 echo 1 > b
13 hg ci -m m -d "0 0"
14 echo 2 > b
15 hg cat -r 0 a
16 hg cat -r 0 b
17 hg cat -r 1 a
18 hg cat -r 1 b
@@ -0,0 +1,7 b''
1 adding a
2 adding b
3 0
4 0
5 0
6 a: No such file in rev 551e7cb14b32
7 1
@@ -42,16 +42,16 b' def matchpats(repo, pats=[], opts={}, he'
42 return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'),
42 return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'),
43 opts.get('exclude'), head) + (cwd,)
43 opts.get('exclude'), head) + (cwd,)
44
44
45 def makewalk(repo, pats, opts, head=''):
45 def makewalk(repo, pats, opts, node=None, head=''):
46 files, matchfn, anypats, cwd = matchpats(repo, pats, opts, head)
46 files, matchfn, anypats, cwd = matchpats(repo, pats, opts, head)
47 exact = dict(zip(files, files))
47 exact = dict(zip(files, files))
48 def walk():
48 def walk():
49 for src, fn in repo.walk(files=files, match=matchfn):
49 for src, fn in repo.walk(node=node, files=files, match=matchfn):
50 yield src, fn, util.pathto(cwd, fn), fn in exact
50 yield src, fn, util.pathto(cwd, fn), fn in exact
51 return files, matchfn, walk()
51 return files, matchfn, walk()
52
52
53 def walk(repo, pats, opts, head=''):
53 def walk(repo, pats, opts, node=None, head=''):
54 files, matchfn, results = makewalk(repo, pats, opts, head)
54 files, matchfn, results = makewalk(repo, pats, opts, node, head)
55 for r in results:
55 for r in results:
56 yield r
56 yield r
57
57
@@ -634,20 +634,14 b' def cat(ui, repo, file1, *pats, **opts):'
634 mf = {}
634 mf = {}
635 rev = opts['rev']
635 rev = opts['rev']
636 if rev:
636 if rev:
637 change = repo.changelog.read(repo.lookup(rev))
637 node = repo.lookup(rev)
638 mf = repo.manifest.read(change[0])
638 else:
639 for src, abs, rel, exact in walk(repo, (file1,) + pats, opts):
639 node = repo.changelog.tip()
640 change = repo.changelog.read(node)
641 mf = repo.manifest.read(change[0])
642 for src, abs, rel, exact in walk(repo, (file1,) + pats, opts, node):
640 r = repo.file(abs)
643 r = repo.file(abs)
641 if rev:
644 n = mf[abs]
642 try:
643 n = mf[abs]
644 except (hg.RepoError, KeyError):
645 try:
646 n = r.lookup(rev)
647 except KeyError, inst:
648 raise util.Abort(_('cannot find file %s in rev %s'), rel, rev)
649 else:
650 n = r.tip()
651 fp = make_file(repo, r, opts['output'], node=n, pathname=abs)
645 fp = make_file(repo, r, opts['output'], node=n, pathname=abs)
652 fp.write(r.read(n))
646 fp.write(r.read(n))
653
647
@@ -462,8 +462,14 b' class localrepository(object):'
462
462
463 def walk(self, node=None, files=[], match=util.always):
463 def walk(self, node=None, files=[], match=util.always):
464 if node:
464 if node:
465 fdict = dict.fromkeys(files)
465 for fn in self.manifest.read(self.changelog.read(node)[0]):
466 for fn in self.manifest.read(self.changelog.read(node)[0]):
466 if match(fn): yield 'm', fn
467 fdict.pop(fn, None)
468 if match(fn):
469 yield 'm', fn
470 for fn in fdict:
471 self.ui.warn(_('%s: No such file in rev %s\n') % (
472 util.pathto(self.getcwd(), fn), short(node)))
467 else:
473 else:
468 for src, fn in self.dirstate.walk(files, match):
474 for src, fn in self.dirstate.walk(files, match):
469 yield src, fn
475 yield src, fn
General Comments 0
You need to be logged in to leave comments. Login now