mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
implement recursive option for mercurial browse command
This commit is contained in:
@@ -99,6 +99,11 @@ public class HgBrowseCommand extends AbstractCommand implements BrowseCommand
|
|||||||
cmd.disableLastCommit();
|
cmd.disableLastCommit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.isRecursive())
|
||||||
|
{
|
||||||
|
cmd.recursive();
|
||||||
|
}
|
||||||
|
|
||||||
BrowserResult result = new BrowserResult();
|
BrowserResult result = new BrowserResult();
|
||||||
|
|
||||||
result.setFiles(cmd.execute());
|
result.setFiles(cmd.execute());
|
||||||
|
|||||||
@@ -157,6 +157,19 @@ public class HgFileviewCommand extends AbstractCommand
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public HgFileviewCommand recursive()
|
||||||
|
{
|
||||||
|
cmdAppend("-c");
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ def appendTrailingSlash(path):
|
|||||||
path += '/'
|
path += '/'
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def collectFiles(revCtx, path, files, directories):
|
def collectFiles(revCtx, path, files, directories, recursive):
|
||||||
length = 0
|
length = 0
|
||||||
paths = []
|
paths = []
|
||||||
mf = revCtx.manifest()
|
mf = revCtx.manifest()
|
||||||
@@ -66,6 +66,7 @@ def collectFiles(revCtx, path, files, directories):
|
|||||||
if f.startswith(directory):
|
if f.startswith(directory):
|
||||||
paths.append(f)
|
paths.append(f)
|
||||||
|
|
||||||
|
if not recursive:
|
||||||
for p in paths:
|
for p in paths:
|
||||||
parts = p.split('/')
|
parts = p.split('/')
|
||||||
depth = len(parts)
|
depth = len(parts)
|
||||||
@@ -78,6 +79,9 @@ def collectFiles(revCtx, path, files, directories):
|
|||||||
dirpath += parts[i] + '/'
|
dirpath += parts[i] + '/'
|
||||||
if not dirpath in directories:
|
if not dirpath in directories:
|
||||||
directories.append(dirpath)
|
directories.append(dirpath)
|
||||||
|
else:
|
||||||
|
for p in paths:
|
||||||
|
files.append(revCtx[p])
|
||||||
|
|
||||||
def createSubRepositoryMap(revCtx):
|
def createSubRepositoryMap(revCtx):
|
||||||
subrepos = {}
|
subrepos = {}
|
||||||
@@ -140,7 +144,7 @@ def fileview(ui, repo, **opts):
|
|||||||
if path.endswith('/'):
|
if path.endswith('/'):
|
||||||
path = path[0:-1]
|
path = path[0:-1]
|
||||||
transport = opts['transport']
|
transport = opts['transport']
|
||||||
collectFiles(revCtx, path, files, directories)
|
collectFiles(revCtx, path, files, directories, opts['recursive'])
|
||||||
subRepositories = createSubRepositoryMap(revCtx)
|
subRepositories = createSubRepositoryMap(revCtx)
|
||||||
for k, v in subRepositories.iteritems():
|
for k, v in subRepositories.iteritems():
|
||||||
if k.startswith(path):
|
if k.startswith(path):
|
||||||
@@ -155,6 +159,7 @@ cmdtable = {
|
|||||||
'fileview': (fileview,[
|
'fileview': (fileview,[
|
||||||
('r', 'revision', 'tip', 'revision to print'),
|
('r', 'revision', 'tip', 'revision to print'),
|
||||||
('p', 'path', '', 'path to print'),
|
('p', 'path', '', 'path to print'),
|
||||||
|
('c', 'recursive', False, 'browse repository recursive'),
|
||||||
('d', 'disableLastCommit', False, 'disables last commit description and date'),
|
('d', 'disableLastCommit', False, 'disables last commit description and date'),
|
||||||
('t', 'transport', False, 'format the output for command server'),
|
('t', 'transport', False, 'format the output for command server'),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -159,6 +159,32 @@ public class HgBrowseCommandTest extends AbstractHgCommandTestBase
|
|||||||
assertNull(a.getLastModified());
|
assertNull(a.getLastModified());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testRecursive() throws IOException, RepositoryException
|
||||||
|
{
|
||||||
|
BrowseCommandRequest request = new BrowseCommandRequest();
|
||||||
|
|
||||||
|
request.setRecursive(true);
|
||||||
|
|
||||||
|
BrowserResult result = new HgBrowseCommand(cmdContext,
|
||||||
|
repository).getBrowserResult(request);
|
||||||
|
|
||||||
|
assertNotNull(result);
|
||||||
|
|
||||||
|
List<FileObject> foList = result.getFiles();
|
||||||
|
|
||||||
|
assertNotNull(foList);
|
||||||
|
assertFalse(foList.isEmpty());
|
||||||
|
assertEquals(5, foList.size());
|
||||||
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user