##// END OF EJS Templates
subrepo: add basic support to hgsubrepo for the files command...
Matt Harbison -
r24413:a8595176 default
parent child Browse files
Show More
@@ -2261,7 +2261,7 b' def forget(ui, repo, match, prefix, expl'
2261 forgot.extend(f for f in forget if f not in rejected)
2261 forgot.extend(f for f in forget if f not in rejected)
2262 return bad, forgot
2262 return bad, forgot
2263
2263
2264 def files(ui, ctx, m, fm, fmt):
2264 def files(ui, ctx, m, fm, fmt, subrepos):
2265 rev = ctx.rev()
2265 rev = ctx.rev()
2266 ret = 1
2266 ret = 1
2267 ds = ctx.repo().dirstate
2267 ds = ctx.repo().dirstate
@@ -2277,6 +2277,17 b' def files(ui, ctx, m, fm, fmt):'
2277 fm.write('path', fmt, m.rel(f))
2277 fm.write('path', fmt, m.rel(f))
2278 ret = 0
2278 ret = 0
2279
2279
2280 if subrepos:
2281 for subpath in sorted(ctx.substate):
2282 sub = ctx.sub(subpath)
2283 try:
2284 submatch = matchmod.narrowmatcher(subpath, m)
2285 if sub.printfiles(ui, submatch, fm, fmt) == 0:
2286 ret = 0
2287 except error.LookupError:
2288 ui.status(_("skipping missing subrepository: %s\n")
2289 % m.abs(subpath))
2290
2280 return ret
2291 return ret
2281
2292
2282 def remove(ui, repo, m, prefix, after, force, subrepos):
2293 def remove(ui, repo, m, prefix, after, force, subrepos):
@@ -3225,7 +3225,7 b' def export(ui, repo, *changesets, **opts'
3225 @command('files',
3225 @command('files',
3226 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3226 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3227 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3227 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3228 ] + walkopts + formatteropts,
3228 ] + walkopts + formatteropts + subrepoopts,
3229 _('[OPTION]... [PATTERN]...'))
3229 _('[OPTION]... [PATTERN]...'))
3230 def files(ui, repo, *pats, **opts):
3230 def files(ui, repo, *pats, **opts):
3231 """list tracked files
3231 """list tracked files
@@ -3280,7 +3280,7 b' def files(ui, repo, *pats, **opts):'
3280 fmt = '%s' + end
3280 fmt = '%s' + end
3281
3281
3282 m = scmutil.match(ctx, pats, opts)
3282 m = scmutil.match(ctx, pats, opts)
3283 ret = cmdutil.files(ui, ctx, m, fm, fmt)
3283 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3284
3284
3285 fm.end()
3285 fm.end()
3286
3286
@@ -109,6 +109,10 b' Interaction with Mercurial Commands'
109 elements. Git subrepositories do not support --include/--exclude.
109 elements. Git subrepositories do not support --include/--exclude.
110 Subversion subrepositories are currently silently ignored.
110 Subversion subrepositories are currently silently ignored.
111
111
112 :files: files does not recurse into subrepos unless -S/--subrepos is
113 specified. Git and Subversion subrepositories are currently
114 silently ignored.
115
112 :forget: forget currently only handles exact file matches in subrepos.
116 :forget: forget currently only handles exact file matches in subrepos.
113 Git and Subversion subrepositories are currently silently ignored.
117 Git and Subversion subrepositories are currently silently ignored.
114
118
@@ -469,6 +469,10 b' class abstractsubrepo(object):'
469 """return file flags"""
469 """return file flags"""
470 return ''
470 return ''
471
471
472 def printfiles(self, ui, m, fm, fmt):
473 """handle the files command for this subrepo"""
474 return 1
475
472 def archive(self, archiver, prefix, match=None):
476 def archive(self, archiver, prefix, match=None):
473 if match is not None:
477 if match is not None:
474 files = [f for f in self.files() if match(f)]
478 files = [f for f in self.files() if match(f)]
@@ -848,6 +852,17 b' class hgsubrepo(abstractsubrepo):'
848 ctx = self._repo[rev]
852 ctx = self._repo[rev]
849 return ctx.flags(name)
853 return ctx.flags(name)
850
854
855 @annotatesubrepoerror
856 def printfiles(self, ui, m, fm, fmt):
857 # If the parent context is a workingctx, use the workingctx here for
858 # consistency.
859 if self._ctx.rev() is None:
860 ctx = self._repo[None]
861 else:
862 rev = self._state[1]
863 ctx = self._repo[rev]
864 return cmdutil.files(ui, ctx, m, fm, fmt, True)
865
851 def walk(self, match):
866 def walk(self, match):
852 ctx = self._repo[None]
867 ctx = self._repo[None]
853 return ctx.walk(match)
868 return ctx.walk(match)
@@ -262,7 +262,7 b' Show all commands + options'
262 debugsuccessorssets:
262 debugsuccessorssets:
263 debugwalk: include, exclude
263 debugwalk: include, exclude
264 debugwireargs: three, four, five, ssh, remotecmd, insecure
264 debugwireargs: three, four, five, ssh, remotecmd, insecure
265 files: rev, print0, include, exclude, template
265 files: rev, print0, include, exclude, template, subrepos
266 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
266 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
267 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
267 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
268 heads: rev, topo, active, closed, style, template
268 heads: rev, topo, active, closed, style, template
@@ -186,6 +186,24 b' Test relative path printing + subrepos'
186 adding foo/bar/abc
186 adding foo/bar/abc
187 committing subrepository sub1
187 committing subrepository sub1
188 committing subrepository sub1/sub2 (glob)
188 committing subrepository sub1/sub2 (glob)
189
190 $ hg forget sub1/sub2/sub2
191 $ echo x > sub1/sub2/x.txt
192 $ hg add sub1/sub2/x.txt
193
194 Files sees uncommitted adds and removes in subrepos
195 $ hg files -S
196 .hgsub
197 .hgsubstate
198 foo/bar/abc (glob)
199 main
200 sub1/.hgsub (glob)
201 sub1/.hgsubstate (glob)
202 sub1/foo (glob)
203 sub1/sub1 (glob)
204 sub1/sub2/folder/bar (glob)
205 sub1/sub2/x.txt (glob)
206
189 $ hg rollback -q
207 $ hg rollback -q
190 $ hg up -Cq
208 $ hg up -Cq
191
209
@@ -393,6 +411,7 b' largefile and a normal file. Then a lar'
393 R sub1/sub2/test.txt
411 R sub1/sub2/test.txt
394 ? foo/bar/abc
412 ? foo/bar/abc
395 ? sub1/sub2/untracked.txt
413 ? sub1/sub2/untracked.txt
414 ? sub1/sub2/x.txt
396 $ hg add sub1/sub2
415 $ hg add sub1/sub2
397 $ hg ci -Sqm 'forget testing'
416 $ hg ci -Sqm 'forget testing'
398
417
@@ -25,8 +25,13 b' Issue2232: committing a subrepo without '
25 abort: can't commit subrepos without .hgsub
25 abort: can't commit subrepos without .hgsub
26 [255]
26 [255]
27
27
28 $ hg -R s add s/a
29 $ hg files -S
30 .hgsub
31 a
32 s/a (glob)
33
28 $ hg -R s ci -Ams0
34 $ hg -R s ci -Ams0
29 adding a
30 $ hg sum
35 $ hg sum
31 parent: 0:f7b1eb17ad24 tip
36 parent: 0:f7b1eb17ad24 tip
32 0
37 0
General Comments 0
You need to be logged in to leave comments. Login now