Commit Graph

337 Commits

Author SHA1 Message Date
Durham Goode
77dcefda06 obsolete: add operation metadata to rebase/amend/histedit obsmarkers
By recording what operation created the obsmarker, we can show very intuitive
messages to the user in various UIs. For instance, log output could have
messages like "Amended as XXX" to show why a commit is old and has an 'x' on it.

     @  ac28e3  durham
    /   First commit
   |
   | o  d4afe7 durham
   | |  Second commit
   | |
   | x  8e9a5d (Amended as ac28e3)  durham
   |/   First commit
   |
2017-05-09 16:29:31 -07:00
Martin von Zweigbergk
c3406ac3db cleanup: use set literals
We no longer support Python 2.6, so we can now use set literals.
2017-02-10 16:56:29 -08:00
Siddharth Agarwal
163ca4866c histedit: make check for unresolved conflicts explicit (issue5545)
Previously, we'd rely on the implicit check that `localrepo.commit` did.
The problem is that that check only happened when the working copy was
dirty. With a "clean" working copy but unresolved conflicts we'd get
into a broken state.

To fix that, do what rebase does and check for unresolved conflicts at
the start of histedit --continue.
2017-04-20 17:18:08 -07:00
Pierre-Yves David
26848e81da histedit: backout changeset 33e44341bb82
Before 33e44341bb82, histedit (like rebase) was only creating markers on final
success from the old-rewritten node to the newly created nodes (as of before
33e44341bb82). In case of abort the aborted attempt were stripped to restore the
repository in its state prior to the attempt.

This use of strip was on purpose. Using markers in this case introduces various
issues. The main one is that keeping the partial result of histedit as obsolete
prevents us to recreates the same nodes in a second attempt. The same operation
will lead to an identical results, using an identical node that already exists
in the repository as obsolete.

To conclude, we cannot and should not switch to obsolescence markers creation on
histedit --abort and we backout 33e44341bb82. A test to catch this class of
issue will be introduced in the next changeset.
2017-03-26 15:46:09 +02:00
Pierre-Yves David
28c534388d histedit: backout changeset bcd3d9060a3a
Its parent is about to be backedout so this one needs to be removed too.
2017-03-26 15:34:39 +02:00
Jun Wu
43b73290d8 histedit: inline cleanupnode
Move "cleanupnode" (unsafe strip) into "safecleanupnode" so it's impossible
to call the unsafe function directly.

This helps reduce future programming errors.
2017-03-13 22:30:07 -07:00
Jun Wu
9a92b85a6b histedit: use safecleanupnode in _aborthistedit (issue5500)
Now nobody in histedit calls the unsafe cleanupnode directly.
2017-03-13 22:22:18 -07:00
Jun Wu
a31c040564 histedit: use safecleanupnode in _finishhistedit
This simplifies code a lot.
2017-03-13 22:19:06 -07:00
Jun Wu
6525da3ca6 histedit: add a method to cleanup nodes safely
The new method will decide between:

  - cleanupnode, which calls the unsafe repair.strip
  - create obsmarkers

Ideally, nobody calls "cleanupnode" directly except for "safecleanupnode".
2017-03-13 21:10:45 -07:00
Durham Goode
6373006050 histedit: add histedit.singletransaction config option
This adds an option (which defaults to False) to run entire histedits in a
single transaction. This results in 20-25% faster histedits in large repos where
transaction startup cost is expensive.

I didn't want to enable this by default because it has some unfortunate side
effects. For instance, if a pretxncommit hook throws midway through the
histedit, it will rollback the entire histedit and lose any progress the user
had made. Same if the user aborts editting a commit message. It's still worth
turning this on for large repos, but probably not for normal sized repos.

Long term, once we have inmemory merging, we could do the entire histedit in
memory, without a transaction, then we could selectively rollback just parts of
it in the event of an exception.

