Explorar el Código

Initial import

cere hace 2 meses
commit
9d03917bb9
Se han modificado 8 ficheros con 317 adiciones y 0 borrados
  1. 1 0
      scite
  2. 1 0
      svn_git_init
  3. 19 0
      svn_interact/AGENTS.md
  4. 55 0
      svn_interact/svn_git_init
  5. 65 0
      win_diff
  6. 56 0
      win_edit
  7. 53 0
      win_python
  8. 67 0
      win_svn_dialog

+ 1 - 0
scite

@@ -0,0 +1 @@
+win_edit

+ 1 - 0
svn_git_init

@@ -0,0 +1 @@
+svn_interact/svn_git_init

+ 19 - 0
svn_interact/AGENTS.md

@@ -0,0 +1,19 @@
+# Repository Guidelines
+
+## Project Structure & Module Organization
+The root contains a single Bash entry point, `svn_git_init`, which automates cloning a subdirectory from an SVN repository into a Git checkout. It creates a transient `trunk-git/` working tree, so keep temporary artifacts out of version control. Place future helpers beside the script and document new folders directly in this section.
+
+## Build, Test, and Development Commands
+Run the script from the SVN subdirectory you want to migrate: `bash svn_git_init`. Make it executable locally with `chmod +x svn_git_init` if you prefer `./svn_git_init`. Lint changes before committing via `shellcheck svn_git_init`, and rely on `set -euo pipefail` semantics if you introduce new entry points.
+
+## Coding Style & Naming Conventions
+Follow the existing two-space indentation and align continued command options for readability. Use uppercase SNAKE_CASE for environment or exported variables and lowercase for locals. Always wrap variable expansions in quotes and prefer modern Bash features (`$(...)`, `[[ ]]`). Keep inline comments focused on non-obvious logic, such as awk pipelines or revision math.
+
+## Testing Guidelines
+There is no automated suite yet; validate behavior by running against a disposable SVN repository. You can create one with `svnadmin create /tmp/demo && svn import ...` to exercise first-of-branch detection and progress output. Confirm `git svn fetch` completes and that the resulting `trunk-git/.git/config` points at the expected subpath. Treat `shellcheck` as a gate—PRs should pass with zero warnings.
+
+## Commit & Pull Request Guidelines
+Use imperative, one-line commit subjects (e.g., `Refine progress reporting`). Reference related tickets in the body when relevant and note any manual verification performed. PRs should include a concise summary, reproduction or validation steps, and mention any new dependencies (`git svn`, `shellcheck`, etc.). Attach console output snippets if they highlight edge cases.
+
+## Security & Configuration Tips
+The script destroys `trunk-git/` on each run; double-check the target path before invoking. Avoid adding commands that require network credentials without documenting the expectation, and keep quoting strict to prevent word splitting when paths contain spaces.

+ 55 - 0
svn_interact/svn_git_init

