Show More
@@ -573,6 +573,111 b' def tersestatus(root, statlist, status, ' | |||||
573 |
|
573 | |||
574 | return finalrs |
|
574 | return finalrs | |
575 |
|
575 | |||
|
576 | def _commentlines(raw): | |||
|
577 | '''Surround lineswith a comment char and a new line''' | |||
|
578 | lines = raw.splitlines() | |||
|
579 | commentedlines = ['# %s' % line for line in lines] | |||
|
580 | return '\n'.join(commentedlines) + '\n' | |||
|
581 | ||||
|
582 | def _conflictsmsg(repo): | |||
|
583 | # avoid merge cycle | |||
|
584 | from . import merge as mergemod | |||
|
585 | mergestate = mergemod.mergestate.read(repo) | |||
|
586 | if not mergestate.active(): | |||
|
587 | return | |||
|
588 | ||||
|
589 | m = scmutil.match(repo[None]) | |||
|
590 | unresolvedlist = [f for f in mergestate if m(f) and mergestate[f] == 'u'] | |||
|
591 | if unresolvedlist: | |||
|
592 | mergeliststr = '\n'.join( | |||
|
593 | [' %s' % os.path.relpath( | |||
|
594 | os.path.join(repo.root, path), | |||
|
595 | pycompat.getcwd()) for path in unresolvedlist]) | |||
|
596 | msg = _('''Unresolved merge conflicts: | |||
|
597 | ||||
|
598 | %s | |||
|
599 | ||||
|
600 | To mark files as resolved: hg resolve --mark FILE''') % mergeliststr | |||
|
601 | else: | |||
|
602 | msg = _('No unresolved merge conflicts.') | |||
|
603 | ||||
|
604 | return _commentlines(msg) | |||
|
605 | ||||
|
606 | def _helpmessage(continuecmd, abortcmd): | |||
|
607 | msg = _('To continue: %s\n' | |||
|
608 | 'To abort: %s') % (continuecmd, abortcmd) | |||
|
609 | return _commentlines(msg) | |||
|
610 | ||||
|
611 | def _rebasemsg(): | |||
|
612 | return _helpmessage('hg rebase --continue', 'hg rebase --abort') | |||
|
613 | ||||
|
614 | def _histeditmsg(): | |||
|
615 | return _helpmessage('hg histedit --continue', 'hg histedit --abort') | |||
|
616 | ||||
|
617 | def _unshelvemsg(): | |||
|
618 | return _helpmessage('hg unshelve --continue', 'hg unshelve --abort') | |||
|
619 | ||||
|
620 | def _updatecleanmsg(dest=None): | |||
|
621 | warning = _('warning: this will discard uncommitted changes') | |||
|
622 | return 'hg update --clean %s (%s)' % (dest or '.', warning) | |||
|
623 | ||||
|
624 | def _graftmsg(): | |||
|
625 | # tweakdefaults requires `update` to have a rev hence the `.` | |||
|
626 | return _helpmessage('hg graft --continue', _updatecleanmsg()) | |||
|
627 | ||||
|
628 | def _mergemsg(): | |||
|
629 | # tweakdefaults requires `update` to have a rev hence the `.` | |||
|
630 | return _helpmessage('hg commit', _updatecleanmsg()) | |||
|
631 | ||||
|
632 | def _bisectmsg(): | |||
|
633 | msg = _('To mark the changeset good: hg bisect --good\n' | |||
|
634 | 'To mark the changeset bad: hg bisect --bad\n' | |||
|
635 | 'To abort: hg bisect --reset\n') | |||
|
636 | return _commentlines(msg) | |||
|
637 | ||||
|
638 | def fileexistspredicate(filename): | |||
|
639 | return lambda repo: repo.vfs.exists(filename) | |||
|
640 | ||||
|
641 | def _mergepredicate(repo): | |||
|
642 | return len(repo[None].parents()) > 1 | |||
|
643 | ||||
|
644 | STATES = ( | |||
|
645 | # (state, predicate to detect states, helpful message function) | |||
|
646 | ('histedit', fileexistspredicate('histedit-state'), _histeditmsg), | |||
|
647 | ('bisect', fileexistspredicate('bisect.state'), _bisectmsg), | |||
|
648 | ('graft', fileexistspredicate('graftstate'), _graftmsg), | |||
|
649 | ('unshelve', fileexistspredicate('unshelverebasestate'), _unshelvemsg), | |||
|
650 | ('rebase', fileexistspredicate('rebasestate'), _rebasemsg), | |||
|
651 | # The merge state is part of a list that will be iterated over. | |||
|
652 | # They need to be last because some of the other unfinished states may also | |||
|
653 | # be in a merge or update state (eg. rebase, histedit, graft, etc). | |||
|
654 | # We want those to have priority. | |||
|
655 | ('merge', _mergepredicate, _mergemsg), | |||
|
656 | ) | |||
|
657 | ||||
|
658 | def _getrepostate(repo): | |||
|
659 | # experimental config: commands.status.skipstates | |||
|
660 | skip = set(repo.ui.configlist('commands', 'status.skipstates')) | |||
|
661 | for state, statedetectionpredicate, msgfn in STATES: | |||
|
662 | if state in skip: | |||
|
663 | continue | |||
|
664 | if statedetectionpredicate(repo): | |||
|
665 | return (state, statedetectionpredicate, msgfn) | |||
|
666 | ||||
|
667 | def morestatus(repo, fm): | |||
|
668 | statetuple = _getrepostate(repo) | |||
|
669 | label = 'status.morestatus' | |||
|
670 | if statetuple: | |||
|
671 | fm.startitem() | |||
|
672 | state, statedetectionpredicate, helpfulmsg = statetuple | |||
|
673 | statemsg = _('The repository is in an unfinished *%s* state.') % state | |||
|
674 | fm.write('statemsg', '%s\n', _commentlines(statemsg), label=label) | |||
|
675 | conmsg = _conflictsmsg(repo) | |||
|
676 | fm.write('conflictsmsg', '%s\n', conmsg, label=label) | |||
|
677 | if helpfulmsg: | |||
|
678 | helpmsg = helpfulmsg() | |||
|
679 | fm.write('helpmsg', '%s\n', helpmsg, label=label) | |||
|
680 | ||||
576 | def findpossible(cmd, table, strict=False): |
|
681 | def findpossible(cmd, table, strict=False): | |
577 | """ |
|
682 | """ | |
578 | Return cmd -> (aliases, command table entry) |
|
683 | Return cmd -> (aliases, command table entry) |
@@ -4710,6 +4710,19 b' def status(ui, repo, *pats, **opts):' | |||||
4710 | files are not considered while tersing until 'i' is there in --terse value |
|
4710 | files are not considered while tersing until 'i' is there in --terse value | |
4711 | or the --ignored option is used. |
|
4711 | or the --ignored option is used. | |
4712 |
|
4712 | |||
|
4713 | --verbose option shows more context about the state of the repo | |||
|
4714 | like the repository is in unfinised merge, shelve, rebase state etc. | |||
|
4715 | You can have this behaviour turned on by default by following config: | |||
|
4716 | ||||
|
4717 | [commands] | |||
|
4718 | status.verbose = true | |||
|
4719 | ||||
|
4720 | You can also skip some states like bisect by adding following in | |||
|
4721 | configuration file. | |||
|
4722 | ||||
|
4723 | [commands] | |||
|
4724 | status.skipstates = bisect | |||
|
4725 | ||||
4713 | Examples: |
|
4726 | Examples: | |
4714 |
|
4727 | |||
4715 | - show changes in the working directory relative to a |
|
4728 | - show changes in the working directory relative to a | |
@@ -4799,6 +4812,10 b' def status(ui, repo, *pats, **opts):' | |||||
4799 | if f in copy: |
|
4812 | if f in copy: | |
4800 | fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd), |
|
4813 | fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd), | |
4801 | label='status.copied') |
|
4814 | label='status.copied') | |
|
4815 | ||||
|
4816 | if ((ui.verbose or ui.configbool('commands', 'status.verbose')) | |||
|
4817 | and not ui.plain()): | |||
|
4818 | cmdutil.morestatus(repo, fm) | |||
4802 | fm.end() |
|
4819 | fm.end() | |
4803 |
|
4820 | |||
4804 | @command('^summary|sum', |
|
4821 | @command('^summary|sum', |
@@ -97,6 +97,12 b" coreconfigitem('color', 'pagermode'," | |||||
97 | coreconfigitem('commands', 'status.relative', |
|
97 | coreconfigitem('commands', 'status.relative', | |
98 | default=False, |
|
98 | default=False, | |
99 | ) |
|
99 | ) | |
|
100 | coreconfigitem('commands', 'status.skipstates', | |||
|
101 | default=[], | |||
|
102 | ) | |||
|
103 | coreconfigitem('commands', 'status.verbose', | |||
|
104 | default=False, | |||
|
105 | ) | |||
100 | coreconfigitem('commands', 'update.requiredest', |
|
106 | coreconfigitem('commands', 'update.requiredest', | |
101 | default=False, |
|
107 | default=False, | |
102 | ) |
|
108 | ) |
@@ -184,6 +184,15 b' bisect test' | |||||
184 |
|
184 | |||
185 | $ hg bisect -r |
|
185 | $ hg bisect -r | |
186 | $ hg bisect -b |
|
186 | $ hg bisect -b | |
|
187 | $ hg status -v | |||
|
188 | # The repository is in an unfinished *bisect* state. | |||
|
189 | ||||
|
190 | None | |||
|
191 | # To mark the changeset good: hg bisect --good | |||
|
192 | # To mark the changeset bad: hg bisect --bad | |||
|
193 | # To abort: hg bisect --reset | |||
|
194 | ||||
|
195 | $ hg status -v --config commands.status.skipstates=bisect | |||
187 | $ hg summary |
|
196 | $ hg summary | |
188 | parent: 31:58c80a7c8a40 tip |
|
197 | parent: 31:58c80a7c8a40 tip | |
189 | msg 31 |
|
198 | msg 31 |
@@ -44,6 +44,23 b'' | |||||
44 | $ hg id |
|
44 | $ hg id | |
45 | 618808747361+c0c68e4fe667+ tip |
|
45 | 618808747361+c0c68e4fe667+ tip | |
46 |
|
46 | |||
|
47 | $ echo "[commands]" >> $HGRCPATH | |||
|
48 | $ echo "status.verbose=true" >> $HGRCPATH | |||
|
49 | $ hg status | |||
|
50 | M a | |||
|
51 | ? a.orig | |||
|
52 | # The repository is in an unfinished *merge* state. | |||
|
53 | ||||
|
54 | # Unresolved merge conflicts: | |||
|
55 | # | |||
|
56 | # a | |||
|
57 | # | |||
|
58 | # To mark files as resolved: hg resolve --mark FILE | |||
|
59 | ||||
|
60 | # To continue: hg commit | |||
|
61 | # To abort: hg update --clean . (warning: this will discard uncommitted changes) | |||
|
62 | ||||
|
63 | ||||
47 |
$ |
|
64 | $ cat a | |
48 | Small Mathematical Series. |
|
65 | Small Mathematical Series. | |
49 | 1 |
|
66 | 1 | |
@@ -58,7 +75,7 b'' | |||||
58 | >>>>>>> merge rev: c0c68e4fe667 - test: branch1 |
|
75 | >>>>>>> merge rev: c0c68e4fe667 - test: branch1 | |
59 | Hop we are done. |
|
76 | Hop we are done. | |
60 |
|
77 | |||
61 | $ hg status |
|
78 | $ hg status --config commands.status.verbose=0 | |
62 | M a |
|
79 | M a | |
63 | ? a.orig |
|
80 | ? a.orig | |
64 |
|
81 |
@@ -221,6 +221,25 b' Summary should mention graft:' | |||||
221 | $ hg summary |grep graft |
|
221 | $ hg summary |grep graft | |
222 | commit: 2 modified, 2 unknown, 1 unresolved (graft in progress) |
|
222 | commit: 2 modified, 2 unknown, 1 unresolved (graft in progress) | |
223 |
|
223 | |||
|
224 | Using status to get more context | |||
|
225 | ||||
|
226 | $ hg status --verbose | |||
|
227 | M d | |||
|
228 | M e | |||
|
229 | ? a.orig | |||
|
230 | ? e.orig | |||
|
231 | # The repository is in an unfinished *graft* state. | |||
|
232 | ||||
|
233 | # Unresolved merge conflicts: | |||
|
234 | # | |||
|
235 | # e | |||
|
236 | # | |||
|
237 | # To mark files as resolved: hg resolve --mark FILE | |||
|
238 | ||||
|
239 | # To continue: hg graft --continue | |||
|
240 | # To abort: hg update --clean . (warning: this will discard uncommitted changes) | |||
|
241 | ||||
|
242 | ||||
224 | Commit while interrupted should fail: |
|
243 | Commit while interrupted should fail: | |
225 |
|
244 | |||
226 | $ hg ci -m 'commit interrupted graft' |
|
245 | $ hg ci -m 'commit interrupted graft' |
@@ -294,9 +294,21 b' folded content is dropped during a merge' | |||||
294 | [1] |
|
294 | [1] | |
295 | There were conflicts, we keep P1 content. This |
|
295 | There were conflicts, we keep P1 content. This | |
296 | should effectively drop the changes from +6. |
|
296 | should effectively drop the changes from +6. | |
297 | $ hg status |
|
297 | ||
|
298 | $ hg status -v | |||
298 | M file |
|
299 | M file | |
299 | ? file.orig |
|
300 | ? file.orig | |
|
301 | # The repository is in an unfinished *histedit* state. | |||
|
302 | ||||
|
303 | # Unresolved merge conflicts: | |||
|
304 | # | |||
|
305 | # file | |||
|
306 | # | |||
|
307 | # To mark files as resolved: hg resolve --mark FILE | |||
|
308 | ||||
|
309 | # To continue: hg histedit --continue | |||
|
310 | # To abort: hg histedit --abort | |||
|
311 | ||||
300 | $ hg resolve -l |
|
312 | $ hg resolve -l | |
301 | U file |
|
313 | U file | |
302 | $ hg revert -r 'p1()' file |
|
314 | $ hg revert -r 'p1()' file |
@@ -71,6 +71,21 b' Conflicting rebase:' | |||||
71 | unresolved conflicts (see hg resolve, then hg rebase --continue) |
|
71 | unresolved conflicts (see hg resolve, then hg rebase --continue) | |
72 | [1] |
|
72 | [1] | |
73 |
|
73 | |||
|
74 | $ hg status --config commands.status.verbose=1 | |||
|
75 | M common | |||
|
76 | ? common.orig | |||
|
77 | # The repository is in an unfinished *rebase* state. | |||
|
78 | ||||
|
79 | # Unresolved merge conflicts: | |||
|
80 | # | |||
|
81 | # common | |||
|
82 | # | |||
|
83 | # To mark files as resolved: hg resolve --mark FILE | |||
|
84 | ||||
|
85 | # To continue: hg rebase --continue | |||
|
86 | # To abort: hg rebase --abort | |||
|
87 | ||||
|
88 | ||||
74 | Try to continue without solving the conflict: |
|
89 | Try to continue without solving the conflict: | |
75 |
|
90 | |||
76 | $ hg rebase --continue |
|
91 | $ hg rebase --continue |
@@ -342,6 +342,23 b' force a conflicted merge to occur' | |||||
342 | warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark') |
|
342 | warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark') | |
343 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') |
|
343 | unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue') | |
344 | [1] |
|
344 | [1] | |
|
345 | $ hg status -v | |||
|
346 | M a/a | |||
|
347 | M b.rename/b | |||
|
348 | M c.copy | |||
|
349 | R b/b | |||
|
350 | ? a/a.orig | |||
|
351 | # The repository is in an unfinished *unshelve* state. | |||
|
352 | ||||
|
353 | # Unresolved merge conflicts: | |||
|
354 | # | |||
|
355 | # a/a | |||
|
356 | # | |||
|
357 | # To mark files as resolved: hg resolve --mark FILE | |||
|
358 | ||||
|
359 | # To continue: hg unshelve --continue | |||
|
360 | # To abort: hg unshelve --abort | |||
|
361 | ||||
345 |
|
362 | |||
346 | ensure that we have a merge with unresolved conflicts |
|
363 | ensure that we have a merge with unresolved conflicts | |
347 |
|
364 |
General Comments 0
You need to be logged in to leave comments.
Login now