Commit Graph

61 Commits

Author SHA1 Message Date
Denis Laxalde
e785df5b6d crecord: drop unused "operation" parameter from filterpatch function 2016-06-07 11:57:11 +02:00
Anton Shestakov
98e687e2c1 crecord: call prevsibling() and nextsibling() directly
The 3 classes for items used in crecord (uiheader, uihunk, uihunkline) all have
prevsibling() and nextsibling() methods. The two methods are used to get the
previous/next item of the same type of the same parent element as the current
one: when `a` is a uihunkline instance, a.nextsibling() returns the next line
in this hunk (or None, if `a` is the last line).

There are also two similar methods: previtem() and nextitem(). When called with
constrainlevel=True (the default) they simply returned the result of
prevsibling()/nextsibling(). Only when called with constrainlevel=False they
did something different: they returned previous/next item regardless of its
type (so if `a` is the last line in a hunk, a.nextitem(constrainlevel=False)
could return the next hunk or the next file -- something that is not a line).

Let's simplify this logic and make code call -sibling() methods when only
siblings are needed and -item() methods when any item would do, and then remove
the constrainlevel argument from previtem() and nextitem().
2016-05-06 19:52:21 +08:00
Anton Shestakov
2114fb5a2b crecord: update downarrowshiftevent() docstring, remove todo
The phrasing is mostly taken from uparrowshiftevent().
2016-05-05 19:51:35 +08:00
Anton Shestakov
5e327181ec crecord: remove things that don't happen in functions from their docstrings
Scrolling screen is currently done in a different place. The things that had
been described in the docstrings may still happen, but the functions touched by
this patch don't do any scrolling, they only set self.currentselecteditem and
nothing more.
2016-05-05 19:40:40 +08:00
Anton Shestakov
5e74474fd5 crecord: remove skipfolded keyword argument from patchnode.previtem()
It wasn't used, it wasn't implemented. Probably was a copy-paste bonus from
patchnode.nextitem()
2016-05-05 18:13:25 +08:00
Anton Shestakov
abe8039328 crecord: update a copy-pasted comment in downarrowshiftevent() 2016-05-05 15:19:37 +08:00
Pierre-Yves David
1df58e3451 crecord: drop the version condition for amend
The UI is now shipped in core, amend feature is always available.
2016-05-05 16:38:24 +02:00
Anton Shestakov
2a1482cb0e crecord: add/remove blank lines (coding style) 2016-05-05 11:19:52 +08:00
Pierre-Yves David
8727b619f9 crecord: cleanup the remains of commit confirmation
The confirmation screen is now only used for the 'review' option we simplify
the code and rename the function.
2016-04-14 01:37:29 -07:00
Pierre-Yves David
cfee396b5b crecord: drop the extra confirmation screen
The commit confirmation is not very useful -- it gives no way to view what you
have selected, so you're blindly choosing whether to proceed or not, and it adds
a lot of unnecessary friction to committing. In addition, we now have a working
'review' choice for those who really want to review the final change.

Ryan McElroy initially submitted a config option to make this optional, but we
never saw a V2. However as the freeze is near and curses have never been
officially out of the door, I think it is worth skipping the config and trying
getting it right for this release.
2016-04-14 01:27:18 -07:00
timeless
f77cdcd3b1 pycompat: switch to util.stringio for py3 compat 2016-04-10 20:55:37 +00:00
Jordi Gutiérrez Hermoso
52cc18f78c crecord: re-enable reviewing a patch before comitting it
The "r" option for this feature was copied into Mercurial from
crecord, but the actual implementation never made it into hg until
now. It's a moderately useful feature that allows the user to edit the
patch in a text editor before comitting it for good.

This requires a test, so we must also enable a corresponding testing
'R' option that skips the confirmation dialogue. In addition, we also
need a help text for the editor when reviewing the final patch.