Tested it by running the tests with
`--extra-config-opt=histedit.singletransaction=True`. The only failure was
related to the hook rollback issue I mention above.
2017-03-10 15:52:29 -08:00
Durham Goode
3b715e3357 histedit: pop action after the action is completed
We only want to pop the action after the action is completed, since if the
action aborts part way through we want it to remain at the front of the list so
continue/abort will start with it.

Previously we relied on the fact that we only serialized the state file at the
beginning of the action, so the pop wasn't serialized until the next iteration
of the loop. In a future patch we will be adding a large transaction around this
area, which means if we pop the list early it might get serialized if the action
throws a user InterventionRequired error, at which point the action is not in
the list anymore. So let's only pop it once the action is really truly done.
2017-03-10 15:43:31 -08:00
Durham Goode
6cd32520b1 histedit: add transaction support to writing the state file
This will be used in a future diff to enable a single transaction around an
entire histedit.
2017-03-10 15:43:31 -08:00
Jun Wu
d49afd55dd histedit: get rid of ui.backupconfig 2017-03-16 14:36:35 -07:00
Pierre-Yves David
a1d4a95c88 histedit: directly use repo.vfs.join
The 'repo.join' method is about to be deprecated.
2017-03-08 16:51:43 -08:00
Ben Schmidt
20f9183d45 histedit: modify rollup to discard date from the rollup commit (issue4820)
This change adjusts and documents the new behaviour of 'roll'. It now fits nicely
with the behaviour of 'commit --amend' and the 'edit' action, by discarding the
date as well as the commit message of the second commit. Previously it used the
later date, like 'fold', but this often wasn't desirable, for example, in the
common use case of using 'roll' to add forgotten changes to a changeset
(because 'hg add' was previously forgotten or not all changes were identified
while using 'hg record').
2017-02-18 21:30:28 +11:00
Ben Schmidt
a0e44b6af4 histedit: improve documentation and behaviour of dates
This clarifies in the histedit documentation that the 'edit' action preserves
the date and that the 'fold' action uses the later date. The documentation was
previously silent on this issue which left users in doubt.
2017-02-18 21:30:28 +11:00
Simon Farnsworth
2d5b62ae12 histedit: log the time taken to read in the commands list
If we're being fed an external command list from stdin (histedit --commands -),
then the time spent reading stdin is outside our control. Log it.
2017-02-15 13:34:06 -08:00
Sean Farley
e145fc2df7 ui: rename tmpdir parameter to more specific repopath
This was requested by Augie and I agree that repopath is more
descriptive.
2017-01-18 18:25:51 -08:00
Sean Farley
df48d2115f histedit: add tmpdir parameter to ui.edit call 2017-01-16 21:15:57 -08:00
Mads Kiilerich
38cb771268 spelling: fixes of non-dictionary words 2016-10-17 23:16:55 +02:00
Yuya Nishihara
db11160c56 histedit: use ui.fin to read commands from stdin
stdin is wrapped by channeledinput in command-server session.
2016-03-18 17:15:06 -07:00
Martin von Zweigbergk
cb58483f81 histedit: avoid converting nodeid to context and back again
It looks like this became unnecessary in 8166e7073157 (histedit: fix
preventing strips during histedit, 2015-04-04).
2016-09-27 22:09:28 -07:00
timeless
04798f0fb8 histedit: use single quotes in use warning 2016-09-20 23:45:25 +00:00
Augie Fackler
24579e9893 histedit: correct output of error when 'base' is from the edit list
This was made more obvious by marmoute's recent rearrangement of this code.
2016-08-30 13:13:50 -04:00
Pierre-Yves David
b9ebcea85e histedit: remove now unused 'constraints' related code
Now that the one action that need different logic handle that using inheritance
and overriding, we can remove that code.
2016-08-26 21:06:31 +02:00
Pierre-Yves David
d2bccef0ce histedt: use inheritance to override the constraints in 'base'
All actions but one actually have the same constraints when it comes to validate
the 'action.node' value. So we actually just add this code to a method that can
be overwritten in the one action where it matters.

