# HG changeset patch # User Benoit Boissinot # Date 2006-01-16 14:51:09 # Node ID 5e9168401a68053e98eba621a13084be33291b56 # Parent ee16f06174bd5fa0f17c99dccdc8b3f5f9476ee3 fix locate broken since 63799b01985c - fix the keyword arguments for walk in commands.locate - implement 'hg locate -r ' - add a test for 'hg locate' diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1531,9 +1531,15 @@ def locate(ui, repo, *pats, **opts): that contain white space as multiple filenames. """ end = opts['print0'] and '\0' or '\n' + rev = opts['rev'] + if rev: + node = repo.lookup(rev) + else: + node = None - for src, abs, rel, exact in walk(repo, pats, opts, '(?:.*/|)'): - if repo.dirstate.state(abs) == '?': + for src, abs, rel, exact in walk(repo, pats, opts, node=node, + head='(?:.*/|)'): + if not node and repo.dirstate.state(abs) == '?': continue if opts['fullpath']: ui.write(os.path.join(repo.root, abs), end) diff --git a/tests/test-locate b/tests/test-locate new file mode 100755 --- /dev/null +++ b/tests/test-locate @@ -0,0 +1,20 @@ +#!/bin/sh +# +mkdir t +cd t +hg init +echo 0 > a +echo 0 > b +hg ci -A -m m -d "0 0" +touch nottracked +hg locate a +hg locate NONEXISTENT +hg locate +hg rm a +hg ci -m m -d "0 0" +hg locate a +hg locate NONEXISTENT +hg locate +hg locate -r 0 a +hg locate -r 0 NONEXISTENT +hg locate -r 0 diff --git a/tests/test-locate.out b/tests/test-locate.out new file mode 100644 --- /dev/null +++ b/tests/test-locate.out @@ -0,0 +1,13 @@ +adding a +adding b +a +NONEXISTENT: No such file or directory +a +b +a: No such file or directory +NONEXISTENT: No such file or directory +b +a +NONEXISTENT: No such file in rev 9e1684505872 +a +b