As for why this is a useful feature if we can already edit hunks in an
editor, I would like to offer the following points:

    * editing hunks does not show the entire patch all at once

      ** furthermore, the hunk "tree" in the TUI has no root that could be
         selected for edition

    * it is helpful to be able to see the entire final patch for
      confirmation

      ** within this view, the unselected hunks are hidden, which is
         visusally cleaner

      ** this works as a final review of the complete result, which is
         a bit more difficult to do conceptually via hunk editing

    * this feature was already in crecord, so it was an oversight to
      not bring it to core

    * it works and is consistent with editing hunks
2016-03-20 21:08:17 -04:00
Jordi Gutiérrez Hermoso
6e38da078e crecord: break out the help message for editing hunks
This help message can be useful for other situations, such as for the
review extension. It's also easier to write it at the top-level
indentation with triple-quoted strings instead of inserting comment
characters and newlines programmatically.
2016-03-20 18:24:59 -04:00
Jordi Gutiérrez Hermoso
e86f12d3c1 crecord: refactor hunk edit action to use ui.edit
The previous version of this code did a lot of dancing around a
temporary edit file that ui.edit already handles.
2016-03-20 20:59:05 -04:00
Ryan McElroy
27da9f85d4 crecord: add docblock to handlekeypressed
This information is pretty useful when reading the code.
2016-03-18 11:06:03 -07:00
Ryan McElroy
06ec8dec0a crecord: fix docblock indentation 2016-03-18 11:06:03 -07:00
Ryan McElroy
f48f34f0f0 crecord: clean up empty lines at ends of docblocks 2016-03-18 11:06:03 -07:00
Simon Farnsworth
4f9fc754b3 crecord: use ui.interface to choose curses interface
use ui.interface to select curses mode, instead of experimental.crecord
2016-03-14 15:01:27 +00:00
Laurent Charignon
f5b5bd3884 crecord: fix help bar display issue (issue5063)
Before this patch, the help bar in crecord wouldn't be printed correctly when
the terminal window didn't have enough column to display it. This patch adds
logic to make sure that the help bar message is always displayed. We use an
ellipsis when it is not possible to display the complete message.
2016-01-25 11:37:02 -08:00
Laurent Charignon
f009465327 crecord: fix typo in the help text
In the crecord help dialog, the toggle all option was wrongfully documented.
Instead of using 'a', one must use 'A' to toggle all the hunks. The crecord
header that is always displayed on the screen contains the right shortcut and
does not need to be changed.
2016-01-25 10:13:03 -08:00
Laurent Charignon
9f20d61491 crecord: edit during hg crecord should preserve cursor position (issue5041)
This patch adds a variable to keep track of what hunk was selected
before the edit. We use that variable to select the hunk or its
replacement after the edit.
2016-01-20 11:21:13 -08:00
Matt Mackall
798e034a3c merge with stable 2015-12-28 10:11:48 -06:00
Sean Farley
972541224f crecord: stop raising error.Abort if curses is not found (issue5008)
On some servers, python curses support is disabled. This patch not only fixes
that but provides a fallback on other machines (e.g. Windows) when curses is
not found.

