author | Siddharth Agarwal <sid0@fb.com> |
Tue, 17 Mar 2015 15:46:30 -0700 | |
changeset 24432 | e22248f6d257 |
parent 24431 | a0004402776b |
child 24433 | f5f4dc115fb2 |
--- a/mercurial/commands.py Tue Mar 17 15:06:40 2015 -0700 +++ b/mercurial/commands.py Tue Mar 17 15:46:30 2015 -0700 @@ -148,6 +148,7 @@ ('U', 'unified', '', _('number of lines of context to show'), _('NUM')), ('', 'stat', None, _('output diffstat-style summary of changes')), + ('', 'relative', '', _('produce diffs relative to subdirectory'), _('DIR')), ] mergetoolopts = [ @@ -3169,7 +3170,8 @@ diffopts = patch.diffallopts(ui, opts) m = scmutil.match(repo[node2], pats, opts) cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat, - listsubrepos=opts.get('subrepos')) + listsubrepos=opts.get('subrepos'), + relative=opts.get('relative')) @command('^export', [('o', 'output', '',
--- a/tests/test-completion.t Tue Mar 17 15:06:40 2015 -0700 +++ b/tests/test-completion.t Tue Mar 17 15:46:30 2015 -0700 @@ -203,7 +203,7 @@ annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos - diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos + diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, relative, include, exclude, subrepos export: output, switch-parent, rev, text, git, nodates forget: include, exclude init: ssh, remotecmd, insecure
--- a/tests/test-diff-subdir.t Tue Mar 17 15:06:40 2015 -0700 +++ b/tests/test-diff-subdir.t Tue Mar 17 15:46:30 2015 -0700 @@ -44,4 +44,24 @@ @@ -0,0 +1,1 @@ +2 +relative to beta + $ cd .. + $ hg diff --nodates --relative beta + diff -r 7d5ef1aea329 two + --- a/two + +++ b/two + @@ -0,0 +1,1 @@ + +2 + +inside beta + + $ cd beta + $ hg diff --nodates --relative . + diff -r 7d5ef1aea329 two + --- a/two + +++ b/two + @@ -0,0 +1,1 @@ + +2 + + $ cd ..
--- a/tests/test-diffstat.t Tue Mar 17 15:06:40 2015 -0700 +++ b/tests/test-diffstat.t Tue Mar 17 15:46:30 2015 -0700 @@ -69,4 +69,39 @@ file with spaces | Bin 1 files changed, 0 insertions(+), 0 deletions(-) +diffstat within directories: + + $ hg rm -f 'file with spaces' + + $ mkdir dir1 dir2 + $ echo new1 > dir1/new + $ echo new2 > dir2/new + $ hg add dir1/new dir2/new + $ hg diff --stat + dir1/new | 1 + + dir2/new | 1 + + 2 files changed, 2 insertions(+), 0 deletions(-) + + $ hg diff --stat --relative dir1 + new | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + + $ hg diff --stat --relative dir1 dir2 + warning: dir2 not inside relative root dir1 + + $ hg diff --stat --relative dir1 -I dir1/old + + $ cd dir1 + $ hg diff --stat . + dir1/new | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + $ hg diff --stat --relative . + new | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + + $ hg diff --stat --relative ../dir1 ../dir2 + warning: ../dir2 not inside relative root . + + $ hg diff --stat --relative . -I old + $ cd ..
--- a/tests/test-git-export.t Tue Mar 17 15:06:40 2015 -0700 +++ b/tests/test-git-export.t Tue Mar 17 15:46:30 2015 -0700 @@ -5,46 +5,279 @@ New file: - $ echo new > new + $ mkdir dir1 + $ echo new > dir1/new $ hg ci -Amnew - adding new + adding dir1/new $ hg diff --git -r 0 - diff --git a/new b/new + diff --git a/dir1/new b/dir1/new new file mode 100644 --- /dev/null - +++ b/new + +++ b/dir1/new @@ -0,0 +1,1 @@ +new Copy: - $ hg cp new copy + $ mkdir dir2 + $ hg cp dir1/new dir1/copy + $ echo copy1 >> dir1/copy + $ hg cp dir1/new dir2/copy + $ echo copy2 >> dir2/copy $ hg ci -mcopy $ hg diff --git -r 1:tip + diff --git a/dir1/new b/dir1/copy + copy from dir1/new + copy to dir1/copy + --- a/dir1/new + +++ b/dir1/copy + @@ -1,1 +1,2 @@ + new + +copy1 + diff --git a/dir1/new b/dir2/copy + copy from dir1/new + copy to dir2/copy + --- a/dir1/new + +++ b/dir2/copy + @@ -1,1 +1,2 @@ + new + +copy2 + +Cross and same-directory copies with a relative root: + + $ hg diff --git --relative .. -r 1:tip + abort: .. not under root '$TESTTMP' + [255] + $ hg diff --git --relative doesnotexist -r 1:tip + $ hg diff --git --relative . -r 1:tip + diff --git a/dir1/new b/dir1/copy + copy from dir1/new + copy to dir1/copy + --- a/dir1/new + +++ b/dir1/copy + @@ -1,1 +1,2 @@ + new + +copy1 + diff --git a/dir1/new b/dir2/copy + copy from dir1/new + copy to dir2/copy + --- a/dir1/new + +++ b/dir2/copy + @@ -1,1 +1,2 @@ + new + +copy2 + $ hg diff --git --relative dir1 -r 1:tip + diff --git a/new b/copy + copy from new + copy to copy + --- a/new + +++ b/copy + @@ -1,1 +1,2 @@ + new + +copy1 + + $ hg diff --git --relative dir2/ -r 1:tip + diff --git a/copy b/copy + new file mode 100644 + --- /dev/null + +++ b/copy + @@ -0,0 +1,2 @@ + +new + +copy2 + + $ hg diff --git --relative dir1 -r 1:tip -I '**/copy' diff --git a/new b/copy copy from new copy to copy + --- a/new + +++ b/copy + @@ -1,1 +1,2 @@ + new + +copy1 + + $ hg diff --git --relative dir1 -r 1:tip dir2 + warning: dir2 not inside relative root dir1 + + $ hg diff --git --relative dir1 -r 1:tip 'dir2/{copy}' + warning: dir2/{copy} not inside relative root dir1 + + $ cd dir1 + $ hg diff --git --relative .. -r 1:tip + diff --git a/dir1/new b/dir1/copy + copy from dir1/new + copy to dir1/copy + --- a/dir1/new + +++ b/dir1/copy + @@ -1,1 +1,2 @@ + new + +copy1 + diff --git a/dir1/new b/dir2/copy + copy from dir1/new + copy to dir2/copy + --- a/dir1/new + +++ b/dir2/copy + @@ -1,1 +1,2 @@ + new + +copy2 + + $ hg diff --git --relative ../.. -r 1:tip + abort: ../.. not under root '$TESTTMP' + [255] + $ hg diff --git --relative ../doesnotexist -r 1:tip + $ hg diff --git --relative .. -r 1:tip + diff --git a/dir1/new b/dir1/copy + copy from dir1/new + copy to dir1/copy + --- a/dir1/new + +++ b/dir1/copy + @@ -1,1 +1,2 @@ + new + +copy1 + diff --git a/dir1/new b/dir2/copy + copy from dir1/new + copy to dir2/copy + --- a/dir1/new + +++ b/dir2/copy + @@ -1,1 +1,2 @@ + new + +copy2 + + $ hg diff --git --relative . -r 1:tip + diff --git a/new b/copy + copy from new + copy to copy + --- a/new + +++ b/copy + @@ -1,1 +1,2 @@ + new + +copy1 + $ hg diff --git --relative . -r 1:tip copy + diff --git a/new b/copy + copy from new + copy to copy + --- a/new + +++ b/copy + @@ -1,1 +1,2 @@ + new + +copy1 + $ hg diff --git --relative . -r 1:tip ../dir2 + warning: ../dir2 not inside relative root . + $ hg diff --git --relative . -r 1:tip '../dir2/*' + warning: ../dir2/* not inside relative root . + $ cd .. Rename: - $ hg mv copy rename + $ hg mv dir1/copy dir1/rename1 + $ echo rename1 >> dir1/rename1 + $ hg mv dir2/copy dir1/rename2 + $ echo rename2 >> dir1/rename2 $ hg ci -mrename $ hg diff --git -r 2:tip - diff --git a/copy b/rename + diff --git a/dir1/copy b/dir1/rename1 + rename from dir1/copy + rename to dir1/rename1 + --- a/dir1/copy + +++ b/dir1/rename1 + @@ -1,2 +1,3 @@ + new + copy1 + +rename1 + diff --git a/dir2/copy b/dir1/rename2 + rename from dir2/copy + rename to dir1/rename2 + --- a/dir2/copy + +++ b/dir1/rename2 + @@ -1,2 +1,3 @@ + new + copy2 + +rename2 + +Cross and same-directory renames with a relative root: + + $ hg diff --relative dir1 --git -r 2:tip + diff --git a/copy b/rename1 rename from copy - rename to rename + rename to rename1 + --- a/copy + +++ b/rename1 + @@ -1,2 +1,3 @@ + new + copy1 + +rename1 + diff --git a/rename2 b/rename2 + new file mode 100644 + --- /dev/null + +++ b/rename2 + @@ -0,0 +1,3 @@ + +new + +copy2 + +rename2 + + $ hg diff --relative dir2 --git -r 2:tip + diff --git a/copy b/copy + deleted file mode 100644 + --- a/copy + +++ /dev/null + @@ -1,2 +0,0 @@ + -new + -copy2 + + $ hg diff --relative dir1 --git -r 2:tip -I '**/copy' + diff --git a/copy b/copy + deleted file mode 100644 + --- a/copy + +++ /dev/null + @@ -1,2 +0,0 @@ + -new + -copy1 + + $ hg diff --relative dir1 --git -r 2:tip -I '**/rename*' + diff --git a/copy b/rename1 + copy from copy + copy to rename1 + --- a/copy + +++ b/rename1 + @@ -1,2 +1,3 @@ + new + copy1 + +rename1 + diff --git a/rename2 b/rename2 + new file mode 100644 + --- /dev/null + +++ b/rename2 + @@ -0,0 +1,3 @@ + +new + +copy2 + +rename2 Delete: - $ hg rm rename + $ hg rm dir1/* $ hg ci -mdelete $ hg diff --git -r 3:tip - diff --git a/rename b/rename + diff --git a/dir1/new b/dir1/new deleted file mode 100644 - --- a/rename + --- a/dir1/new +++ /dev/null @@ -1,1 +0,0 @@ -new + diff --git a/dir1/rename1 b/dir1/rename1 + deleted file mode 100644 + --- a/dir1/rename1 + +++ /dev/null + @@ -1,3 +0,0 @@ + -new + -copy1 + -rename1 + diff --git a/dir1/rename2 b/dir1/rename2 + deleted file mode 100644 + --- a/dir1/rename2 + +++ /dev/null + @@ -1,3 +0,0 @@ + -new + -copy2 + -rename2 $ cat > src <<EOF > 1
--- a/tests/test-help.t Tue Mar 17 15:06:40 2015 -0700 +++ b/tests/test-help.t Tue Mar 17 15:46:30 2015 -0700 @@ -509,6 +509,7 @@ -B --ignore-blank-lines ignore changes whose lines are all blank -U --unified NUM number of lines of context to show --stat output diffstat-style summary of changes + --relative DIR produce diffs relative to subdirectory -I --include PATTERN [+] include names matching the given patterns -X --exclude PATTERN [+] exclude names matching the given patterns -S --subrepos recurse into subrepositories