##// END OF EJS Templates
files: add new command unifying locate and manifest functionality
Matt Mackall -
r22423:edf07a80 default
parent child Browse files
Show More
@@ -3061,6 +3061,81 b' def export(ui, repo, *changesets, **opts'
3061 3061 switch_parent=opts.get('switch_parent'),
3062 3062 opts=patch.diffopts(ui, opts))
3063 3063
3064 @command('files',
3065 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3066 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3067 ] + walkopts,
3068 _('[OPTION]... [PATTERN]...'))
3069 def files(ui, repo, *pats, **opts):
3070 """list tracked files
3071
3072 Print files under Mercurial control in the working directory or
3073 specified revision whose names match the given patterns (excluding
3074 removed files).
3075
3076 If no patterns are given to match, this command prints the names
3077 of all files under Mercurial control in the working copy.
3078
3079 .. container:: verbose
3080
3081 Examples:
3082
3083 - list all files under the current directory::
3084
3085 hg files .
3086
3087 - shows sizes and flags for current revision::
3088
3089 hg files -vr .
3090
3091 - list all files named README::
3092
3093 hg files -I "**/README"
3094
3095 - list all binary files::
3096
3097 hg files "set:binary()"
3098
3099 - find files containing a regular expression:
3100
3101 hg files "set:grep('bob')"
3102
3103 - search tracked file contents with xargs and grep::
3104
3105 hg files -0 | xargs -0 grep foo
3106
3107 See :hg:'help pattern' and :hg:'help revsets' for more information
3108 on specifying file patterns.
3109
3110 Returns 0 if a match is found, 1 otherwise.
3111
3112 """
3113 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3114 rev = ctx.rev()
3115 ret = 1
3116
3117 end = '\n'
3118 if opts.get('print0'):
3119 end = '\0'
3120 fm = ui.formatter('status', opts)
3121 fmt = '%s' + end
3122
3123 m = scmutil.match(ctx, pats, opts)
3124 for f in ctx.walk(m):
3125 if rev is None and repo.dirstate[f] in 'R?!':
3126 continue
3127 fm.startitem()
3128 if ui.verbose:
3129 fc = ctx[f]
3130 fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
3131 fm.data(abspath=f)
3132 fm.write('path', fmt, m.rel(f))
3133 ret = 0
3134
3135 fm.end()
3136
3137 return ret
3138
3064 3139 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3065 3140 def forget(ui, repo, *pats, **opts):
3066 3141 """forget the specified files on the next commit
@@ -17,6 +17,7 b' Show all commands except debug commands'
17 17 copy
18 18 diff
19 19 export
20 files
20 21 forget
21 22 graft
22 23 grep
@@ -257,6 +258,7 b' Show all commands + options'
257 258 debugsuccessorssets:
258 259 debugwalk: include, exclude
259 260 debugwireargs: three, four, five, ssh, remotecmd, insecure
261 files: rev, print0, include, exclude
260 262 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
261 263 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
262 264 heads: rev, topo, active, closed, style, template
@@ -301,6 +301,7 b' Testing -h/--help:'
301 301 copy mark files as copied for the next commit
302 302 diff diff repository (or selected files)
303 303 export dump the header and diffs for one or more changesets
304 files list tracked files
304 305 forget forget the specified files on the next commit
305 306 graft copy changes from other branches onto the current branch
306 307 grep search for a pattern in specified files and revisions
@@ -383,6 +384,7 b' Testing -h/--help:'
383 384 copy mark files as copied for the next commit
384 385 diff diff repository (or selected files)
385 386 export dump the header and diffs for one or more changesets
387 files list tracked files
386 388 forget forget the specified files on the next commit
387 389 graft copy changes from other branches onto the current branch
388 390 grep search for a pattern in specified files and revisions
@@ -66,6 +66,7 b' Short help:'
66 66 copy mark files as copied for the next commit
67 67 diff diff repository (or selected files)
68 68 export dump the header and diffs for one or more changesets
69 files list tracked files
69 70 forget forget the specified files on the next commit
70 71 graft copy changes from other branches onto the current branch
71 72 grep search for a pattern in specified files and revisions
@@ -142,6 +143,7 b' Short help:'
142 143 copy mark files as copied for the next commit
143 144 diff diff repository (or selected files)
144 145 export dump the header and diffs for one or more changesets
146 files list tracked files
145 147 forget forget the specified files on the next commit
146 148 graft copy changes from other branches onto the current branch
147 149 grep search for a pattern in specified files and revisions
@@ -684,6 +686,7 b' Test that default list of commands omits'
684 686 copy mark files as copied for the next commit
685 687 diff diff repository (or selected files)
686 688 export dump the header and diffs for one or more changesets
689 files list tracked files
687 690 forget forget the specified files on the next commit
688 691 graft copy changes from other branches onto the current branch
689 692 grep search for a pattern in specified files and revisions
@@ -1444,6 +1447,13 b' Dish up an empty repo; serve it cold.'
1444 1447 mark files as copied for the next commit
1445 1448 </td></tr>
1446 1449 <tr><td>
1450 <a href="/help/files">
1451 files
1452 </a>
1453 </td><td>
1454 list tracked files
1455 </td></tr>
1456 <tr><td>
1447 1457 <a href="/help/graft">
1448 1458 graft
1449 1459 </a>
@@ -92,6 +92,16 b' Issue294: hg remove --after dir fails wh'
92 92 t/e.h (glob)
93 93 t/x (glob)
94 94
95 $ hg files
96 b
97 dir.h/foo
98 t.h
99 t/b
100 t/e.h
101 t/x
102 $ hg files b
103 b
104
95 105 $ mkdir otherdir
96 106 $ cd otherdir
97 107
@@ -24,6 +24,14 b' The next call is expected to return noth'
24 24 b/a
25 25 l
26 26
27 $ hg files -vr .
28 2 a
29 2 x b/a
30 1 l l
31 $ hg files -r . -X b
32 a
33 l
34
27 35 $ hg manifest -v
28 36 644 a
29 37 755 * b/a
General Comments 0
You need to be logged in to leave comments. Login now