The previous code was actually flawed logic and relied on wcurses throwing an
ImportError which demandimport wouldn't throw. So, this patch also fixes that
problem.
2015-12-16 10:39:00 -08:00
Sean Farley
38fab65a09 crecord: ensure that curses is False if not imported
This provides no functional change but makes the next two patches easier to
review.
2015-12-15 16:00:06 -08:00
Sean Farley
db61c5aa1f crecord: add helper function to determine if we should use curses
To fix issue5008 properly, we need a helper function to determine if curses is
imported and also if the user has enabled the experimental flag.
2015-12-15 15:56:10 -08:00
Sean Farley
e8a52b93c0 crecord: use try/except for import of curses
Not only does this improve fragility with 'if os.name == ...' it will help
future patches enable the behavior to fallback to use plain record when curses
is unavailable (e.g. python compiled without curses support).
2015-12-16 10:33:19 -08:00
Mads Kiilerich
09567db49a spelling: trivial spell checking 2015-10-17 00:58:46 +02:00
Laurent Charignon
2ddae732ee crecord: add dictionary to default return value of filterpatch
When committing interactively without changes, the user would get a ValueError
exception. This patch adds a dictionary to the return value of filterpatch
when there are no files to change.
2015-12-09 17:01:27 -08:00
Laurent Charignon
37960d39f4 commit: add amend mode for commit -i
When I moved crecord into core, I didn't include the toggleAmend function (to
switch from commit to amend mode). I did it because it would have made it more
difficult to use record and crecord interchangably. This patch reintroduces the
amend mode for commit -i as well as two tests to verify the behavior of the
function.
2015-11-30 16:37:42 -08:00
Laurent Charignon
1409af5e69 commit: add a way to return more information from the chunkselector
Before this patch, the chunkselector for record or crecord was used to return
the list of hunks that were selected by the user. The goal of this series is to
reintroduce the toggle amend feature for crecord. To do so, we need to be able
to return more than just the selected hunks from the chunkselector but also
the information: is amend mode toggled. This patch adds a new return value for
chunkselectors that will be used to implement the toggle amend feature in
crecord.
2015-11-30 16:35:21 -08:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Matt Mackall
5e1b4ad958 urls: bulk-change primary website URLs 2015-09-30 15:43:49 -05:00
Gregory Szorc
d1b3f5b2a0 crecord: use absolute_import 2015-08-08 19:05:55 -07:00
Laurent Charignon
f9a0bb5c34 crecord: throws error instead of crashing for large diffs
Before this patch, crecord was crashing for large diffs
(30k lines on my laptop). This patch catches the exception raised in that case
and use the error reporting mechanism introduced in the previous patch for
notifying the user of the issue. It is not possible to add a test for that for
now as we don't yet have full blown ui tests for the curses interface.
2015-07-17 13:44:01 -07:00
Laurent Charignon
678b69749a crecord: add error reporting for failure in curses interface initialization
Before this patch, we couldn't report to the user any error that occurred:
- after we enabled the curses interface but
- before the interface is set up and drawn
This patch, provides a way to set errors that happens during the initialization
of the interface and log them once the curses interface has been displayed.
2015-07-17 13:41:17 -07:00
Laurent Charignon
ea68db323a crecord: fix issue when backgrounding editor would leave artefact
Before this patch:
- if a user was entering a commit message after having ran the curses
interface
- and then uses ctrl-z, followed by fg to put the editor in the
background/foreground
- then the curses interface would leave artefact on the screen of
the editor, making entering the commit message a difficult task

This happened because ncurses registers a signal handler for SIGTSTP and
does not restore the original signal handler after running.
More info at:
http://stackoverflow.com/questions/31440392/
curses-wrapper-messing-up-terminal-after-background-foreground-sequence/
31441709#31441709

