mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
files: recurse into subrepos automatically with an explicit path
This commit is contained in:
parent
1946bae3e9
commit
f25dcb1c8d
@ -2297,12 +2297,16 @@ def files(ui, ctx, m, fm, fmt, subrepos):
|
||||
fm.write('path', fmt, m.rel(f))
|
||||
ret = 0
|
||||
|
||||
if subrepos:
|
||||
for subpath in sorted(ctx.substate):
|
||||
for subpath in sorted(ctx.substate):
|
||||
def matchessubrepo(subpath):
|
||||
return (m.always() or m.exact(subpath)
|
||||
or any(f.startswith(subpath + '/') for f in m.files()))
|
||||
|
||||
if subrepos or matchessubrepo(subpath):
|
||||
sub = ctx.sub(subpath)
|
||||
try:
|
||||
submatch = matchmod.narrowmatcher(subpath, m)
|
||||
if sub.printfiles(ui, submatch, fm, fmt) == 0:
|
||||
if sub.printfiles(ui, submatch, fm, fmt, subrepos) == 0:
|
||||
ret = 0
|
||||
except error.LookupError:
|
||||
ui.status(_("skipping missing subrepository: %s\n")
|
||||
|
@ -109,8 +109,10 @@ Interaction with Mercurial Commands
|
||||
elements. Subversion subrepositories are currently silently ignored.
|
||||
|
||||
:files: files does not recurse into subrepos unless -S/--subrepos is
|
||||
specified. Git and Subversion subrepositories are currently
|
||||
silently ignored.
|
||||
specified. However, if you specify the full path of a file or
|
||||
directory in a subrepo, it will be displayed even without
|
||||
-S/--subrepos being specified. Git and Subversion subrepositories
|
||||
are currently silently ignored.
|
||||
|
||||
:forget: forget currently only handles exact file matches in subrepos.
|
||||
Git and Subversion subrepositories are currently silently ignored.
|
||||
|
@ -504,7 +504,7 @@ class abstractsubrepo(object):
|
||||
"""Resolve the fileset expression for this repo"""
|
||||
return set()
|
||||
|
||||
def printfiles(self, ui, m, fm, fmt):
|
||||
def printfiles(self, ui, m, fm, fmt, subrepos):
|
||||
"""handle the files command for this subrepo"""
|
||||
return 1
|
||||
|
||||
@ -904,7 +904,7 @@ class hgsubrepo(abstractsubrepo):
|
||||
return ctx.flags(name)
|
||||
|
||||
@annotatesubrepoerror
|
||||
def printfiles(self, ui, m, fm, fmt):
|
||||
def printfiles(self, ui, m, fm, fmt, subrepos):
|
||||
# If the parent context is a workingctx, use the workingctx here for
|
||||
# consistency.
|
||||
if self._ctx.rev() is None:
|
||||
@ -912,7 +912,7 @@ class hgsubrepo(abstractsubrepo):
|
||||
else:
|
||||
rev = self._state[1]
|
||||
ctx = self._repo[rev]
|
||||
return cmdutil.files(ui, ctx, m, fm, fmt, True)
|
||||
return cmdutil.files(ui, ctx, m, fm, fmt, subrepos)
|
||||
|
||||
@annotatesubrepoerror
|
||||
def getfileset(self, expr):
|
||||
|
@ -232,6 +232,18 @@ Files sees uncommitted adds and removes in subrepos
|
||||
sub1/sub2/sub2 (glob)
|
||||
sub1/sub2/test.txt (glob)
|
||||
|
||||
$ hg files sub1
|
||||
sub1/.hgsub (glob)
|
||||
sub1/.hgsubstate (glob)
|
||||
sub1/foo (glob)
|
||||
sub1/sub1 (glob)
|
||||
sub1/sub2/folder/bar (glob)
|
||||
sub1/sub2/x.txt (glob)
|
||||
|
||||
$ hg files sub1/sub2
|
||||
sub1/sub2/folder/bar (glob)
|
||||
sub1/sub2/x.txt (glob)
|
||||
|
||||
$ hg files -S -r '.^' sub1/sub2/folder
|
||||
sub1/sub2/folder/test.txt (glob)
|
||||
|
||||
@ -239,7 +251,7 @@ Files sees uncommitted adds and removes in subrepos
|
||||
sub1/sub2/missing: no such file in rev 78026e779ea6 (glob)
|
||||
[1]
|
||||
|
||||
$ hg files -S -r '.^' sub1/
|
||||
$ hg files -r '.^' sub1/
|
||||
sub1/.hgsub (glob)
|
||||
sub1/.hgsubstate (glob)
|
||||
sub1/sub1 (glob)
|
||||
@ -247,7 +259,7 @@ Files sees uncommitted adds and removes in subrepos
|
||||
sub1/sub2/sub2 (glob)
|
||||
sub1/sub2/test.txt (glob)
|
||||
|
||||
$ hg files -S -r '.^' sub1/sub2
|
||||
$ hg files -r '.^' sub1/sub2
|
||||
sub1/sub2/folder/test.txt (glob)
|
||||
sub1/sub2/sub2 (glob)
|
||||
sub1/sub2/test.txt (glob)
|
||||
|
Loading…
Reference in New Issue
Block a user