Commit Graph

26 Commits

Author SHA1 Message Date
Matt Harbison
7d8bebd9c1 tests: remove (glob) annotations that were only for '\' matches
# skip-blame because this was mechanically rewritten the following script.  I
ran it on both *.t and *.py, but none of the *.py changes were proper.  All *.t
ones appear to be, and they run without addition failures on both Windows and
Linux.

  import argparse
  import os
  import re

  ap = argparse.ArgumentParser()
  ap.add_argument('path', nargs='+')
  opts = ap.parse_args()

  globre = re.compile(r'^(.*) \(glob\)(.*)$')

  for p in opts.path:
      tmp = p + '.tmp'
      with open(p, 'rb') as src, open(tmp, 'wb') as dst:
          for line in src:
              m = globre.match(line)
              if not m or '$LOCALIP' in line or '*' in line:
                  dst.write(line)
                  continue
              if '?' in line[:-3] or ('?' in line[:-3] and line[-3:] != '(?)'):
                  dst.write(line)
                  continue
              dst.write(m.group(1) + m.group(2) + '\n')
      os.unlink(p)
      os.rename(tmp, p)
2017-12-10 22:50:57 -05:00
Saurabh Singh
d207bf8f86 cmdutil: remove the redundant commit during amend
There was an extra commit made during the amend operation to track the
changes to the working copy. However, this logic was written a long time back
and newer API's make this extra commit redundant. Therefore, I am removing the
extra commit. After this change, I noticed that

  - Execution time of the cmdutil.amend improved by over 40%.
  - Execution time of "hg commit --amend" improved by over 20%.

Test Plan:
I ensured that the all the hg tests passed after the change. I had
to fix a few tests which were aware of the extra commit made during the amend.

Differential Revision: https://phab.mercurial-scm.org/D636
2017-09-01 12:34:36 -07:00
Augie Fackler
9a0414f5ae tests: clean up many print statements to be print functions instead
Differential Revision: https://phab.mercurial-scm.org/D294
2017-06-15 14:22:25 -04:00
Jun Wu
41049ab36d amend: use scmutil.cleanupnodes (BC)
This is marked as BC because the strip backup file name has changed.
2017-06-26 15:28:28 -07:00
Augie Fackler
3112944d5b tests: replace yet more calls to python with $PYTHON
These are some simple cases. More to come in a future change.

Reviewers: krbullock

Reviewed By: krbullock

Differential Revision: https://phab.mercurial-scm.org/D4
2017-07-05 11:10:11 -05:00
Yuya Nishihara
dcf75add48 test-commit-interactive-curses: remove unused import of parsers 2017-05-02 19:10:55 +09:00
Anton Shestakov
10cc5b4f2f tests: test experimental.spacemovesdown config for commit -i
The feature is still very experimental, but at least its behavior is captured
in the test.
2017-01-17 13:44:53 +08:00
Yuya Nishihara
1d44bd2bbb ui: factor out ui.load() to create a ui without loading configs (API)
This allows us to write doctests depending on a ui object, but not on global
configs.

ui.load() is a class method so we can do wsgiui.load(). All ui() calls but
for doctests are replaced with ui.load(). Some of them could be changed to
not load configs later.
2016-10-22 14:35:10 +09:00
FUJIWARA Katsunori
feea36218b tests: add test-commit-interactive-curses.t "require tic" for test portability
Standard library of Python on Windows doesn't have curses module.
2016-10-29 03:08:08 +09:00
Philippe Pepiot
82dc121fd0 commit: return 1 for interactive commit with no changes (issue5397)
For consistency with non interactive commit
2016-10-14 09:52:38 +02:00
timeless
aa2c0ad5a3 crecord: properly handle files with No newline at eof (issue5268)
Yes, this bug was a single character with the wrong case...
2016-09-02 20:15: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
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
Simon Farnsworth
c7b3ee31ad ui: add new config flag for interface selection
This patch introduces a new config flag ui.interface to select the interface
for interactive commands. It currently only applies to chunks selection.
The config can be overridden on a per feature basis with the flag
ui.interface.<feature>.

features for the moment can only be 'chunkselector', moving forward we expect
to have 'histedit' and other commands there.

If an incorrect value is given to ui.interface we print a warning and use the
default interface: text. If HGPLAIN is specified we also use the default
interface: text.

Note that we fail quickly if a feature does not handle all the interfaces
that we permit in ui.interface; in future, we could design a fallback path
(e.g. blackpearl to curses, curses to text), but let's leave that until we
need it.
2016-03-14 15:01:27 +00: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
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
Mads Kiilerich
09567db49a spelling: trivial spell checking 2015-10-17 00:58:46 +02: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
4fc3c4c465 record: fix record with change on moved file crashes (issue4619)
reverting fe807064739c, add a test to prevent the issue from coming back.
2015-04-22 13:56:30 -07:00
Laurent Charignon
ac26bdeb92 record_curses: add test for newly added files
We have a UI bug where toggling a newly added file twice in the curses
interface didn't mark it as selected. This test checks that the underlying
logic is working as expected, the next patch of the series fixes the UI bug.
2015-03-25 16:40:37 -07:00
Matt Harbison
c140481b78 test-commit-interactive-curses: backout 67380343474d
Now that the imports have been fixed up, and the platform EOL difference
eliminated, this test runs on Windows.
2015-03-21 12:01:05 -04:00
Matt Harbison
2a4fd713bf test-interactive: use stable EOL in various file generating routines
The seq.py and shell echo redirected to a file ends up with platform
specific EOL, which throws off the hash when the file is committed to
the test repo on Windows. The other option is to glob the hashes, but
the ability to see if they have changed might point out problems that
would otherwise be missed.
2015-03-21 11:56:43 -04:00
Matt Harbison
8a3f14eed1 test-commit-interactive-curses: #require 'tic'
When run on Windows, this test aborts:

@@ -20,7 +20,8 @@
   > X
   > EOF
   $ hg commit -i  -m "a" -d "0 0"
-  no changes to record
+  abort: No module named fcntl!
+  [255]
   $ hg tip
   changeset:   -1:000000000000
   tag:         tip

Maybe there's another way to get the screen size on Windows (it dies in
crecord.gethw()), but for now, quiet the test noise by skipping it if terminal
info compiler is unavailable.
2015-03-17 22:21:09 -04:00
Matt Harbison
9741c43e48 tests: replace uses of 'seq' with portable 'seq.py' 2015-03-17 21:47:47 -04:00
Laurent Charignon
8f36385e6f record: add tests for the curses recording interface 2015-03-12 14:42:55 -07:00