The now unused 'contraints' related enum and class attribute will be cleaned up
in the next changeset.
2016-08-26 21:00:33 +02:00
Pierre-Yves David
e83d8435c9 histedit: move constraint verification to the 'action.verify' method
Action has a method dedicated to verifying its validity. So we move code
related to constrains into that method. This requires a bit more context to the
'verify' method in the same fashion we were passing the 'prev' argument.

This is an extra step before we can simplify the constraint handling code
further.
2016-08-26 20:54:52 +02:00
Pierre-Yves David
c056fb41dc histedit: directly use node in 'verifyactions'
It does not seem useful to convert to hex: it is an extra step and they are
longer strings. So we stick to node for the logic. We only convert to short hex
for error when needed. As a nice side effect this remove the explicit constant
usage in'[12:]'. This will also help moving the code around later as we just
have to access action.node.
2016-08-26 20:54:32 +02:00
Pierre-Yves David
58fa162d21 histedit: temporarily shorten name of 'constraints' variable
An upcoming changeset will make the line where this variable is used
slightly too long. Other later changesets will clean that up further and makes
the variable unnecessary, so this is only temporary and it does seems useful to
put anything more complicate in place.
2016-08-26 20:42:18 +02:00
Pierre-Yves David
5dfe266b33 histedit: drop the 'nodetoverify' local variable
We can just use 'action.node'.
2016-08-26 20:38:37 +02:00
Pierre-Yves David
f113c210a5 histedit: make 'constraints' a class attribute instead of a method
There does not seem to be a reason for this to be a method. So we initialise
the class attribute once and for all at creation time and drop the instance
method.
2016-08-26 20:34:58 +02:00
Pierre-Yves David
d390c8d401 histedit: drop the 'nodetoverify' method
That method is just returning self.node and is never overridden. We just use
the attribute directly instead and get rid of the method.

This is the beginning of series to simplify and unify verification of constraints
for actions.
2016-08-26 20:31:33 +02:00
Augie Fackler
4e1c384d0a extensions: change magic "shipped with hg" string
I've caught multiple extensions in the wild lying about being
'internal', so it's time to move the goalposts on people. Goalpost
moving will continue until third party extensions stop trying to
defeat the system.
2016-08-23 11:26:08 -04:00
Hannes Oldenburg
f878dbe267 histedit: use samefile function from cmdutil
Replace usage of inefficient samefile function in collapse with a call to
cmdutil.samefile().
2016-08-21 08:03:22 +00:00
Sean Farley
bae0386e22 histedit: move autoverb rule to the commit it matches
Inspired by how 'git rebase -i' works, we move the autoverb to the
commit line summary that it matches. We do this by iterating over all
rules and inserting each non-autoverb line into a key in an ordered
dictionary. If we find an autoverb line later, we then search for the
matching key and append it to the list (which is the value of each key
in the dictionary). If we can't find a previous line to move to, then we
leave the rule in the same spot.

Tests have been updated but the diff looks a little messy because we
need to change one of the summary lines so that it will actually move to
a new spot. On top of that, we added -q flags to future some of the
output and needed to change the file it modified so that it wouldn't
cause a conflict.
2016-06-21 14:58:49 -07:00
Sean Farley
f5c99064dd histedit: use _getsummary in ruleeditor
This patch uses our common method instead of duplicating logic.
2016-05-27 14:03:00 -07:00
Sean Farley
0aadad3fdc histedit: use _getsummary in torule
This patch uses our common method instead of duplicating logic.
2016-05-27 14:02:36 -07:00
Sean Farley
2a852d9312 histedit: extract common summary code into method
We're going to need to use this code in our autoverb logic so let's
extract it now and save ourselves from code duplication.
2016-05-27 14:00:12 -07:00
Sean Farley
a8452be140 histedit: remove unneeded initial parameter
Now that the autoverb logic no longer acts on an individual rule line,
we don't need this parameter since we apply our logic just once at the
time of initialization.
2016-05-26 15:43:00 -07:00
Sean Farley
60d7ad0f37 histedit: move autoverb logic from torule to ruleeditor
This is needed for an upcoming change that will automatically rearrange the
rules based on the commit message. Before this patch, the autoverb logic only
applied to one rule at a time. This moves that logic one step up so that it can
iterate over all the rules and rearrange as needed.
2016-05-26 16:46:10 -07:00
Pulkit Goyal
5f52c722cf py3: conditionalize cPickle import by adding in util
The cPickle is renamed to _pickle in python3 and this C extension is available
 in pickle which was not included in earlier versions. So imports are conditionalized
 to import cPickle in py2 and pickle in py3. Moreover the use of pickle in py2 is
 switched to cPickle as the C extension is faster. The hack is added in util.py and
