Submitter | phabricator |
---|---|
Date | Aug. 3, 2017, 4:08 a.m. |
Message ID | <differential-rev-PHID-DREV-s5rfq55e2wuquiecptga-req@phab.mercurial-scm.org> |
Download | mbox | patch |
Permalink | /patch/22655/ |
State | Superseded |
Headers | show |
Comments
pulkit added a subscriber: durham. pulkit added a comment. @durham and I thought on the flag name and had '--more' and '--repo-state' in our mind. Since '--repo-state' is more explicit, I went with that. Need suggestions for a better flag name. :) REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers Cc: durham, mercurial-devel
martinvonz added a comment.
In https://phab.mercurial-scm.org/D219#3558, @pulkit wrote:
> @durham and I thought on the flag name and had '--more' and '--repo-state' in our mind. Since '--repo-state' is more explicit, I went with that. Need suggestions for a better flag name. :)
Do we need a flag? Why not just a config option (whose value is ignored with HGPLAIN)?
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D219
To: pulkit, #hg-reviewers
Cc: martinvonz, durham, mercurial-devel
akushner added a comment. So what does '--verbose' do for status currently? Didn't seem to do anything. Can this output be for verbose? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers Cc: akushner, martinvonz, durham, mercurial-devel
martinvonz added a comment.
In https://phab.mercurial-scm.org/D219#3562, @akushner wrote:
> So what does '--verbose' do for status currently? Didn't seem to do anything. Can this output be for verbose?
Good question. From https://www.mercurial-scm.org/wiki/CompatibilityRules#Commands: "Adding messages at the verbose level is also usually acceptable."
I think it makes sense for this output to be part of the verbose form.
It would still be nice to have a config option for it. I don't like "morestatus" for that. I would think it should be in commands.status (along with ".relative"). Maybe commands.status.verbose=1 to enable it if we decide to use the --verbose flag for it.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D219
To: pulkit, #hg-reviewers
Cc: akushner, martinvonz, durham, mercurial-devel
akushner added a comment. @martinvonz - I like the commands.status.verbose=1 option. I think the verbose form of status makes sense when there's a large body of unsophisticated source control users and the more details on how to get out of the current predicament, the better. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers Cc: akushner, martinvonz, durham, mercurial-devel
pulkit added a comment. @akushner @martinvonz : thanks for suggestions. I also like the --verbose option, I will send a new version with that. @martinvonz: Since you don't like 'morestatus' much, shall I place the skipstates option which skips some states under some different config name, maybe status.skipstates? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers Cc: akushner, martinvonz, durham, mercurial-devel
martinvonz added a comment. In https://phab.mercurial-scm.org/D219#3566, @pulkit wrote: > @akushner @martinvonz : thanks for suggestions. I also like the --verbose option, I will send a new version with that. > @martinvonz: Since you don't like 'morestatus' much, shall I place the skipstates option which skips some states under some different config name, maybe status.skipstates? I'm not 100% sure, but I think we're trying to put command-specific configs under command.<command>, so it would probably be commands.status.skipstates. Also, shouldn't you be putting it in configitems.py? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers Cc: akushner, martinvonz, durham, mercurial-devel
quark added a comment. Maybe this is a good case for the new release note extension. According to https://www.mercurial-scm.org/wiki/ReleasenotesExtension having the following in commit message would be helpful: .. feature:: ``hg status -v`` can now show unfinished state. For example, when in an unfinished rebase state, ``hg status -v`` might show:: # The repository is in an unfinished *rebase* state. # No unresolved merge conflicts. # To continue: hg rebase --continue # To abort: hg rebase --abort I'm thinking about the difference between the deprecated `[defaults]` and `[commands]` (and also `[alias]`) but don't quite get it. It seems people wanting the behavior might just set `alias.status = status -v`, or use `[defaults]`. What's the advantage of using a `[commands]` option? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers Cc: quark, akushner, martinvonz, durham, mercurial-devel
martinvonz added a comment.
In https://phab.mercurial-scm.org/D219#3661, @quark wrote:
> I'm thinking about the difference between the deprecated `[defaults]` and `[commands]` (and also `[alias]`) but don't quite get it. It seems people wanting the behavior might just set `alias.status = status -v`, or use `[defaults]`. What's the advantage of using a `[commands]` option?
Good point, there's probably no good reason to use [commands] for this. [defaults] has been discouraged, but I don't know if there's a good reason to discourage it (I think it's already ignored when HGPLAIN is in effect). [commands] make sense when there's no command line flag for the behavior, but we do have that here. So if we agree on using --verbose for this, I don't think I see a reason to a special config for it and we can use [defaults] instead.
Hmm, I just realized there is a somewhat good reason to avoid [defaults]: it applies to *all* options at once. Let me clarify with an example. Let's say your sysadmin has set "defaults.status = --relative" (hypothetical option -- it's currently a config in [commands]) and you want to keep that *and* get verbose status output, you now have to copy the default config from the system hgrc. I don't think I've heard that argument against [defaults] before, but that seems more relevant than the scripting argument (which, again, goes away with HGPLAIN). Or am I mistaken?
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D219
To: pulkit, #hg-reviewers
Cc: quark, akushner, martinvonz, durham, mercurial-devel
durin42 requested changes to this revision. durin42 added a comment. This revision now requires changes to proceed. In https://phab.mercurial-scm.org/D219#3755, @martinvonz wrote: > In https://phab.mercurial-scm.org/D219#3661, @quark wrote: > > > I'm thinking about the difference between the deprecated `[defaults]` and `[commands]` (and also `[alias]`) but don't quite get it. It seems people wanting the behavior might just set `alias.status = status -v`, or use `[defaults]`. What's the advantage of using a `[commands]` option? > > > Good point, there's probably no good reason to use [commands] for this. [defaults] has been discouraged, but I don't know if there's a good reason to discourage it (I think it's already ignored when HGPLAIN is in effect). The discouragement is twofold: we didn't used to have HGPLAIN, and it used to be there was no way to un-do the setting of a boolean flag in [defaults]. Both of those limitations are now fixed, so I'm less worried about it overall. That said, I would like a config knob for this, so it can be part of ui.tweakdefaults. > [commands] make sense when there's no command line flag for the behavior, but we do have that here. So if we agree on using --verbose for this, I don't think I see a reason to a special config for it and we can use [defaults] instead. > > Hmm, I just realized there is a somewhat good reason to avoid [defaults]: it applies to *all* options at once. Let me clarify with an example. Let's say your sysadmin has set "defaults.status = --relative" (hypothetical option -- it's currently a config in [commands]) and you want to keep that *and* get verbose status output, you now have to copy the default config from the system hgrc. I don't think I've heard that argument against [defaults] before, but that seems more relevant than the scripting argument (which, again, goes away with HGPLAIN). Or am I mistaken? That's another argument in favor of a config knob IMO. I'm not sure if --verbose should be (ab)used for this, given that we've got --terse. --verbose almost sounds like the opposite of --terse, so it might be confusing. Meditate on that, I guess. (Marking as "Request changes" for now, since we seem largely agreed that --verbose is a decent way to go, and if nobody else is worried about the conceptual overlap with --terse I'm fine with it, especially since I more or less expect this to be on in tweakdefaults soon.) REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers, durin42 Cc: durin42, quark, akushner, martinvonz, durham, mercurial-devel
durin42 accepted this revision as: durin42. durin42 added a comment. I'm still a tiny bit worried about potential confusion between --terse and --verbose (in that they're not opposites), but I'm also fine with this. I'll take it in a couple of days if I don't hear any objections. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers, durin42 Cc: durin42, quark, akushner, martinvonz, durham, mercurial-devel
pulkit added a comment.
In https://phab.mercurial-scm.org/D219#4343, @durin42 wrote:
> I'm still a tiny bit worried about potential confusion between --terse and --verbose (in that they're not opposites), but I'm also fine with this. I'll take it in a couple of days if I don't hear any objections.
Currently if we pass do `hg log --terse u --verbose`, it will still terse the output. I think the best way is to document that --verbose and --terse are not opposites.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D219
To: pulkit, #hg-reviewers, durin42
Cc: durin42, quark, akushner, martinvonz, durham, mercurial-devel
durin42 accepted this revision. durin42 added a comment. This revision is now accepted and ready to land. I've heard no objections, but also the suggestion that --terse be something like --terse-dirs or similar so it's obviously not the antonym of --verbose. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers, durin42 Cc: durin42, quark, akushner, martinvonz, durham, mercurial-devel
durin42 (Augie Fackler) wrote: > I've heard no objections, but also the suggestion that --terse be > something like --terse-dirs or similar so it's obviously not the antonym > of --verbose. Maybe --collapse? I think that's what you do when you've got a directory tree in a GUI and you rotate the little triangle thingie, which is pretty much what --terse does. Danek
martinvonz added inline comments. INLINE COMMENTS > test-bisect.t:190 > + > + None > + # To mark the changeset good: hg bisect --good What does None mean here? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers, durin42 Cc: durin42, quark, akushner, martinvonz, durham, mercurial-devel
pulkit added inline comments. INLINE COMMENTS > martinvonz wrote in test-bisect.t:190 > What does None mean here? Oh, _conflictsmsg() is returning None which is getting printed. I will send a follow-up for this. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D219 To: pulkit, #hg-reviewers, durin42 Cc: durin42, quark, akushner, martinvonz, durham, mercurial-devel
Patch
diff --git a/tests/test-shelve.t b/tests/test-shelve.t --- a/tests/test-shelve.t +++ b/tests/test-shelve.t @@ -342,6 +342,23 @@ warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark') unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') [1] + $ hg status --repo-state + M a/a + M b.rename/b + M c.copy + R b/b + ? a/a.orig + # The repository is in an unfinished *unshelve* state. + + # Unresolved merge conflicts: + # + # a/a + # + # To mark files as resolved: hg resolve --mark FILE + + # To continue: hg unshelve --continue + # To abort: hg unshelve --abort + ensure that we have a merge with unresolved conflicts diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t --- a/tests/test-rebase-conflicts.t +++ b/tests/test-rebase-conflicts.t @@ -71,6 +71,21 @@ unresolved conflicts (see hg resolve, then hg rebase --continue) [1] + $ hg status --repo-state + M common + ? common.orig + # The repository is in an unfinished *rebase* state. + + # Unresolved merge conflicts: + # + # common + # + # To mark files as resolved: hg resolve --mark FILE + + # To continue: hg rebase --continue + # To abort: hg rebase --abort + + Try to continue without solving the conflict: $ hg rebase --continue diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t --- a/tests/test-histedit-fold.t +++ b/tests/test-histedit-fold.t @@ -294,9 +294,20 @@ [1] There were conflicts, we keep P1 content. This should effectively drop the changes from +6. - $ hg status + $ hg status --repo-state M file ? file.orig + # The repository is in an unfinished *histedit* state. + + # Unresolved merge conflicts: + # + # file + # + # To mark files as resolved: hg resolve --mark FILE + + # To continue: hg histedit --continue + # To abort: hg histedit --abort + $ hg resolve -l U file $ hg revert -r 'p1()' file diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -617,6 +617,7 @@ -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 + --repo-state show the state of the repo -I --include PATTERN [+] include names matching the given patterns -X --exclude PATTERN [+] exclude names matching the given patterns -S --subrepos recurse into subrepositories diff --git a/tests/test-graft.t b/tests/test-graft.t --- a/tests/test-graft.t +++ b/tests/test-graft.t @@ -221,6 +221,25 @@ $ hg summary |grep graft commit: 2 modified, 2 unknown, 1 unresolved (graft in progress) +Using status to get more context + + $ hg status --repo-state + M d + M e + ? a.orig + ? e.orig + # The repository is in an unfinished *graft* state. + + # Unresolved merge conflicts: + # + # e + # + # To mark files as resolved: hg resolve --mark FILE + + # To continue: hg graft --continue + # To abort: hg update --clean . (warning: this will discard uncommitted changes) + + Commit while interrupted should fail: $ hg ci -m 'commit interrupted graft' diff --git a/tests/test-conflict.t b/tests/test-conflict.t --- a/tests/test-conflict.t +++ b/tests/test-conflict.t @@ -44,6 +44,21 @@ $ hg id 618808747361+c0c68e4fe667+ tip + $ hg status --repo-state + M a + ? a.orig + # The repository is in an unfinished *merge* state. + + # Unresolved merge conflicts: + # + # a + # + # To mark files as resolved: hg resolve --mark FILE + + # To continue: hg commit + # To abort: hg update --clean . (warning: this will discard uncommitted changes) + + $ cat a Small Mathematical Series. 1 diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -231,7 +231,7 @@ push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure remove: after, force, subrepos, include, exclude serve: accesslog, daemon, daemon-postexec, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate, subrepos - status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, include, exclude, subrepos, template + status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, terse, copies, print0, rev, change, repo-state, include, exclude, subrepos, template summary: remote update: clean, check, merge, date, rev, tool addremove: similarity, subrepos, include, exclude, dry-run diff --git a/tests/test-bisect.t b/tests/test-bisect.t --- a/tests/test-bisect.t +++ b/tests/test-bisect.t @@ -184,6 +184,15 @@ $ hg bisect -r $ hg bisect -b + $ hg status --repo-state + # The repository is in an unfinished *bisect* state. + + None + # To mark the changeset good: hg bisect --good + # To mark the changeset bad: hg bisect --bad + # To abort: hg bisect --reset + + $ hg status --repo-state --config morestatus.skipstates=bisect $ hg summary parent: 31:58c80a7c8a40 tip msg 31 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -4659,6 +4659,7 @@ ('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')), + ('', 'repo-state', None, _('show the state of the repo')), ] + walkopts + subrepoopts + formatteropts, _('[OPTION]... [FILE]...'), inferrepo=True) @@ -4710,6 +4711,17 @@ files are not considered while tersing until 'i' is there in --terse value or the --ignored option is used. + The --repo-state option shows more context about the state of the repo + like the repository is in unfinised merge, shelve, rebase state etc. + + You can switch the --repo-state option on permanently as follows: + + [morestatus] + show = true + + You can also skip some states like bisect by setting + ``morestatus.skipstates = bisect`` in configuration file. + Examples: - show changes in the working directory relative to a @@ -4799,6 +4811,10 @@ if f in copy: fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd), label='status.copied') + + if (opts.get('repo_state') or + (ui.configbool('morestatus', 'show', False) and not ui.plain())): + cmdutil.morestatus(repo, fm) fm.end() @command('^summary|sum', diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -572,6 +572,111 @@ return finalrs +def _commentlines(raw): + '''Surround lineswith a comment char and a new line''' + lines = raw.splitlines() + commentedlines = ['# %s' % line for line in lines] + return '\n'.join(commentedlines) + '\n' + +def _conflictsmsg(repo): + # avoid merge cycle + from . import merge as mergemod + mergestate = mergemod.mergestate.read(repo) + if not mergestate.active(): + return + + m = scmutil.match(repo[None]) + unresolvedlist = [f for f in mergestate if m(f) and mergestate[f] == 'u'] + if unresolvedlist: + mergeliststr = '\n'.join( + [' %s' % os.path.relpath( + os.path.join(repo.root, path), + pycompat.getcwd()) for path in unresolvedlist]) + msg = _('''Unresolved merge conflicts: + +%s + +To mark files as resolved: hg resolve --mark FILE''') % mergeliststr + else: + msg = _('No unresolved merge conflicts.') + + return _commentlines(msg) + +def _helpmessage(continuecmd, abortcmd): + msg = _('To continue: %s\n' + 'To abort: %s') % (continuecmd, abortcmd) + return _commentlines(msg) + +def _rebasemsg(): + return _helpmessage('hg rebase --continue', 'hg rebase --abort') + +def _histeditmsg(): + return _helpmessage('hg histedit --continue', 'hg histedit --abort') + +def _unshelvemsg(): + return _helpmessage('hg unshelve --continue', 'hg unshelve --abort') + +def _updatecleanmsg(dest=None): + warning = _('warning: this will discard uncommitted changes') + return 'hg update --clean %s (%s)' % (dest or '.', warning) + +def _graftmsg(): + # tweakdefaults requires `update` to have a rev hence the `.` + return _helpmessage('hg graft --continue', _updatecleanmsg()) + +def _mergemsg(): + # tweakdefaults requires `update` to have a rev hence the `.` + return _helpmessage('hg commit', _updatecleanmsg()) + +def _bisectmsg(): + msg = _('To mark the changeset good: hg bisect --good\n' + 'To mark the changeset bad: hg bisect --bad\n' + 'To abort: hg bisect --reset\n') + return _commentlines(msg) + +def fileexistspredicate(filename): + return lambda repo: repo.vfs.exists(filename) + +def _mergepredicate(repo): + return len(repo[None].parents()) > 1 + +STATES = ( + # (state, predicate to detect states, helpful message function) + ('histedit', fileexistspredicate('histedit-state'), _histeditmsg), + ('bisect', fileexistspredicate('bisect.state'), _bisectmsg), + ('graft', fileexistspredicate('graftstate'), _graftmsg), + ('unshelve', fileexistspredicate('unshelverebasestate'), _unshelvemsg), + ('rebase', fileexistspredicate('rebasestate'), _rebasemsg), + # The merge state is part of a list that will be iterated over. + # They need to be last because some of the other unfinished states may also + # be in a merge or update state (eg. rebase, histedit, graft, etc). + # We want those to have priority. + ('merge', _mergepredicate, _mergemsg), +) + +def _getrepostate(repo): + # experimental config: morestatus.skipstates + skip = set(repo.ui.configlist('morestatus', 'skipstates', [])) + for state, statedetectionpredicate, msgfn in STATES: + if state in skip: + continue + if statedetectionpredicate(repo): + return (state, statedetectionpredicate, msgfn) + +def morestatus(repo, fm): + statetuple = _getrepostate(repo) + label = 'status.morestatus' + if statetuple: + fm.startitem() + state, statedetectionpredicate, helpfulmsg = statetuple + statemsg = _('The repository is in an unfinished *%s* state.') % state + fm.write('statemsg', '%s\n', _commentlines(statemsg), label=label) + conmsg = _conflictsmsg(repo) + fm.write('conflictsmsg', '%s\n', conmsg, label=label) + if helpfulmsg: + helpmsg = helpfulmsg() + fm.write('helpmsg', '%s\n', helpmsg, label=label) + def findpossible(cmd, table, strict=False): """ Return cmd -> (aliases, command table entry)