svn_status
Check the status of files in an SVN working copy, including remote changes, by specifying a path and optional visibility of remote updates.
Instructions
Ver el estado de archivos en el working copy
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Ruta específica a consultar | |
| showAll | No | Mostrar estado remoto también |
Implementation Reference
- index.ts:152-201 (handler)MCP tool handler for 'svn_status': registers the tool, defines input schema, executes SvnService.getStatus(), and formats status list as markdown with icons.server.tool( "svn_status", "Ver el estado de archivos en el working copy", { path: z.string().optional().describe("Ruta específica a consultar"), showAll: z.boolean().optional().default(false).describe("Mostrar estado remoto también") }, async (args) => { try { const result = await getSvnService().getStatus(args.path, args.showAll); const statusList = result.data!; if (statusList.length === 0) { return { content: [{ type: "text", text: "✅ **No hay cambios en el working copy**" }], }; } const statusText = `📊 **Estado SVN** (${statusList.length} elementos)\n\n` + statusList.map(status => { const statusIcon: {[key: string]: string} = { 'added': '➕', 'deleted': '➖', 'modified': '✏️', 'replaced': '🔄', 'merged': '🔀', 'conflicted': '⚠️', 'ignored': '🙈', 'none': '⚪', 'normal': '✅', 'external': '🔗', 'incomplete': '⏸️', 'unversioned': '❓', 'missing': '❌' }; return `${statusIcon[status.status] || '📄'} **${status.status.toUpperCase()}** - ${status.path}`; }).join('\n') + `\n\n**Tiempo de Ejecución:** ${formatDuration(result.executionTime || 0)}`; return { content: [{ type: "text", text: statusText }], }; } catch (error: any) { return { content: [{ type: "text", text: `❌ **Error:** ${error.message}` }], }; } } );
- tools/svn-service.ts:158-201 (handler)Core SvnService.getStatus() method: executes 'svn status' command (optionally with --show-updates), parses output using parseStatusOutput, handles errors./** * Obtener estado de archivos en el working copy */ async getStatus(path?: string, showAll: boolean = false): Promise<SvnResponse<SvnStatus[]>> { try { const args = ['status']; if (path) { if (!validatePath(path)) { throw new SvnError(`Invalid path: ${path}`); } args.push(normalizePath(path)); } let response; // Si showAll es true, intentar primero con --show-updates if (showAll) { try { const argsWithUpdates = [...args, '--show-updates']; response = await executeSvnCommand(this.config, argsWithUpdates); } catch (error: any) { // Si falla con --show-updates, intentar sin él console.warn(`Warning: --show-updates failed, falling back to local status only: ${error.message}`); response = await executeSvnCommand(this.config, args); } } else { response = await executeSvnCommand(this.config, args); } const statusList = parseStatusOutput(cleanOutput(response.data as string)); return { success: true, data: statusList, command: response.command, workingDirectory: response.workingDirectory, executionTime: response.executionTime }; } catch (error: any) { this.handleSvnError(error, 'get SVN status'); } }
- common/types.ts:50-57 (schema)TypeScript interface defining SvnStatus used for parsing svn status output.export interface SvnStatus { path: string; status: 'unversioned' | 'added' | 'deleted' | 'modified' | 'replaced' | 'merged' | 'conflicted' | 'ignored' | 'none' | 'normal' | 'external' | 'incomplete'; revision?: number; changedRev?: number; changedAuthor?: string; changedDate?: string; }
- common/utils.ts:281-301 (helper)Utility function to parse raw 'svn status' output into array of SvnStatus objects using SVN_STATUS_CODES mapping.export function parseStatusOutput(output: string): SvnStatus[] { const lines = output.split('\n').filter(line => line.trim()); const statusList: SvnStatus[] = []; for (const line of lines) { if (line.length < 8) continue; const statusCode = line[0]; const propStatusCode = line[1]; const path = line.substring(8).trim(); const status: SvnStatus = { path, status: (SVN_STATUS_CODES as any)[statusCode] || 'unknown' }; statusList.push(status); } return statusList; }
- common/types.ts:306-318 (schema)Constant mapping of SVN status codes to human-readable status strings, used in parsing.export const SVN_STATUS_CODES = { ' ': 'none', 'A': 'added', 'D': 'deleted', 'M': 'modified', 'R': 'replaced', 'C': 'conflicted', 'X': 'external', 'I': 'ignored', '?': 'unversioned', '!': 'missing', '~': 'obstructed' } as const;