@@ -180,56 +180,103 @@ def _diff_directory(path1, path2, data_path, after):
180180 return 1 if has_diff else 0
181181
182182
183- @click .command ("xdiff" , no_args_is_help = True )
183+ def _show_summary (ctx , refspec , ref , targets ):
184+ """Show summary of file/hash changes (like old dvx diff)."""
185+ from dvx .repo import Repo
186+ from dvx .commands .diff import CmdDiff
187+
188+ # Parse refspec
189+ if refspec and ref :
190+ raise click .UsageError ("Specify -r/--refspec or -R/--ref, not both" )
191+
192+ if ref :
193+ # -R <ref> means compare <ref>^ to <ref>
194+ a_rev = f"{ ref } ^"
195+ b_rev = ref
196+ elif refspec and ".." in refspec :
197+ a_rev , b_rev = refspec .split (".." , 1 )
198+ elif refspec :
199+ a_rev = refspec
200+ b_rev = None
201+ else :
202+ a_rev = None
203+ b_rev = None
204+
205+ try :
206+ repo = Repo ()
207+ except Exception as e :
208+ raise click .ClickException (f"Not a DVX repository: { e } " )
209+
210+ with repo :
211+ diff_result = repo .diff (a_rev , b_rev , targets = targets or None )
212+
213+ CmdDiff ._show_diff (diff_result )
214+ ctx .exit (0 )
215+
216+
217+ @click .command ("diff" )
184218@click .option ("-b" , "--both" , is_flag = True , help = "Merge stderr into stdout in pipeline commands." )
185219@click .option ("-c/-C" , "--color/--no-color" , default = None , help = "Force or prevent colorized output." )
186220@click .option ("-r" , "--refspec" , help = "<commit1>..<commit2> or <commit> (compare to worktree)." )
187221@click .option ("-R" , "--ref" , help = "Shorthand for -r <ref>^..<ref> (compare commit to parent)." )
188- @click .option ("-s " , "--shell-executable" , help = "Shell to use for executing commands." )
222+ @click .option ("-e " , "--shell-executable" , help = "Shell to use for executing commands." )
189223@click .option ("-S" , "--no-shell" , is_flag = True , help = "Don't use shell for subprocess execution." )
224+ @click .option ("-s" , "--summary" , is_flag = True , help = "Show summary of changes (files and hashes) instead of content diff." )
190225@click .option ("-U" , "--unified" , type = int , help = "Number of lines of context." )
191226@click .option ("-v" , "--verbose" , is_flag = True , help = "Log intermediate commands to stderr." )
192227@click .option ("-w" , "--ignore-whitespace" , is_flag = True , help = "Ignore whitespace differences." )
193228@click .option ("-x" , "--exec-cmd" , "exec_cmds" , multiple = True , help = "Command to execute before diffing." )
194229@click .argument ("args" , nargs = - 1 , metavar = "[cmd...] <path>" )
195230@click .pass_context
196- def xdiff (
231+ def diff (
197232 ctx ,
198233 both : bool ,
199234 color : Optional [bool ],
200235 refspec : Optional [str ],
201236 ref : Optional [str ],
202237 shell_executable : Optional [str ],
203238 no_shell : bool ,
239+ summary : bool ,
204240 unified : Optional [int ],
205241 verbose : bool ,
206242 ignore_whitespace : bool ,
207243 exec_cmds : Tuple [str , ...],
208244 args : Tuple [str , ...],
209245):
210- """Diff a DVC-tracked file between commits, optionally through preprocessing commands.
246+ """Diff DVC-tracked files between commits.
247+
248+ By default, shows actual content differences. Use -s/--summary to show
249+ a summary of which files changed (with hashes) instead.
211250
212251 Examples:
213252
214253 \b
215- dvx xdiff -r HEAD^..HEAD wc -l foo.dvc
216- Compare line count of foo at previous vs current commit .
254+ dvx diff data.csv
255+ Show content diff of data.csv between HEAD and worktree .
217256
218257 \b
219- dvx xdiff md5sum foo
220- Diff md5sum of foo at HEAD vs current worktree .
258+ dvx diff -r HEAD^..HEAD data.csv
259+ Show content diff between previous and current commit .
221260
222261 \b
223- dvx xdiff -R abc123 cat data.csv
224- Show what changed in data.csv at commit abc123.
262+ dvx diff -s
263+ Show summary of all changed files with hashes.
264+
265+ \b
266+ dvx diff -R abc123 wc -l data.csv
267+ Compare line count of data.csv at commit abc123 vs its parent.
225268 """
226269 from dvx .repo import Repo
227270
271+ # Handle summary mode (shows file/hash changes, not content)
272+ if summary :
273+ return _show_summary (ctx , refspec , ref , args )
274+
228275 # Combine exec_cmds and args
229276 remaining = list (exec_cmds ) + list (args )
230277
231278 if not remaining :
232- raise click .UsageError ("Must specify [cmd...] <path>" )
279+ raise click .UsageError ("Must specify [cmd...] <path> (or use -s/--summary) " )
233280
234281 * cmds , target = remaining
235282 data_path , dvc_path = _normalize_path (target )
0 commit comments