Submitter | Sean Farley |
---|---|
Date | March 25, 2015, 5:46 a.m. |
Message ID | <f9e43618a84b4ce1de23.1427262416@1.0.0.127.in-addr.arpa> |
Download | mbox | patch |
Permalink | /patch/8256/ |
State | Changes Requested |
Headers | show |
Comments
On 3/24/2015 10:46 PM, Sean Farley wrote: > # HG changeset patch > # User Yung-Jin (Joey) Hu <yungjinhu@gmail.com> > # Date 1426736402 25200 > # Wed Mar 18 20:40:02 2015 -0700 > # Node ID f9e43618a84b4ce1de23c8cdf22de5e9bcadafdd > # Parent 5b85a5bc5bbb9d8365953609d98e4dce7110e9b0 > status: add relative option flag (issue3835) > > Previously, you had to send the root of the repo to get the relative files of > the entire repo. > > hg status $(hg root) > > This had the downside of involking running mercurial twice. Instead let's just > add a flag and be done with it. > > diff --git a/mercurial/commands.py b/mercurial/commands.py > --- a/mercurial/commands.py > +++ b/mercurial/commands.py > @@ -5686,10 +5686,12 @@ class httpservice(object): > ('n', 'no-status', None, _('hide status prefix')), > ('C', 'copies', None, _('show source of copied files')), > ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), > ('', 'rev', [], _('show difference from revision'), _('REV')), > ('', 'change', '', _('list the changed files of a revision'), _('REV')), > + ('', 'relative', None, > + ('list the changed files relative to working directory')), > ] + walkopts + subrepoopts + formatteropts, > _('[OPTION]... [FILE]...'), > inferrepo=True) > def status(ui, repo, *pats, **opts): > """show changed files in the working directory > @@ -5757,11 +5759,17 @@ def status(ui, repo, *pats, **opts): > node2 = scmutil.revsingle(repo, change, None).node() > node1 = repo[node2].p1().node() > else: > node1, node2 = scmutil.revpair(repo, revs) > > - if pats: > + relative = opts.get('relative') > + > + if pats and relative: > + msg = _('cannot specify path and --relative at the same time') > + raise util.Abort(msg) > + > + if pats or relative: > cwd = repo.getcwd() > else: > cwd = '' > > if opts.get('print0'): > diff --git a/tests/test-completion.t b/tests/test-completion.t > --- a/tests/test-completion.t > +++ b/tests/test-completion.t > @@ -211,11 +211,11 @@ Show all commands + options > merge: force, rev, preview, tool > pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure > push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure > remove: after, force, subrepos, include, exclude > serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate > - status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template > + status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, relative, include, exclude, subrepos, template > summary: remote > update: clean, check, date, rev, tool > addremove: similarity, subrepos, include, exclude, dry-run > archive: no-decode, prefix, rev, type, subrepos, include, exclude > backout: merge, commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user > diff --git a/tests/test-help.t b/tests/test-help.t > --- a/tests/test-help.t > +++ b/tests/test-help.t > @@ -569,10 +569,11 @@ Test command without options > -n --no-status hide status prefix > -C --copies show source of copied files > -0 --print0 end filenames with NUL, for use with xargs > --rev REV [+] show difference from revision > --change REV list the changed files of a revision > + --relative list the changed files relative to working directory > -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) > diff --git a/tests/test-status.t b/tests/test-status.t > --- a/tests/test-status.t > +++ b/tests/test-status.t > @@ -99,10 +99,22 @@ hg status . in repo root: > $ hg status --cwd b/2 .. > ? ../1/in_b_1 > ? in_b_2 > ? ../in_b > > +test status relative flag > + > + $ cd b/2 > + $ hg status --relative > + ? ../../a/1/in_a_1 > + ? ../../a/in_a > + ? ../1/in_b_1 > + ? in_b_2 > + ? ../in_b > + ? ../../in_root > + $ cd ../.. > + > combining patterns with root and patterns without a root works > > $ hg st a/in_a re:.*b$ > ? a/in_a > ? b/in_b > I'm so happy to see this patch! Now I will be able to reduce the complexity of my "hg st" alias, from: !$HG status $($HG root) -C $@ && $HG resolve --list to simply: !$HG status --relative -C $@ && $HG resolve --list I've played around with this patch and it looks good to me. Thanks! ~Ryan
On Tue, 24 Mar 2015 22:46:56 -0700, Sean Farley wrote: > # HG changeset patch > # User Yung-Jin (Joey) Hu <yungjinhu@gmail.com> > # Date 1426736402 25200 > # Wed Mar 18 20:40:02 2015 -0700 > # Node ID f9e43618a84b4ce1de23c8cdf22de5e9bcadafdd > # Parent 5b85a5bc5bbb9d8365953609d98e4dce7110e9b0 > status: add relative option flag (issue3835) > > Previously, you had to send the root of the repo to get the relative files of > the entire repo. > > hg status $(hg root) > > This had the downside of involking running mercurial twice. Instead let's just > add a flag and be done with it. > > diff --git a/mercurial/commands.py b/mercurial/commands.py > --- a/mercurial/commands.py > +++ b/mercurial/commands.py > @@ -5686,10 +5686,12 @@ class httpservice(object): > ('n', 'no-status', None, _('hide status prefix')), > ('C', 'copies', None, _('show source of copied files')), > ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), > ('', 'rev', [], _('show difference from revision'), _('REV')), > ('', 'change', '', _('list the changed files of a revision'), _('REV')), > + ('', 'relative', None, > + ('list the changed files relative to working directory')), > ] + walkopts + subrepoopts + formatteropts, > _('[OPTION]... [FILE]...'), > inferrepo=True) > def status(ui, repo, *pats, **opts): > """show changed files in the working directory > @@ -5757,11 +5759,17 @@ def status(ui, repo, *pats, **opts): > node2 = scmutil.revsingle(repo, change, None).node() > node1 = repo[node2].p1().node() > else: > node1, node2 = scmutil.revpair(repo, revs) > > - if pats: > + relative = opts.get('relative') > + > + if pats and relative: > + msg = _('cannot specify path and --relative at the same time') > + raise util.Abort(msg) It's a little confusing to me that there are two variants of --relative. hg diff --relative PATH - takes PATH - filtered by PATH hg status --relative - boolean - not filtered by $PWD Regards,
Yuya Nishihara <yuya@tcha.org> writes: > On Tue, 24 Mar 2015 22:46:56 -0700, Sean Farley wrote: >> # HG changeset patch >> # User Yung-Jin (Joey) Hu <yungjinhu@gmail.com> >> # Date 1426736402 25200 >> # Wed Mar 18 20:40:02 2015 -0700 >> # Node ID f9e43618a84b4ce1de23c8cdf22de5e9bcadafdd >> # Parent 5b85a5bc5bbb9d8365953609d98e4dce7110e9b0 >> status: add relative option flag (issue3835) >> >> Previously, you had to send the root of the repo to get the relative files of >> the entire repo. >> >> hg status $(hg root) >> >> This had the downside of involking running mercurial twice. Instead let's just >> add a flag and be done with it. >> >> diff --git a/mercurial/commands.py b/mercurial/commands.py >> --- a/mercurial/commands.py >> +++ b/mercurial/commands.py >> @@ -5686,10 +5686,12 @@ class httpservice(object): >> ('n', 'no-status', None, _('hide status prefix')), >> ('C', 'copies', None, _('show source of copied files')), >> ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), >> ('', 'rev', [], _('show difference from revision'), _('REV')), >> ('', 'change', '', _('list the changed files of a revision'), _('REV')), >> + ('', 'relative', None, >> + ('list the changed files relative to working directory')), >> ] + walkopts + subrepoopts + formatteropts, >> _('[OPTION]... [FILE]...'), >> inferrepo=True) >> def status(ui, repo, *pats, **opts): >> """show changed files in the working directory >> @@ -5757,11 +5759,17 @@ def status(ui, repo, *pats, **opts): >> node2 = scmutil.revsingle(repo, change, None).node() >> node1 = repo[node2].p1().node() >> else: >> node1, node2 = scmutil.revpair(repo, revs) >> >> - if pats: >> + relative = opts.get('relative') >> + >> + if pats and relative: >> + msg = _('cannot specify path and --relative at the same time') >> + raise util.Abort(msg) > > It's a little confusing to me that there are two variants of --relative. > > hg diff --relative PATH > > - takes PATH > - filtered by PATH > > hg status --relative > > - boolean > - not filtered by $PWD This is a good point. After some talking with Sid and Ryan, we're thinking about renamign the diff flag to --root: hg diff --root PATH hg status --relative
On Tue, 2015-03-24 at 22:46 -0700, Sean Farley wrote: > # HG changeset patch > # User Yung-Jin (Joey) Hu <yungjinhu@gmail.com> > # Date 1426736402 25200 > # Wed Mar 18 20:40:02 2015 -0700 > # Node ID f9e43618a84b4ce1de23c8cdf22de5e9bcadafdd > # Parent 5b85a5bc5bbb9d8365953609d98e4dce7110e9b0 > status: add relative option flag (issue3835) > > Previously, you had to send the root of the repo to get the relative files of > the entire repo. > > hg status $(hg root) After discussing the low marginal utility of this feature on IRC, we'll probably instead document one of the existing ways to do this (like hg st "" or hg st re:) as a help example.
Patch
diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5686,10 +5686,12 @@ class httpservice(object): ('n', 'no-status', None, _('hide status prefix')), ('C', 'copies', None, _('show source of copied files')), ('0', 'print0', None, _('end filenames with NUL, for use with xargs')), ('', 'rev', [], _('show difference from revision'), _('REV')), ('', 'change', '', _('list the changed files of a revision'), _('REV')), + ('', 'relative', None, + ('list the changed files relative to working directory')), ] + walkopts + subrepoopts + formatteropts, _('[OPTION]... [FILE]...'), inferrepo=True) def status(ui, repo, *pats, **opts): """show changed files in the working directory @@ -5757,11 +5759,17 @@ def status(ui, repo, *pats, **opts): node2 = scmutil.revsingle(repo, change, None).node() node1 = repo[node2].p1().node() else: node1, node2 = scmutil.revpair(repo, revs) - if pats: + relative = opts.get('relative') + + if pats and relative: + msg = _('cannot specify path and --relative at the same time') + raise util.Abort(msg) + + if pats or relative: cwd = repo.getcwd() else: cwd = '' if opts.get('print0'): diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -211,11 +211,11 @@ Show all commands + options merge: force, rev, preview, tool pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure remove: after, force, subrepos, include, exclude serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate - status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template + status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, relative, include, exclude, subrepos, template summary: remote update: clean, check, date, rev, tool addremove: similarity, subrepos, include, exclude, dry-run archive: no-decode, prefix, rev, type, subrepos, include, exclude backout: merge, commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -569,10 +569,11 @@ Test command without options -n --no-status hide status prefix -C --copies show source of copied files -0 --print0 end filenames with NUL, for use with xargs --rev REV [+] show difference from revision --change REV list the changed files of a revision + --relative list the changed files relative to working directory -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) diff --git a/tests/test-status.t b/tests/test-status.t --- a/tests/test-status.t +++ b/tests/test-status.t @@ -99,10 +99,22 @@ hg status . in repo root: $ hg status --cwd b/2 .. ? ../1/in_b_1 ? in_b_2 ? ../in_b +test status relative flag + + $ cd b/2 + $ hg status --relative + ? ../../a/1/in_a_1 + ? ../../a/in_a + ? ../1/in_b_1 + ? in_b_2 + ? ../in_b + ? ../../in_root + $ cd ../.. + combining patterns with root and patterns without a root works $ hg st a/in_a re:.*b$ ? a/in_a ? b/in_b