From patchwork Thu Mar 26 18:14:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,2,V2] diff: rename --relative option to --root From: Sean Farley X-Patchwork-Id: 8303 Message-Id: <3769372acb363c945b44.1427393698@laptop.staff.sf.atlassian.com> To: mercurial-devel@selenic.com Date: Thu, 26 Mar 2015 11:14:58 -0700 # HG changeset patch # User Sean Farley # Date 1427309715 25200 # Wed Mar 25 11:55:15 2015 -0700 # Node ID 3769372acb363c945b444a89dbb510b1c49fa7af # Parent 98042b0e19f9a04be3270cecb07915eac3a515cf diff: rename --relative option to --root The diff output format is unable to express files outside the directory so it makes sense to name this option --root instead of --relative. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1006,20 +1006,20 @@ def export(repo, revs, template='hg-%h.p for seqno, rev in enumerate(revs): single(rev, seqno + 1, fp) def diffordiffstat(ui, repo, diffopts, node1, node2, match, changes=None, stat=False, fp=None, prefix='', - relative='', listsubrepos=False): + root='', listsubrepos=False): '''show diff or diffstat.''' if fp is None: write = ui.write else: def write(s, **kw): fp.write(s) - if relative: - relroot = pathutil.canonpath(repo.root, repo.getcwd(), relative) + if root: + relroot = pathutil.canonpath(repo.root, repo.getcwd(), root) else: relroot = '' if relroot != '': # XXX relative roots currently don't work if the root is within a # subrepo diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -146,11 +146,11 @@ diffopts2 = [ ('', 'reverse', None, _('produce a diff that undoes the changes')), ] + diffwsopts + [ ('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')), + ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')), ] mergetoolopts = [ ('t', 'tool', '', _('specify merge tool')), ] @@ -3169,11 +3169,11 @@ def diff(ui, repo, *pats, **opts): 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'), - relative=opts.get('relative')) + root=opts.get('root')) @command('^export', [('o', 'output', '', _('print output to file with formatted name'), _('FORMAT')), ('', 'switch-parent', None, _('diff against the second parent')), diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -201,11 +201,11 @@ Show all commands + options $ hg debugcommands add: include, exclude, subrepos, dry-run 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, relative, include, exclude, subrepos + diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, root, include, exclude, subrepos export: output, switch-parent, rev, text, git, nodates forget: include, exclude init: ssh, remotecmd, insecure log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude merge: force, rev, preview, tool diff --git a/tests/test-diff-subdir.t b/tests/test-diff-subdir.t --- a/tests/test-diff-subdir.t +++ b/tests/test-diff-subdir.t @@ -45,21 +45,21 @@ inside beta +2 relative to beta $ cd .. - $ hg diff --nodates --relative beta + $ hg diff --nodates --root beta diff -r 7d5ef1aea329 two --- a/two +++ b/two @@ -0,0 +1,1 @@ +2 inside beta $ cd beta - $ hg diff --nodates --relative . + $ hg diff --nodates --root . diff -r 7d5ef1aea329 two --- a/two +++ b/two @@ -0,0 +1,1 @@ +2 diff --git a/tests/test-diffstat.t b/tests/test-diffstat.t --- a/tests/test-diffstat.t +++ b/tests/test-diffstat.t @@ -80,28 +80,28 @@ diffstat within directories: $ hg diff --stat dir1/new | 1 + dir2/new | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) - $ hg diff --stat --relative dir1 + $ hg diff --stat --root dir1 new | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) - $ hg diff --stat --relative dir1 dir2 + $ hg diff --stat --root dir1 dir2 warning: dir2 not inside relative root dir1 - $ hg diff --stat --relative dir1 -I dir1/old + $ hg diff --stat --root dir1 -I dir1/old $ cd dir1 $ hg diff --stat . dir1/new | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) - $ hg diff --stat --relative . + $ hg diff --stat --root . new | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) - $ hg diff --stat --relative ../dir1 ../dir2 + $ hg diff --stat --root ../dir1 ../dir2 warning: ../dir2 not inside relative root . - $ hg diff --stat --relative . -I old + $ hg diff --stat --root . -I old $ cd .. diff --git a/tests/test-git-export.t b/tests/test-git-export.t --- a/tests/test-git-export.t +++ b/tests/test-git-export.t @@ -43,15 +43,15 @@ Copy: new +copy2 Cross and same-directory copies with a relative root: - $ hg diff --git --relative .. -r 1:tip + $ hg diff --git --root .. -r 1:tip abort: .. not under root '$TESTTMP' [255] - $ hg diff --git --relative doesnotexist -r 1:tip - $ hg diff --git --relative . -r 1:tip + $ hg diff --git --root doesnotexist -r 1:tip + $ hg diff --git --root . -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 @@ -64,47 +64,47 @@ Cross and same-directory copies with a r --- a/dir1/new +++ b/dir2/copy @@ -1,1 +1,2 @@ new +copy2 - $ hg diff --git --relative dir1 -r 1:tip + $ hg diff --git --root 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 + $ hg diff --git --root 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' + $ hg diff --git --root 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 + $ hg diff --git --root dir1 -r 1:tip dir2 warning: dir2 not inside relative root dir1 - $ hg diff --git --relative dir1 -r 1:tip 'dir2/{copy}' + $ hg diff --git --root dir1 -r 1:tip 'dir2/{copy}' warning: dir2/{copy} not inside relative root dir1 $ cd dir1 - $ hg diff --git --relative .. -r 1:tip + $ hg diff --git --root .. -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 @@ -118,15 +118,15 @@ Cross and same-directory copies with a r +++ b/dir2/copy @@ -1,1 +1,2 @@ new +copy2 - $ hg diff --git --relative ../.. -r 1:tip + $ hg diff --git --root ../.. -r 1:tip abort: ../.. not under root '$TESTTMP' [255] - $ hg diff --git --relative ../doesnotexist -r 1:tip - $ hg diff --git --relative .. -r 1:tip + $ hg diff --git --root ../doesnotexist -r 1:tip + $ hg diff --git --root .. -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 @@ -140,31 +140,31 @@ Cross and same-directory copies with a r +++ b/dir2/copy @@ -1,1 +1,2 @@ new +copy2 - $ hg diff --git --relative . -r 1:tip + $ hg diff --git --root . -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 + $ hg diff --git --root . -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 + $ hg diff --git --root . -r 1:tip ../dir2 warning: ../dir2 not inside relative root . - $ hg diff --git --relative . -r 1:tip '../dir2/*' + $ hg diff --git --root . -r 1:tip '../dir2/*' warning: ../dir2/* not inside relative root . $ cd .. Rename: @@ -193,11 +193,11 @@ Rename: copy2 +rename2 Cross and same-directory renames with a relative root: - $ hg diff --relative dir1 --git -r 2:tip + $ hg diff --root dir1 --git -r 2:tip diff --git a/copy b/rename1 rename from copy rename to rename1 --- a/copy +++ b/rename1 @@ -212,29 +212,29 @@ Cross and same-directory renames with a @@ -0,0 +1,3 @@ +new +copy2 +rename2 - $ hg diff --relative dir2 --git -r 2:tip + $ hg diff --root 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' + $ hg diff --root 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*' + $ hg diff --root dir1 --git -r 2:tip -I '**/rename*' diff --git a/copy b/rename1 copy from copy copy to rename1 --- a/copy +++ b/rename1 diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -507,11 +507,11 @@ Test command without options -w --ignore-all-space ignore white space when comparing lines -b --ignore-space-change ignore changes in the amount of white space -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 + --root 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 (some details hidden, use --verbose to show complete help)