@@ -0,0 +1,55 @@
+# From inside the SVN subdir you want to extract:
+
+# Discover URLs (works on older svn too)
+REPO_ROOT="$(svn info --show-item repos-root-url 2>/dev/null || svn info | awk -F': ' '/^Repository Root:/ {print $2; exit}')"
+CURR_URL="$(svn info --show-item url 2>/dev/null || svn info | awk -F': ' '/^URL:/ {print $2; exit}')"
+
+# Find FIRST and HEAD that touched *this* path
+FIRST_REV="$(svn log -q --stop-on-copy "$CURR_URL" | awk '/^r[0-9]+/ {rev=$1} END {sub(/^r/,"",rev); print rev}')"
+[[ -z "$FIRST_REV" ]] && FIRST_REV=1
+HEAD_REV="$(svn info -r HEAD "$CURR_URL" 2>/dev/null | awk -F': ' '/^Revision:/ {print $2; exit}')"
+[[ -z "$HEAD_REV" ]] && HEAD_REV="$(svn log -q -r HEAD "$CURR_URL" | awk '/^r[0-9]+/ {sub(/^r/,"",$1); print $1; exit}')"
+
+TOTAL=$(( HEAD_REV - FIRST_REV + 1 ))
+(( TOTAL > 0 )) || { echo "Nothing to import (HEAD < FIRST)"; exit 0; }
+
+TARGET_DIR="trunk-git"
+rm -rf -- "$TARGET_DIR"
+
+# Init against the *subdir* URL (no ignore-paths needed)
+git svn init --no-minimize-url --no-metadata "$CURR_URL" "$TARGET_DIR"
+cd "$TARGET_DIR"
+
+# Optional cosmetics
+git config init.defaultBranch trunk || true
+
+# Stream fetch with live percentage (no --verbose needed)
+echo "Importing SVN history with progress..."
+git svn fetch -r "${FIRST_REV}:HEAD" 2>&1 | \
+awk -v first="$FIRST_REV" -v last="$HEAD_REV" -v total="$TOTAL" '
+  BEGIN { imported=0 }
+  { print $0
+    if ($1 ~ /^r[0-9]+$/ && $2 == "=") {
+      rev = substr($1,2)
+      if (rev >= first && rev <= last) {
+        imported++
+        pct = int((imported*100)/total)
+        printf("\r[%3d%%] Imported %d/%d revisions (r%d)", pct, imported, total, rev) > "/dev/stderr"
+        fflush("/dev/stderr")
+      }
+    }
+  }
+  END { printf("\n") > "/dev/stderr" }
+'
+
+# Optional: make this subdir the repo root (should already be, since we targeted the subdir URL)
+# If you still see extra path components, you can use:
+# if command -v git-filter-repo >/dev/null 2>&1; then
+#   git filter-repo --force
+# fi
+
+# Rename branch to trunk (if needed)
+curr_branch="$(git symbolic-ref --short HEAD 2>/dev/null || true)"
+if [[ -n "$curr_branch" && "$curr_branch" != "trunk" ]]; then
+  git branch -m trunk || true
+fi

+ 65 - 0
win_diff

