mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
ed1d8b7e7a
Most of the time, one can reverse a diff by swapping the revisions passed with -r but it happens that if you use the global -R, and diff against the tip of the current repo, you can't swap the revisions. One use-case for that is reviewing changes from a bundle before unbundling. One could also pipe the output of `hg diff` to a command line filter that reverses the diff, but that would remove the benefit from color diffs. Therefore, having an option in `hg diff` to reverse a diff is a good thing. The option flag selection was tricky. GNU patch uses -R/--reverse but -R is already used as a global option and --reverse would make --rev ambiguous.
63 lines
1.1 KiB
Bash
Executable File
63 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
echo "[extensions]" >> $HGRCPATH
|
|
echo "mq=" >> $HGRCPATH
|
|
|
|
echo % init
|
|
hg init a
|
|
cd a
|
|
|
|
echo % commit
|
|
echo 'base' > base
|
|
hg ci -Ambase -d '1 0'
|
|
|
|
echo % qnew mqbase
|
|
hg qnew -mmqbase mqbase
|
|
|
|
echo % qrefresh
|
|
echo 'patched' > base
|
|
hg qrefresh
|
|
|
|
echo % qdiff
|
|
hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
|
|
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
|
|
|
|
echo % qdiff dirname
|
|
hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
|
|
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
|
|
|
|
echo % qdiff filename
|
|
hg qdiff --nodates base
|
|
|
|
echo % revert
|
|
hg revert -a
|
|
|
|
echo % qpop
|
|
hg qpop
|
|
|
|
echo % qdelete mqbase
|
|
hg qdelete mqbase
|
|
|
|
echo % commit 2
|
|
printf '1\n2\n3\n4\nhello world\ngoodbye world\n7\n8\n9\n' > lines
|
|
hg ci -Amlines -d '2 0'
|
|
|
|
echo % qnew 2
|
|
hg qnew -mmqbase2 mqbase2
|
|
printf '\n\n1\n2\n3\n4\nhello world\n goodbye world\n7\n8\n9\n' > lines
|
|
|
|
echo % qdiff -U 1
|
|
hg qdiff --nodates -U 1
|
|
|
|
echo % qdiff -b
|
|
hg qdiff --nodates -b
|
|
|
|
echo % qdiff -U 1 -B
|
|
hg qdiff --nodates -U 1 -B
|
|
|
|
echo % qdiff -w
|
|
hg qdiff --nodates -w
|
|
|
|
echo % qdiff --inverse
|
|
hg qdiff --nodates --inverse
|