-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd_rm.py
More file actions
63 lines (48 loc) · 1.87 KB
/
Copy pathcmd_rm.py
File metadata and controls
63 lines (48 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""Handler for 'git rm' command.
Supported flags:
- RM-01: -f/--force -> -f (pass through)
- RM-02: --cached -> warning (no staging area in Sapling)
- RM-03: -n/--dry-run -> warning (not supported)
- RM-04: -q/--quiet -> -q (pass through)
- RM-05: -r/--recursive -> filtered (sl remove is recursive by default)
"""
import sys
from common import ParsedCommand, run_sl
def handle(parsed: ParsedCommand) -> int:
"""
Handle 'git rm' command.
Translations:
- git rm <files> -> sl remove <files>
- git rm -f -> sl remove -f
- git rm -q -> sl remove -q
- git rm -r -> sl remove (recursive by default)
Warnings:
- --cached (no staging area, use 'sl forget')
- -n/--dry-run (not supported)
"""
sl_args = []
remaining_args = []
i = 0
while i < len(parsed.args):
arg = parsed.args[i]
# RM-01: -f/--force -> pass through
if arg in ('-f', '--force'):
sl_args.append('-f')
# RM-04: -q/--quiet -> pass through
elif arg in ('-q', '--quiet'):
sl_args.append('-q')
# RM-05: -r/--recursive -> filtered (sl remove is recursive by default)
elif arg in ('-r', '--recursive'):
pass # Skip - sl remove is recursive by default
# RM-02: --cached -> warning (no staging area)
elif arg == '--cached':
print("Warning: --cached not supported. Sapling has no staging area. "
"Use 'sl forget' to untrack files.", file=sys.stderr)
# RM-03: -n/--dry-run -> warning (not supported)
elif arg in ('-n', '--dry-run'):
print("Warning: -n/--dry-run not supported by Sapling remove. "
"Use 'sl status' to see tracked files.", file=sys.stderr)
else:
remaining_args.append(arg)
i += 1
return run_sl(["remove"] + sl_args + remaining_args)