This patch restores the original value of the signal handler after
running the curses interface and therefore fixes this issue.
It don't know how to add a test for this issue, I tested the scenario
above manually and it works correctly with the patch.
2015-07-15 20:39:23 -07:00
Laurent Charignon
05537e0c0f crecord: exit edition of hunk with non-zero status does not interrupt session
Before this patch, when editing a hunk, if the editor was exiting with a non-
zero status the crecord session would be aborted. This patch makes crecord
handle the failure and goes back to the state before the failed edition.
We use the new error reporting mechanism introduced in the previous patch to
notify the user of the issue.
2015-06-05 13:41:14 -07:00
Laurent Charignon
9a5e2d91be crecord: add mechanism for error reporting
Before this patch, there was no way to report errors in the crecord ui.
This patch introduces a new variable errorstr. If set, its content replaces the
top banner displayed in crecord until a key is pressed.
2015-06-05 13:53:49 -07:00
Laurent Charignon
b472b09bc6 crecord: extract ui refresh code after editing of hunk in a function
This is useful to reuse the logic to implement the continuation of the crecord
session if the user edits a hunk and the editor exits with a non-zero status.
2015-06-05 13:32:52 -07:00
Matt Mackall
002599d5f3 merge with stable 2015-06-05 15:44:43 -05:00
Laurent Charignon
e02fe4b93e crecord: fix three typos introduced while moving crecord into core
When moving crecord to core, I did a search an replace to remove all of the
variable with caps letter. Doing so, I unfortunately changed some commands
with capital letter shortcut to their lowercase counterpart. I fixed one
of these cases in bfcbb3995330. This patch fixes all of the remaining cases.
2015-06-05 12:57:21 -07:00
Laurent Charignon
8979893774 crecord: fix a typo introduced when moving crecord to core
When moving crecord to core, I did a search an replace to remove all of the
variable with caps letter. Doing so, I unfortunately changed the 'F' command
to 'f' leading to two 'f' commands, one never used. This patch fixes this
mistake and re enables the behavior of 'F'.
2015-06-05 10:44:34 -07:00
Matt Mackall
dfeafbe538 merge with stable 2015-06-05 13:00:18 -05:00
Laurent Charignon
55be79bae4 crecord: fix blue artifact bug coming back from help screen
Before this patch, with record's curses interface:
- When one pressed the ? key to see the help menu and then leaves the help menu
- Then, blue artifacts would remain on the screen

This patch forces a screen clear / refresh after coming back from the help menu.
Since we don't have UI test for crecord I checked on my machine that the bug
does not reproduce.
2015-06-03 14:22:21 -07:00
Laurent Charignon
9b866fafac record: add default value for operation argument
This patch is part of a series of patches to change the recording ui to reflect
the operation currently running (commit, shelve, revert ...).
This patch adds the default value of the operation argument for record's
standard and curses interface to match what is displayed in the interface
as of today.
2015-05-27 15:56:10 -07:00
Laurent Charignon
92c99cc1a7 record: add an operation arguments to customize recording ui
This patch is part of a series of patches to change the recording ui to reflect
the operation currently running (commit, shelve, revert ...).
This patch adds a new argument to the recording function to reflect in the UI
what operation we are running.
2015-05-27 15:49:24 -07:00
Laurent Charignon
7e6cda9955 record: change wording for record curses interface
We are using record and crecord in different context, not just for commiting
changes but also reverting and shelving changes. This diff changes the wording
from commiting to confirming changes to avoid confusing the users with what
they are doing.
2015-04-21 16:20:43 -07:00
Laurent Charignon
8213891de3 record: add message when starting record's curses interface
We are adding this log message to reduce a confusion when a command prints
something just before starting the curses interface.

Since the interactive mode is taking over the entire screen, starts with no
delay and does wait for a key press, the user believes that messages printed
before opening the interactive mode were actually printed after using
interactive mode, not before.
The fix adds the line "Starting interactive mode" helping the user separate
the messages that were printed before and after the start of the
interactive mode.

One particular example where this was a problem is the revert command where we
first print the list of changes to be considered for revert, then opens the
curses interface right away without letting the user see the messages.
The user then selects the changes, validates and then see the messages from
before opening the interactive mode and is confused.
2015-04-16 14:26:50 -07:00
Laurent Charignon
ff5c5b9b22 record_curses: fix ui bug for newly added file
With record's curses interface toggling and untoggling a newly added
file would lead to a confusing UI (the header was marked as partial
and the hunks as unselected). Tested additionally using the curses
interface with newly added, removed and modified files in a test repo.
2015-03-27 14:11:13 -07:00
Matt Harbison
ca3f9b0788 crecord: don't abort on Windows when curses isn't available
This is the hack portion of the previous patch, which can be backed out once we
figure out how to deal with curses.  Without this, the tests affected by the
import problem mentioned in the previous patch fail in exactly the same way, but
with the nicer 'module not available' error.
2015-03-20 23:35:13 -04:00