the modules import util.pickle
2016-06-04 14:38:00 +05:30
Sean Farley
a69dcd1771 histedit: add experimental config for using the first word of the commit
This allows users to start a commit with "verb! ..." so that when this is
opened in histedit, the default action will be "verb". For example, "roll! foo"
will default to the action "roll". Currently, we'll allow any known verb to be
used but this is experimental.
2016-05-06 18:12:36 -07:00
Sean Farley
6348f9426e histedit: add optional parameter for determining intial editor line
A simple refactor to allow us to change the default verb for the initial editor
display.
2016-05-06 18:00:03 -07:00
Yuya Nishihara
a5c934df3c py3: move up symbol imports to enforce import-checker rules
Since (b) is banned, we should do the same for (a) for consistency.

 a) from mercurial import hg
    from mercurial.i18n import _

 b) from . import hg
    from .i18n import _
2016-05-14 14:03:12 +09:00
Pulkit Goyal
8d03cfe483 py3: make hgext/hisedit.py use absolute_import 2016-05-06 21:52:26 +05:30
Mateusz Kwapich
36f23adcb5 histedit: add a hint about enabled dropmissing to histedit edit comment
Adds a hint to histedit comment reminding user about enabled dropmissing.
This will make the enabled dropmissing more visible. The example comment:

# Edit history between 5abd0a5c28d1 and b54649a8a63f
#
# Commits are listed from least to most recent
#
# You can reorder changesets by reordering the lines
#
# Commands:
#
#  e, edit = use commit, but stop for amending
#  m, mess = edit commit message without changing commit content
#  p, pick = use commit
#  b, base = checkout changeset and apply further changesets from there
#  d, drop = remove commit from history
#  f, fold = use commit, but combine it with the one above
#  r, roll = like fold, but discard this commit's description
#
# Deleting a changeset from the list will DISCARD it from the edited history!
2016-03-19 11:39:13 -07:00
Jun Wu
745b527cb7 histedit: do not close stdin
Closing stdin is unexpected by chgserver and is not a good idea generally.
This patch refactors related code a bit and make sure stdin is not closed.
It will make chg much happier on test-histedit*.t.
2016-03-15 00:42:33 +00:00
Mateusz Kwapich
812fb817e3 histedit: have dropmissing abort on empty plan
We noticed that many users have the intuition of laving the editor empty when
they want to abort the operation. The fact that dropmissing allows user to
delete all edited commits is not intuitive even for users that asked for it.

Let's prevent people from this footgun.
2016-03-13 16:46:49 -07:00
liscju
7a7ee3b559 histedit: adds hint how to reorder changesets at editor (issue3766) 2016-03-08 21:59:06 +01:00
timeless
6b7ebe1ed5 histedit: reword message when a changeset produces no changes
There are various ways to use histedit such that an item in
the list of things to perform will not result in a change
relative to the previous repository state.

When that happens, histedit does not keep the commit/message.

This changes the note to try to explain to the user that it
will not be present in their history.
2016-03-02 22:39:03 +00:00