Submitter | via Mercurial-devel |
---|---|
Date | March 22, 2017, 4:35 a.m. |
Message ID | <e0e123324f205071c806.1490157304@martinvonz.mtv.corp.google.com> |
Download | mbox | patch |
Permalink | /patch/19549/ |
State | Changes Requested |
Headers | show |
Comments
I'm +100 on this patch. We've been doing this in tweakdefaults for ages. Everyone loves it. On 3/22/17 4:35 AM, Martin von Zweigbergk via Mercurial-devel wrote: > # HG changeset patch > # User Martin von Zweigbergk <martinvonz@google.com> > # Date 1490143844 25200 > # Tue Mar 21 17:50:44 2017 -0700 > # Node ID e0e123324f205071c80657079ff83a4e58db862c > # Parent 102f291807c92864a2231e5e925d6cd64783bb59 > status: support commands.status.relative config > > When the config is set to true, status output becomes relative to the > working directory. This has bugged me since I started using hg and it > turns it is sillily simple to support it (unless I missed something, > of course). > > We could also add a --relative flag, but I would personally always > want that on, and I haven't heard any use for having it sometimes on, > so this patch only lets you enable it via config. > > diff -r 102f291807c9 -r e0e123324f20 mercurial/commands.py > --- a/mercurial/commands.py Mon Mar 20 16:34:12 2017 -0700 > +++ b/mercurial/commands.py Tue Mar 21 17:50:44 2017 -0700 > @@ -4734,7 +4734,8 @@ > else: > node1, node2 = scmutil.revpair(repo, revs) > > - if pats: > + if pats or (not ui.plain() and > + ui.configbool('commands', 'status.relative', False)): Style-nits: * The "false" isn't necessary -- that's the default, isn't it? * Also, I think it would be clearer to divide this into two lines: relative = not ui.plain and ui.configbool('commands', 'status.relative') if pats or relative: > cwd = repo.getcwd() > else: > cwd = '' > diff -r 102f291807c9 -r e0e123324f20 mercurial/help/config.txt > --- a/mercurial/help/config.txt Mon Mar 20 16:34:12 2017 -0700 > +++ b/mercurial/help/config.txt Tue Mar 21 17:50:44 2017 -0700 > @@ -417,6 +417,10 @@ > ``commands`` > ---------- > > +``status.relative`` > + Make paths in ``hg status`` output relative to the current directory. > + (default: False) > + > ``update.requiredest`` > Require that the user pass a destination when running ``hg update``. > For example, ``hg update .::`` will be allowed, but a plain ``hg update`` > diff -r 102f291807c9 -r e0e123324f20 tests/test-status.t > --- a/tests/test-status.t Mon Mar 20 16:34:12 2017 -0700 > +++ b/tests/test-status.t Tue Mar 21 17:50:44 2017 -0700 > @@ -40,6 +40,20 @@ > ? ../b/2/in_b_2 > ? ../b/in_b > ? ../in_root > + $ hg --config commands.status.relative=True status --cwd a > + ? 1/in_a_1 > + ? in_a > + ? ../b/1/in_b_1 > + ? ../b/2/in_b_2 > + ? ../b/in_b > + ? ../in_root > + $ HGPLAIN=1 hg --config commands.status.relative=True status --cwd a > + ? a/1/in_a_1 > + ? a/in_a > + ? b/1/in_b_1 > + ? b/2/in_b_2 > + ? b/in_b > + ? in_root > > $ hg status --cwd b > ? a/1/in_a_1 >
On Wed, Mar 22, 2017 at 3:12 AM, Ryan McElroy <rm@fb.com> wrote: > I'm +100 on this patch. We've been doing this in tweakdefaults for ages. > Everyone loves it. > > On 3/22/17 4:35 AM, Martin von Zweigbergk via Mercurial-devel wrote: >> >> # HG changeset patch >> # User Martin von Zweigbergk <martinvonz@google.com> >> # Date 1490143844 25200 >> # Tue Mar 21 17:50:44 2017 -0700 >> # Node ID e0e123324f205071c80657079ff83a4e58db862c >> # Parent 102f291807c92864a2231e5e925d6cd64783bb59 >> status: support commands.status.relative config >> >> When the config is set to true, status output becomes relative to the >> working directory. This has bugged me since I started using hg and it >> turns it is sillily simple to support it (unless I missed something, >> of course). >> >> We could also add a --relative flag, but I would personally always >> want that on, and I haven't heard any use for having it sometimes on, >> so this patch only lets you enable it via config. >> >> diff -r 102f291807c9 -r e0e123324f20 mercurial/commands.py >> --- a/mercurial/commands.py Mon Mar 20 16:34:12 2017 -0700 >> +++ b/mercurial/commands.py Tue Mar 21 17:50:44 2017 -0700 >> @@ -4734,7 +4734,8 @@ >> else: >> node1, node2 = scmutil.revpair(repo, revs) >> - if pats: >> + if pats or (not ui.plain() and >> + ui.configbool('commands', 'status.relative', False)): > > > Style-nits: > * The "false" isn't necessary -- that's the default, isn't it? Ah, thanks. (Guess where I inherited that from :-)) > * Also, I think it would be clearer to divide this into two lines: > > relative = not ui.plain and ui.configbool('commands', 'status.relative') > if pats or relative: As Yuya pointed out, the ui.plain() should probably be done in one place (in ui.py) for all [commands] config, which will make this a little simpler. I still think your proposal is good, so I'll address that in V2. > > > >> cwd = repo.getcwd() >> else: >> cwd = '' >> diff -r 102f291807c9 -r e0e123324f20 mercurial/help/config.txt >> --- a/mercurial/help/config.txt Mon Mar 20 16:34:12 2017 -0700 >> +++ b/mercurial/help/config.txt Tue Mar 21 17:50:44 2017 -0700 >> @@ -417,6 +417,10 @@ >> ``commands`` >> ---------- >> +``status.relative`` >> + Make paths in ``hg status`` output relative to the current directory. >> + (default: False) >> + >> ``update.requiredest`` >> Require that the user pass a destination when running ``hg update``. >> For example, ``hg update .::`` will be allowed, but a plain ``hg >> update`` >> diff -r 102f291807c9 -r e0e123324f20 tests/test-status.t >> --- a/tests/test-status.t Mon Mar 20 16:34:12 2017 -0700 >> +++ b/tests/test-status.t Tue Mar 21 17:50:44 2017 -0700 >> @@ -40,6 +40,20 @@ >> ? ../b/2/in_b_2 >> ? ../b/in_b >> ? ../in_root >> + $ hg --config commands.status.relative=True status --cwd a >> + ? 1/in_a_1 >> + ? in_a >> + ? ../b/1/in_b_1 >> + ? ../b/2/in_b_2 >> + ? ../b/in_b >> + ? ../in_root >> + $ HGPLAIN=1 hg --config commands.status.relative=True status --cwd a >> + ? a/1/in_a_1 >> + ? a/in_a >> + ? b/1/in_b_1 >> + ? b/2/in_b_2 >> + ? b/in_b >> + ? in_root >> $ hg status --cwd b >> ? a/1/in_a_1 >> >
On Wed, Mar 22, 2017 at 8:42 AM, Martin von Zweigbergk <martinvonz@google.com> wrote: > On Wed, Mar 22, 2017 at 3:12 AM, Ryan McElroy <rm@fb.com> wrote: >> I'm +100 on this patch. We've been doing this in tweakdefaults for ages. >> Everyone loves it. >> >> On 3/22/17 4:35 AM, Martin von Zweigbergk via Mercurial-devel wrote: >>> >>> # HG changeset patch >>> # User Martin von Zweigbergk <martinvonz@google.com> >>> # Date 1490143844 25200 >>> # Tue Mar 21 17:50:44 2017 -0700 >>> # Node ID e0e123324f205071c80657079ff83a4e58db862c >>> # Parent 102f291807c92864a2231e5e925d6cd64783bb59 >>> status: support commands.status.relative config >>> >>> When the config is set to true, status output becomes relative to the >>> working directory. This has bugged me since I started using hg and it >>> turns it is sillily simple to support it (unless I missed something, >>> of course). >>> >>> We could also add a --relative flag, but I would personally always >>> want that on, and I haven't heard any use for having it sometimes on, >>> so this patch only lets you enable it via config. >>> >>> diff -r 102f291807c9 -r e0e123324f20 mercurial/commands.py >>> --- a/mercurial/commands.py Mon Mar 20 16:34:12 2017 -0700 >>> +++ b/mercurial/commands.py Tue Mar 21 17:50:44 2017 -0700 >>> @@ -4734,7 +4734,8 @@ >>> else: >>> node1, node2 = scmutil.revpair(repo, revs) >>> - if pats: >>> + if pats or (not ui.plain() and >>> + ui.configbool('commands', 'status.relative', False)): >> >> >> Style-nits: >> * The "false" isn't necessary -- that's the default, isn't it? > > Ah, thanks. (Guess where I inherited that from :-)) > >> * Also, I think it would be clearer to divide this into two lines: >> >> relative = not ui.plain and ui.configbool('commands', 'status.relative') >> if pats or relative: > > As Yuya pointed out, the ui.plain() should probably be done in one > place (in ui.py) for all [commands] config, which will make this a > little simpler. I still think your proposal is good, so I'll address > that in V2. Actually, after the "not ui.plain() and" and the unnecessary False were removed, it got pretty simple, so I'm leaving on one line. > >> >> >> >>> cwd = repo.getcwd() >>> else: >>> cwd = '' >>> diff -r 102f291807c9 -r e0e123324f20 mercurial/help/config.txt >>> --- a/mercurial/help/config.txt Mon Mar 20 16:34:12 2017 -0700 >>> +++ b/mercurial/help/config.txt Tue Mar 21 17:50:44 2017 -0700 >>> @@ -417,6 +417,10 @@ >>> ``commands`` >>> ---------- >>> +``status.relative`` >>> + Make paths in ``hg status`` output relative to the current directory. >>> + (default: False) >>> + >>> ``update.requiredest`` >>> Require that the user pass a destination when running ``hg update``. >>> For example, ``hg update .::`` will be allowed, but a plain ``hg >>> update`` >>> diff -r 102f291807c9 -r e0e123324f20 tests/test-status.t >>> --- a/tests/test-status.t Mon Mar 20 16:34:12 2017 -0700 >>> +++ b/tests/test-status.t Tue Mar 21 17:50:44 2017 -0700 >>> @@ -40,6 +40,20 @@ >>> ? ../b/2/in_b_2 >>> ? ../b/in_b >>> ? ../in_root >>> + $ hg --config commands.status.relative=True status --cwd a >>> + ? 1/in_a_1 >>> + ? in_a >>> + ? ../b/1/in_b_1 >>> + ? ../b/2/in_b_2 >>> + ? ../b/in_b >>> + ? ../in_root >>> + $ HGPLAIN=1 hg --config commands.status.relative=True status --cwd a >>> + ? a/1/in_a_1 >>> + ? a/in_a >>> + ? b/1/in_b_1 >>> + ? b/2/in_b_2 >>> + ? b/in_b >>> + ? in_root >>> $ hg status --cwd b >>> ? a/1/in_a_1 >>> >>
Patch
diff -r 102f291807c9 -r e0e123324f20 mercurial/commands.py --- a/mercurial/commands.py Mon Mar 20 16:34:12 2017 -0700 +++ b/mercurial/commands.py Tue Mar 21 17:50:44 2017 -0700 @@ -4734,7 +4734,8 @@ else: node1, node2 = scmutil.revpair(repo, revs) - if pats: + if pats or (not ui.plain() and + ui.configbool('commands', 'status.relative', False)): cwd = repo.getcwd() else: cwd = '' diff -r 102f291807c9 -r e0e123324f20 mercurial/help/config.txt --- a/mercurial/help/config.txt Mon Mar 20 16:34:12 2017 -0700 +++ b/mercurial/help/config.txt Tue Mar 21 17:50:44 2017 -0700 @@ -417,6 +417,10 @@ ``commands`` ---------- +``status.relative`` + Make paths in ``hg status`` output relative to the current directory. + (default: False) + ``update.requiredest`` Require that the user pass a destination when running ``hg update``. For example, ``hg update .::`` will be allowed, but a plain ``hg update`` diff -r 102f291807c9 -r e0e123324f20 tests/test-status.t --- a/tests/test-status.t Mon Mar 20 16:34:12 2017 -0700 +++ b/tests/test-status.t Tue Mar 21 17:50:44 2017 -0700 @@ -40,6 +40,20 @@ ? ../b/2/in_b_2 ? ../b/in_b ? ../in_root + $ hg --config commands.status.relative=True status --cwd a + ? 1/in_a_1 + ? in_a + ? ../b/1/in_b_1 + ? ../b/2/in_b_2 + ? ../b/in_b + ? ../in_root + $ HGPLAIN=1 hg --config commands.status.relative=True status --cwd a + ? a/1/in_a_1 + ? a/in_a + ? b/1/in_b_1 + ? b/2/in_b_2 + ? b/in_b + ? in_root $ hg status --cwd b ? a/1/in_a_1