@@ -0,0 +1,65 @@
+#!/usr/bin/env bash
+# compare_wsl.sh
+# Usage: ./compare_wsl.sh /path/to/file1 /path/to/file2
+
+set -euo pipefail
+
+if [[ $# -ne 2 ]]; then
+  echo "Usage: $0 <linux_path_to_file1> <linux_path_to_file2>"
+  exit 1
+fi
+
+# Input (Linux) paths
+F1_LINUX="$1"
+F2_LINUX="$2"
+
+# Basic checks
+if [[ ! -e "$F1_LINUX" ]]; then
+  echo "Error: '$F1_LINUX' does not exist." >&2
+  exit 1
+fi
+if [[ ! -e "$F2_LINUX" ]]; then
+  echo "Error: '$F2_LINUX' does not exist." >&2
+  exit 1
+fi
+if ! command -v wslpath >/dev/null 2>&1; then
+  echo "Error: wslpath not found." >&2
+  exit 1
+fi
+
+# Resolve to absolute Linux paths (helps if you pass relative paths)
+# 'readlink -f' is available on most WSL distros; if not, remove these two lines.
+F1_LINUX="$(readlink -f "$F1_LINUX")"
+F2_LINUX="$(readlink -f "$F2_LINUX")"
+
+# === Prepare required variables ===
+# Filenames only
+F1_NAME="$(basename "$F1_LINUX")"
+F2_NAME="$(basename "$F2_LINUX")"
+
+# Windows-mapped absolute paths
+F1_PATH="$(wslpath -w "$F1_LINUX")"
+F2_PATH="$(wslpath -w "$F2_LINUX")"
+
+# (Optional) show what we computed
+#echo "F1_PATH=$F1_PATH"
+#echo "F1_NAME=$F1_NAME"
+#echo "F2_PATH=$F2_PATH"
+#echo "F2_NAME=$F2_NAME"
+
+# === Example: launch ExamDiff via Windows PowerShell ===
+# Adjust ExamDiff path if your version/path differs.
+POWERSHELL="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"
+EXAMDIFF="C:\\Program Files\\ExamDiff Pro 16.0\\ExamDiff.exe"
+
+# Use Start-Process with an explicit -ArgumentList.
+# We wrap the entire PowerShell command in double quotes so Bash expands our vars,
+# and we escape the inner double quotes so PowerShell receives proper strings.
+"$POWERSHELL" -NoProfile -Command \
+"Start-Process -FilePath '$EXAMDIFF' -ArgumentList \
+\"$F1_PATH\",\"$F2_PATH\",\"/dn1:$F1_NAME\",\"/dn2:$F2_NAME\",\"/nh\""
+
+# If you prefer to block until ExamDiff exits, add: -Wait
+# ...like:
+# \"$F1_PATH\",\"$F2_PATH\",\"/dn1:$F1_NAME\",\"/dn2:$F2_NAME\",\"/nh\" -Wait
+

+ 56 - 0
win_edit

@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+# open_scite.sh
+# Usage:
+#   ./open_scite.sh /path/to/file [line_number] [column_number]
+
+set -euo pipefail
+
+if [[ $# -lt 1 || $# -gt 3 ]]; then
+  echo "Usage: $0 <linux_path_to_file> [line_number] [column_number]"
+  exit 1
+fi
+
+FILE_LINUX="$1"
+LINE="${2:-}"
+COL="${3:-}"
+
+if ! command -v wslpath >/dev/null 2>&1; then
+  echo "Error: wslpath not found." >&2
+  exit 1
+fi
+
+# Convert Linux path to Windows path
+FILE_WIN="$(wslpath -w "$FILE_LINUX")"
+
+# Build goto arg if line/col provided
+GOTO_ARG=""
+if [[ -n "$LINE" ]]; then
+  if ! [[ "$LINE" =~ ^[0-9]+$ ]]; then
+    echo "Error: line number must be numeric." >&2
+    exit 1
+  fi
+  if [[ -n "$COL" && ! "$COL" =~ ^[0-9]+$ ]]; then
+    echo "Error: column number must be numeric." >&2
+    exit 1
+  fi
+  COL="${COL:-1}"   # default col=1 if only line given
+  GOTO_ARG="-goto:$LINE,$COL"
+fi
+
+# Debug info
+# echo "Opening in SciTE:"
+# echo "  FILE_WIN=$FILE_WIN"
+# [[ -n "$GOTO_ARG" ]] && echo "  GOTO_ARG=$GOTO_ARG"
+
+# Paths
+POWERSHELL="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"
+SCITE="C:\\apps\\scite\\SciTE.exe"
+
+# Launch SciTE
+if [[ -n "$GOTO_ARG" ]]; then
+  "$POWERSHELL" -NoProfile -Command \
+    "Start-Process -FilePath '$SCITE' -ArgumentList \"$FILE_WIN\",\"$GOTO_ARG\""
+else
+  "$POWERSHELL" -NoProfile -Command \
+    "Start-Process -FilePath '$SCITE' -ArgumentList \"$FILE_WIN\""
+fi

+ 53 - 0
win_python

@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+# winpy.sh — stream Windows python.exe output in WSL
+# Usage:
+#   winpy.sh script.py [args...]
+#   winpy.sh -c "print('hi')"
+#   winpy.sh -m module [args...]
+
+set -euo pipefail
+
+# Path to Windows python.exe, via WSL mount
+PY="/mnt/d/vls-trunk/env-win64/python27/python.exe"
+
+if [[ ! -x "$PY" && ! -f "$PY" ]]; then
+  echo "Error: python.exe not found at: $PY" >&2
+  exit 1
+fi
+
+if [[ $# -lt 1 ]]; then
+  echo "Usage: $0 <script.py | -c cmd | -m module | other python flags> [args...]" >&2
+  exit 1
+fi
+
+# If first arg is a python flag (e.g. -c/-m/-V), pass through directly.
+if [[ "$1" == -* ]]; then
+  exec "$PY" -u "$@"
+fi
+
+# Otherwise treat first arg as a script path; convert to Windows if it exists in WSL.
+SCRIPT="$1"; shift
+if [[ -e "$SCRIPT" ]]; then
+  SCRIPT_WIN="$(wslpath -w "$SCRIPT")"
+else
+  # allow passing a Windows-style path directly
+  SCRIPT_WIN="$SCRIPT"
+fi
+
+# Optional: convert any remaining args that are existing WSL paths if you set
+# WINPY_CONVERT_ARGS=1 in your environment.
+ARGS=()
+if [[ "${WINPY_CONVERT_ARGS:-0}" == "1" ]]; then
+  for a in "$@"; do
+    if [[ -e "$a" ]]; then
+      ARGS+=("$(wslpath -w "$a")")
+    else
+      ARGS+=("$a")
+    fi
+  done
+else
+  ARGS=("$@")
+fi
+
+# -u = unbuffered for immediate streaming
+exec "$PY" -u "$SCRIPT_WIN" "${ARGS[@]}"

+ 67 - 0
win_svn_dialog

@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+# win_tortoisesvn.sh
+# Usage:
+#   ./win_tortoisesvn.sh commit /path/to/workingcopy "Your commit message"
+
+set -euo pipefail
+
+if [[ $# -ne 3 ]]; then
+  echo "Usage: $0 commit <linux_path> <commit_message>" >&2
+  exit 1
+fi
+
+CMD="$1"
+WC_LINUX="$2"
+LOGMSG="$3"
+
+if [[ "$CMD" != "commit" ]]; then
+  echo "Error: only the 'commit' command is supported." >&2
+  exit 1
+fi
+
+# Validate path
+if [[ ! -e "$WC_LINUX" ]]; then
+  echo "Error: path '$WC_LINUX' does not exist." >&2
+  exit 1
+fi
+
+# Resolve absolute linux path and convert to Windows
+if command -v readlink >/dev/null 2>&1; then
+  WC_LINUX="$(readlink -f "$WC_LINUX")"
+fi
+if ! command -v wslpath >/dev/null 2>&1; then
+  echo "Error: wslpath not found." >&2
+  exit 1
+fi
+WC_WIN="$(wslpath -w "$WC_LINUX")"
+
+# Write commit message to a temporary file and convert its path
+LOGFILE_LINUX="$(mktemp /tmp/tsvn-commit.XXXXXX.txt)"
+printf "%s" "$LOGMSG" > "$LOGFILE_LINUX"
+LOGFILE_WIN="$(wslpath -w "$LOGFILE_LINUX")"
+
+# Paths
+POWERSHELL="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"
+TSVN_EXE="C:\\Program Files\\TortoiseSVN\\bin\\TortoiseProc.exe"
+
+# Build TortoiseProc arguments:
+# /command:commit — open Commit dialog
+# /path:"<path>" — the working copy path
+# /logmsgfile:"<file>" — prefill commit message (safer than /logmsg for quotes/newlines)
+# /closeonend:0 — keep dialog; don't auto-close
+PS_CMD="
+Start-Process -FilePath '$TSVN_EXE' -ArgumentList @(
+  '/command:commit',
+  '/path:$WC_WIN',
+  '/logmsgfile:$LOGFILE_WIN',
+  '/closeonend:0'
+)
+"
+
+# Launch (non-blocking; remove Start-Process and call directly if you want to block)
+"$POWERSHELL" -NoProfile -Command "$PS_CMD"
+
+# Optional: keep temp file (useful if you want to reuse); otherwise uncomment to auto-clean
+# rm -f \"$LOGFILE_LINUX\"
+
+echo "Opened TortoiseSVN Commit dialog for: $WC_LINUX"