Mercurial > hgbook
comparison ja/hgext.tex @ 358:1348ce7d2d77
more hgext.tex
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Tue, 02 Sep 2008 19:03:38 +0900 |
parents | ef197f25f11e |
children | 81116699a510 |
comparison
equal
deleted
inserted
replaced
357:ef197f25f11e | 358:1348ce7d2d77 |
---|---|
357 | 357 |
358 %\section{Flexible diff support with the \hgext{extdiff} extension} | 358 %\section{Flexible diff support with the \hgext{extdiff} extension} |
359 \section{\hgext{extdiff}$B3HD%$K$h$k=@Fp$J(Bdiff$B%5%]!<%H(B} | 359 \section{\hgext{extdiff}$B3HD%$K$h$k=@Fp$J(Bdiff$B%5%]!<%H(B} |
360 \label{sec:hgext:extdiff} | 360 \label{sec:hgext:extdiff} |
361 | 361 |
362 Mercurial's built-in \hgcmd{diff} command outputs plaintext unified | 362 %Mercurial's built-in \hgcmd{diff} command outputs plaintext unified |
363 diffs. | 363 %diffs. |
364 %\interaction{extdiff.diff} | |
365 %If you would like to use an external tool to display modifications, | |
366 %you'll want to use the \hgext{extdiff} extension. This will let you | |
367 %use, for example, a graphical diff tool. | |
368 | |
369 Mercurial$B$N%S%k%H%$%s%3%^%s%I(B\hgcmd{diff}$B$O(Bunified$B7A<0$N(Bdiff$B$r%W%l!<%s%F(B | |
370 $B%-%9%H$G=PNO$9$k!%(B | |
364 \interaction{extdiff.diff} | 371 \interaction{extdiff.diff} |
365 If you would like to use an external tool to display modifications, | 372 $BJQ99$r30It%D!<%k$r;H$C$FI=<($7$?$$$J$i$P!$(B\hgext{extdiff}$B3HD%$r;H$&$HNI(B |
366 you'll want to use the \hgext{extdiff} extension. This will let you | 373 $B$$!%$3$N3HD%$ONc$($P%0%i%U%#%+%k$J(Bdiff$BI=<($r9T$&!%(B |
367 use, for example, a graphical diff tool. | 374 |
368 | 375 %The \hgext{extdiff} extension is bundled with Mercurial, so it's easy |
369 The \hgext{extdiff} extension is bundled with Mercurial, so it's easy | 376 %to set up. In the \rcsection{extensions} section of your \hgrc, |
370 to set up. In the \rcsection{extensions} section of your \hgrc, | 377 %simply add a one-line entry to enable the extension. |
371 simply add a one-line entry to enable the extension. | 378 |
379 \hgext{extdiff}$B3HD%$O(BMercurial$B$KF1:-$5$l$F$$$k$N$G!$%;%C%H%"%C%W$OMF0W$G(B | |
380 $B$"$k!%(B\hgrc $B$NCf$N(B\rcsection{extensions}$B%;%/%7%g%s$K(B1$B9T$N@_Dj$rDI2C$9$k(B | |
381 $B$@$1$GNI$$!%(B | |
372 \begin{codesample2} | 382 \begin{codesample2} |
373 [extensions] | 383 [extensions] |
374 extdiff = | 384 extdiff = |
375 \end{codesample2} | 385 \end{codesample2} |
376 This introduces a command named \hgxcmd{extdiff}{extdiff}, which by | 386 |
377 default uses your system's \command{diff} command to generate a | 387 %This introduces a command named \hgxcmd{extdiff}{extdiff}, which by |
378 unified diff in the same form as the built-in \hgcmd{diff} command. | 388 %default uses your system's \command{diff} command to generate a |
389 %unified diff in the same form as the built-in \hgcmd{diff} command. | |
390 %\interaction{extdiff.extdiff} | |
391 %The result won't be exactly the same as with the built-in \hgcmd{diff} | |
392 %variations, because the output of \command{diff} varies from one | |
393 %system to another, even when passed the same options. | |
394 | |
395 $B$3$N3HD%$G(B\hgxcmd{extdiff}{extdiff}$B$H$$$&%3%^%s%I$,;H$($k$h$&$K$J$k!%(B | |
396 $B$3$N%3%^%s%I$O%7%9%F%`$N(B\command{diff}$B$r;H$C$FAH$_9~$_$N(B\hgcmd{diff}$B%3%^(B | |
397 $B%s%I$HF1MM$N(Bunified$B7A<0$N(Bdiff$B$r@8@.$9$k!%(B | |
379 \interaction{extdiff.extdiff} | 398 \interaction{extdiff.extdiff} |
380 The result won't be exactly the same as with the built-in \hgcmd{diff} | 399 $BF@$i$l$k@.2LJ*$OAH$_9~$_$N(B\hgcmd{diff}$B$HA4$/F1$8$K$O$J$i$J$$$@$m$&!%M}M3(B |
381 variations, because the output of \command{diff} varies from one | 400 $B$O(B\command{diff}$B%3%^%s%I$O%7%9%F%`Kh$K0[$J$j!$F1$8%*%W%7%g%s$rEO$7$F$bF1(B |
382 system to another, even when passed the same options. | 401 $B$8=PNO$r$9$k$H$O8B$i$J$$$+$i$@!%(B |
383 | 402 |
384 As the ``\texttt{making snapshot}'' lines of output above imply, the | 403 %As the ``\texttt{making snapshot}'' lines of output above imply, the |
385 \hgxcmd{extdiff}{extdiff} command works by creating two snapshots of | 404 %\hgxcmd{extdiff}{extdiff} command works by creating two snapshots of |
386 your source tree. The first snapshot is of the source revision; the | 405 %your source tree. The first snapshot is of the source revision; the |
387 second, of the target revision or working directory. The | 406 %second, of the target revision or working directory. The |
388 \hgxcmd{extdiff}{extdiff} command generates these snapshots in a | 407 %\hgxcmd{extdiff}{extdiff} command generates these snapshots in a |
389 temporary directory, passes the name of each directory to an external | 408 %temporary directory, passes the name of each directory to an external |
390 diff viewer, then deletes the temporary directory. For efficiency, it | 409 %diff viewer, then deletes the temporary directory. For efficiency, it |
391 only snapshots the directories and files that have changed between the | 410 %only snapshots the directories and files that have changed between the |
392 two revisions. | 411 %two revisions. |
393 | 412 |
394 Snapshot directory names have the same base name as your repository. | 413 $B=PNO$N(B``\texttt{making snapshot}''$B9T$,<gD%$9$k$h$&(B |
395 If your repository path is \dirname{/quux/bar/foo}, then \dirname{foo} | 414 $B$K!$(B\hgxcmd{extdiff}{extdiff}$B%3%^%s%I$O%=!<%9%D%j!<$N(B2$B$D$N%9%J%C%W%7%g%C(B |
396 will be the name of each snapshot directory. Each snapshot directory | 415 $B%H$r:n$k$h$&$KF/$/!%(B 1$B$DL\$N%9%J%C%W%7%g%C%H$O%=!<%9%j%S%8%g%s$G!$(B2$B$DL\$O(B |
397 name has its changeset ID appended, if appropriate. If a snapshot is | 416 $B%o!<%-%s%0%G%#%l%/%H%j$N%?!<%2%C%H%j%S%8%g%s$G$"$k!%(B |
398 of revision \texttt{a631aca1083f}, the directory will be named | 417 \hgxcmd{extdiff}{extdiff}$B%3%^%s%I$O$3$l$i$N%9%J%C%W%7%g%C%H$r%F%s%]%i%j%G%#(B |
399 \dirname{foo.a631aca1083f}. A snapshot of the working directory won't | 418 $B%l%/%H%j$K:n$j!$30It(Bdiff$B%S%e!<%"$K$=$l$>$l$N%G%#%l%/%H%j$NL>A0$rEO$9!%$=(B |
400 have a changeset ID appended, so it would just be \dirname{foo} in | 419 $B$N8e!$%F%s%]%i%j%G%#%l%/%H%j$r>C5n$9$k!%8zN($N$?$a$K(B2$B$D$N%j%S%8%g%s4V$GJQ(B |
401 this example. To see what this looks like in practice, look again at | 420 $B99$N$"$C$?%G%#%l%/%H%j$H%U%!%$%k$N%9%J%C%W%7%g%C%H$@$1$r<h$k!%(B |
402 the \hgxcmd{extdiff}{extdiff} example above. Notice that the diff has | 421 |
403 the snapshot directory names embedded in its header. | 422 %Snapshot directory names have the same base name as your repository. |
404 | 423 %If your repository path is \dirname{/quux/bar/foo}, then \dirname{foo} |
405 The \hgxcmd{extdiff}{extdiff} command accepts two important options. | 424 %will be the name of each snapshot directory. Each snapshot directory |
406 The \hgxopt{extdiff}{extdiff}{-p} option lets you choose a program to | 425 %name has its changeset ID appended, if appropriate. If a snapshot is |
407 view differences with, instead of \command{diff}. With the | 426 %of revision \texttt{a631aca1083f}, the directory will be named |
408 \hgxopt{extdiff}{extdiff}{-o} option, you can change the options that | 427 %\dirname{foo.a631aca1083f}. A snapshot of the working directory won't |
409 \hgxcmd{extdiff}{extdiff} passes to the program (by default, these | 428 %have a changeset ID appended, so it would just be \dirname{foo} in |
410 options are ``\texttt{-Npru}'', which only make sense if you're | 429 |
411 running \command{diff}). In other respects, the | 430 %this example. To see what this looks like in practice, look again at |
412 \hgxcmd{extdiff}{extdiff} command acts similarly to the built-in | 431 %the \hgxcmd{extdiff}{extdiff} example above. Notice that the diff has |
413 \hgcmd{diff} command: you use the same option names, syntax, and | 432 %the snapshot directory names embedded in its header. |
414 arguments to specify the revisions you want, the files you want, and | 433 |
415 so on. | 434 $B%9%J%C%W%7%g%C%H%G%#%l%/%H%j$NL>A0$O%j%]%8%H%j$HF1$8%Y!<%9%M!<%`$r;}$D!%(B |
416 | 435 $B%j%]%8%H%j$N%Q%9$,(B\dirname{/quux/bar/foo}$B$J$i$P!$(B\dirname{foo}$B$,%9%J%C%W(B |
417 As an example, here's how to run the normal system \command{diff} | 436 $B%7%g%C%H%G%#%l%/%H%j$N%Y!<%9%M!<%`$K$J$j!$$3$3$K%A%'%s%8%;%C%H(BID$B$,IU2C$5(B |
418 command, getting it to generate context diffs (using the | 437 $B$l$k!%%9%J%C%W%7%g%C%H$N%j%S%8%g%s$,(B\texttt{a631aca1083f}$B$J$i!$%G%#%l%/%H(B |
419 \cmdopt{diff}{-c} option) instead of unified diffs, and five lines of | 438 $B%j$O(B\dirname{foo.a631aca1083f}$B$H$J$k!%%o!<%-%s%0%G%#%l%/%H%j$N%9%J%C%W(B |
420 context instead of the default three (passing \texttt{5} as the | 439 $B%7%g%C%H$O%A%'%s%8%;%C%H(BID$B$r;}$?$J$$$N$G!$$3$NNc$G$O(B\dirname{foo}$B$H$$$&L>(B |
421 argument to the \cmdopt{diff}{-C} option). | 440 $BA0$K$J$k!%<B:]$NF0:n$r8+$k$K$O!$>e5-$N(B\hgxcmd{extdiff}{extdiff}$B$r;2>H$5$l(B |
422 \interaction{extdiff.extdiff-ctx} | 441 $B$?$$!%(B diff$B$N%X%C%@$K$O%9%J%C%W%7%g%C%H%G%#%l%/%H%jL>$,Kd$a9~$^$l$F$$$kE@(B |
423 | 442 $B$KN10U$5$l$?$$!%(B |
424 Launching a visual diff tool is just as easy. Here's how to launch | 443 |
425 the \command{kdiff3} viewer. | 444 %The \hgxcmd{extdiff}{extdiff} command accepts two important options. |
445 %The \hgxopt{extdiff}{extdiff}{-p} option lets you choose a program to | |
446 %view differences with, instead of \command{diff}. With the | |
447 %\hgxopt{extdiff}{extdiff}{-o} option, you can change the options that | |
448 %\hgxcmd{extdiff}{extdiff} passes to the program (by default, these | |
449 %options are ``\texttt{-Npru}'', which only make sense if you're | |
450 %running \command{diff}). In other respects, the | |
451 %\hgxcmd{extdiff}{extdiff} command acts similarly to the built-in | |
452 %\hgcmd{diff} command: you use the same option names, syntax, and | |
453 %arguments to specify the revisions you want, the files you want, and | |
454 %so on. | |
455 | |
456 \hgxcmd{extdiff}{extdiff}$B%3%^%s%I$K$O=EMW$J%*%W%7%g%s$,(B2$B$D$"$k!%(B | |
457 \hgxopt{extdiff}{extdiff}{-p}$B%*%W%7%g%s$G:9J,$r<h$k%3%^%s%I$H$7$F(B | |
458 \command{diff}$B0J30$N%3%^%s%I$r;XDj$G$-$k!%(B \hgxopt{extdiff}{extdiff}{-o} | |
459 $B%*%W%7%g%s$G(B\hgxcmd{extdiff}{extdiff}$B$,30It%W%m%0%i%`$KEO$9%*%W%7%g%s$rJQ(B | |
460 $B99$9$k$3$H$,$G$-$k!%!J%G%U%)%k%H$G$O(B``\texttt{-Npru}''$B$,EO$5$l$k!%$3$l$O(B | |
461 \command{diff}$B$,5/F0$5$l$k;~$N$_0UL#$r;}$D!%!K$=$NB>$NE@$G$O(B | |
462 \hgxcmd{extdiff}{extdiff}$B%3%^%s%I$O%S%k%H%$%s$N(B\hgcmd{diff}$B$HF1MM$NF0:n$r(B | |
463 $B$9$k!%$9$J$o$A!$F1$8%*%W%7%g%sL>!$J8K!!$%j%S%8%g%s$d%U%!%$%k$r;XDj$9$k=q(B | |
464 $B<0$J$I$r;}$D!%(B | |
465 | |
466 %As an example, here's how to run the normal system \command{diff} | |
467 %command, getting it to generate context diffs (using the | |
468 | |
469 %\cmdopt{diff}{-c} option) instead of unified diffs, and five lines of | |
470 %context instead of the default three (passing \texttt{5} as the | |
471 %argument to the \cmdopt{diff}{-C} option). | |
472 %\interaction{extdiff.extdiff-ctx} | |
473 | |
474 $B$3$3$G%7%9%F%`$NDL>o%3%^%s%I$N(B\command{diff}$B$r!$(Bunified diff$B7A<0$G$O$J(B | |
475 $B$/!$!J(B\cmdopt{diff}{-c}$B%*%W%7%g%s$r;H$C$F!K(Bcontext diff$B7A<0$r=PNO$5$;$kNc(B | |
476 $B$r8+$F$_$h$&!%(Bcontext diff$B$K4^$^$l$k%3%s%F%-%9%H$N9T?t$b%G%U%)%k%H$N(B3$B9T$G(B | |
477 $B$O$J$/!$!J(B\cmdopt{diff}{-C}$B$X(B\texttt{5}$B%*%W%7%g%s$rEO$7$F!K(B5$B9T=PNO$5$;$k(B | |
478 $B$h$&$K$9$k!%(B | |
479 | |
480 %Launching a visual diff tool is just as easy. Here's how to launch | |
481 %the \command{kdiff3} viewer. | |
482 $B%S%8%e%"%k(Bdiff$B%D!<%k$N5/F0$O$?$d$9$$!%$3$3$G$O(B\command{kdiff3}$B%S%e!<%"$N(B | |
483 $B5/F0J}K!$r<($9!%(B | |
426 \begin{codesample2} | 484 \begin{codesample2} |
427 hg extdiff -p kdiff3 -o '' | 485 hg extdiff -p kdiff3 -o '' |
428 \end{codesample2} | 486 \end{codesample2} |
429 | 487 |
430 If your diff viewing command can't deal with directories, you can | 488 %If your diff viewing command can't deal with directories, you can |
431 easily work around this with a little scripting. For an example of | 489 %easily work around this with a little scripting. For an example of |
432 such scripting in action with the \hgext{mq} extension and the | 490 %such scripting in action with the \hgext{mq} extension and the |
433 \command{interdiff} command, see | 491 %\command{interdiff} command, see |
434 section~\ref{mq-collab:tips:interdiff}. | 492 %section~\ref{mq-collab:tips:interdiff}. |
493 | |
494 $BMxMQ$7$h$&$H$9$k(Bdiff$B%S%e!<%3%^%s%I$,%G%#%l%/%H%j$r07$($J$$>l9g!$$o$:$+$J(B | |
495 $B%9%/%j%W%H$r=q$/$3$H$G4JC1$K$3$NLdBj$r2sHr$9$k$3$H$,$G$-$k!%<B:]$K;H$o$l(B | |
496 $B$F$$$k%9%/%j%W%HNc$H$7$F$O!$(B\hgext{mq}$B3HD%$H(B\command{interdiff}$B%3%^%s%I$N(B | |
497 $B4V$N$b$N$,$"$k!%$3$l$K$D$$$F$O(B\ref{mq-collab:tips:interdiff}$B$r;2>H$5$l$?(B | |
498 $B$$!%(B | |
435 | 499 |
436 %\subsection{Defining command aliases} | 500 %\subsection{Defining command aliases} |
437 \subsection{$B%3%^%s%I$N%(%$%j%"%9$r:n$k(B} | 501 \subsection{$B%3%^%s%I$N%(%$%j%"%9$r:n$k(B} |
438 | 502 |
439 It can be cumbersome to remember the options to both the | 503 It can be cumbersome to remember the options to both the |