Commit Graph

220 Commits

Author SHA1 Message Date
Mateusz Kwapich
0e2838b3e0 histedit: add abortdirty function
Small helper function for aborting histedit when left with dirty working
directory.
2015-11-17 17:53:52 -08:00
Mateusz Kwapich
0cd6ba356d histedit: add forceother constraint
For the future 'base' action in histedit we need a verification
constraint which will not allow using this action with changes
that are currently edited.
2015-11-12 16:40:33 -08:00
Mateusz Kwapich
45af8348f7 histedit: make verification configurable
Before we can add a 'base' action to histedit need to change verification
so that action can specify which steps of verification should run for it.

Also it's everything we need for the exec and stop actions implementation.

I thought about baking verification into each histedit action (so each
of them is responsible for verifying its constraints) but it felt wrong
because:
 - every action would need to know its context (eg. the list of all other
   actions)
 - a lot of duplicated work will be added - each action will iterate through
   all others
 - the steps of the verification would need to be extracted and named anyway
   in order to be reused

The verifyrules function grows too big now. I plan to refator it in one of
the next series.
2015-11-17 16:37:26 -08:00
Laurent Charignon
8ace80e21d histedit: make use of bookmarks.recordchange instead of bookmarks.write
Before this patch we were using the old api bookmarks.write, this patches
replaces its usage by bookmarks.recordchange, the new api to record bookmark
changes.
2015-11-20 13:23:47 -08:00
liscju
8a47b8ef21 histedit: extracts _isdirtywc function
Checking if working copy is dirty was done in few places, this
patch extracts it in _isdirtywc procedure.
2015-11-12 12:44:15 +01:00
Pierre-Yves David
eaea148fdb histedit: properly apply bundle2 backups
If the histedit fails, we restore a backup. We make sure this backup bundle can
be in bundle2 format as general delta will require.
2015-10-20 03:07:23 +02:00
Durham Goode
6c10065cf4 histedit: make histedit prune when obsolete is enabled
Back in June we made histedit use obsolete markers to cleanup when possible.
This was rolled back as part of bb3db0db4037 (which should have only rolled back
the --abort stuff, but rolled back everything). This caused a nasty bug when
used in conjuction with the inhibit+directaccess extensions where histedit would
leave old nodes around even after they had been squashed away.

The root of the problem is that we first clean up old nodes, and then we clean
up temp nodes. In the first pass, when we obsoleted old nodes, some would become
unobsolete because they had temp nodes on top of them, thus making them stick
around even after the histedit finished.

The fix is to A) move the temp node cleanup to be before the old node cleanup
(since they are topological on top of the old nodes), and B) use obsolete
markers instead of stripping.
2015-10-17 12:32:23 -07:00
Augie Fackler
f53d137cd7 histedit: use cg?unpacker.apply() instead of changegroup.addchangegroup() 2015-10-13 17:14:21 -04: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
Christian Delahousse
7472064a6f histedit: delete histedit statefile on any exception during abort
When an user aborts a histedit, many things could go wrong. At a minimum, after
a histedit abort failure, their repository should be out of that state. We've
found situations where the user could not exit the histedit state without
manually deleting the histedit state file. This patch ensures that if any
exception happens during an abort, the histedit statefile will be deleted so
that users are out of the histedit state and can at least manually get the repo
back to a workable condition.
2015-10-05 16:44:45 -07:00
Christian Delahousse
77b3596e11 histedit: check presence of statefile before deleting it
When the histeditstate class instance has it's clear() method called, there is
nothing to check to see if the state file exists before deleting it. It may not
exist, which would create an exception. This patch allows clear to be called at
any time.

This will be needed for the following patch.
2015-10-06 15:09:28 -07:00
Christian Delahousse
6f2b3a468a histedit: add inprogress method to state class
If a histedit is progress, the 'histedit-state' file should exist. The patch
implements a convenience function to do check if a histedit is in progress.

This method will be use in next patch in the series.
2015-10-05 16:34:17 -07:00
Pierre-Yves David
374e65cff5 histedit: remove a mutable default argument
Mutable default arguments are know to the state of California to cause bugs.
2015-09-24 00:38:34 -07:00
Augie Fackler
57b1966770 histedit: use one editor when multiple folds happen in a row (issue3524) (BC)
This was the first ever feature request for histedit, originally filed
back on April 4, 2009. Finally fixed.

In the future we'll probably want to make it possible for other
preprocessing steps to be added to the list, but for now we're
skipping that because it's unclear what the API should look like
without a proposed consumer.
2015-08-27 14:46:26 -04:00
timeless@mozdev.org
c07651e722 histedit: fix grammar in cleanupnode comment 2015-09-08 20:30:01 -04:00
timeless@mozdev.org
0ceae1ee9a histedit: fix English (en-US) 2015-08-28 13:52:49 -04:00
timeless@mozdev.org
e88cb37448 histedit: improve discoverability of edit commit message 2015-08-28 15:50:36 -04:00
timeless@mozdev.org
52eae47139 spelling: behaviour -> behavior 2015-08-28 10:53:55 -04:00
timeless@mozdev.org
b8d4ab1619 histedit: fix grammar for help for safety aborts 2015-08-28 11:31:44 -04:00
Augie Fackler
25ce37007c histedit: correct spelling etc in more comments
Spotted during review of another patch.
2015-08-17 22:56:12 -04:00
Pierre-Yves David
d1822462df histedit: add a missing "s" in a comment 2015-07-31 12:54:16 -07:00
Pierre-Yves David
d7dbab10fd histedit: do not stay on a cleaned nodes on abort
There is case where nodes are neither in tmpnodes nor leaf but still get
removed. For example, if you used the "edit" action, made a commit and run
--abort. The commit you made is not tracked by histedit, yet it will likely be
cleaned up with its parent. The commit may not tracked because no replacements
computations are done in the --abort case.
2015-08-03 06:13:05 -07:00
Pierre-Yves David
d31b5ec741 histedit: also update away from tmpnodes
The working copy may be on a tmpnodes, we need to update away before it is
stripped from the repository.
2015-08-03 06:11:45 -07:00
Pierre-Yves David
8eb6cf86e6 histedit: use revset to check if we need to update during abort
The for loop is already quite more complicated than necessary and we are about
to add some logic. Instead, we use a simple revset. Revset laziness should
provide us with similar performance.
2015-08-03 06:08:37 -07:00
Pierre-Yves David
063bf1acfb histedit: remove useless 'else' clause
This 'else: pass' clause have no effect. We drop it for clarity.
2015-08-03 05:57:45 -07:00
Pierre-Yves David
138cd324a8 histedit: make cleanupnode more robust
The goal of this function is to strip content out of the repository. We do not
really care if this content is visible or cleanup node not and we should proceed
anyway. None of the internal actions are subject to this, however, a third party
extension running arbitrary commands during histedit is affected by this.
2015-07-31 15:46:49 -07:00
Pierre-Yves David
a2cfbc8b70 histedit: extract a simpler function to process replacement on abort
The process replacement is building a full mapping to allow moving bookmarks and
creating obsolescence marker. We do not need the full logic for abort so we
extract it. It will be useful as abort is missing some data about the
replacement and can crash when third party extensions push it a bit too far.
2015-08-03 14:16:51 -07:00
Pierre-Yves David
6b2961e47a histedit: backout 3e883e7ec57b
The faulty changeset use obsolescence marker to roll the repository back on
--abort. This is a problematic approach because --abort should be as close as an
actually transaction rollback as possible stripping all created data from the
repository (cf `hg rebase --abort` stripping all created changesets). Instead
3e883e7ec57b made all content created during the aborted histedit still
available in the repository adding obsolescence marker to make them hidden. This
will cause trouble to evolution user as a re-run of the same histedit (with
success) will likely result in the very same node to be "recreated" while
obsolescence marker would be in place for them. And canceling an obsoletion is
still a fairly complicated process.

This also rollback using obsmarkers instead of strip to clean up temporary node
on successful histedit run because the two change were not split in separated
changeset. Rolling that part back does not have significant consequence a will
have to be resubmitted independently
2015-07-31 15:11:07 -07:00
Matt Mackall
f9425f2260 histedit: mark defaultrev option experimental 2015-06-25 17:37:35 -05:00
Laurent Charignon
e2ba5b2bbc histedit: mark temporary commits as obsolete when allowed to
Before this patch, we were stripping temporary commits at the end of a histedit
whether it was successful or not. If we can create obs markers, we should
create them instead of stripping because it is faster and safer.
2015-07-16 11:12:15 -07:00
Laurent Charignon
5d5716b606 histedit: minor refactoring of createmarkers check
We use a variable to store whether or not we can create obsolescence markers.
It makes the patch series more readable as we are going to reuse this
values in other places in the function.
2015-07-16 11:17:37 -07:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Augie Fackler
7dfc9502d8 histedit: abort rather than edit a public changeset (issue4704)
This is suboptimal as the user still has to explicitly cancel the
histedit afterwards, but it prevents the immediate problem.

histedit should probably implicitly do 'hg histedit --abort' if a
util.Abort is raised internally.
2015-06-05 15:20:33 -04:00
Augie Fackler
a8bce1d268 histedit: copyedit docstring wording problem I noticed while here 2015-06-05 15:12:08 -04:00
Jordi Gutiérrez Hermoso
a6105df67a phases: add hg help phases hint to failures to edit public commits
There were a couple of locations that were missing this hint after an
edition of some kind failed due to the public phase.
2015-06-01 14:16:52 -04:00
Jordi Gutiérrez Hermoso
3ed01018a3 phases: rewrite "immutable changeset" to "public changeset"
The phrase "cannot edit immutable changeset" is kind of tautological.
Of course unchangeable things can't be changed. We instead mention
"public" and provide a hint so that we can point to the actual
problem. Even in cases where some operation other than edition cannot
be performed, "public" gives the root cause that results in the
"immutable" effect.

There is a precedent for saying "public" instead of "immutable", for
example, in `hg commit --amend`.
2015-06-01 18:05:38 +00:00
Matt Mackall
82ee6a7ddc merge with stable 2015-05-29 17:00:55 -05:00
Durham Goode
70caa9d8e9 histedit: fix keep during --continue
The --keep option was being serialized to the state file, but it wasn't actually
being used when running a histedit --continue. This fixes that.
2015-05-28 20:30:20 -07:00
Durham Goode
af1cd08e45 histedit: fix --continue when rules are finished
If histedit failed after all the rules were complete (for instance, if there was
an exception in the cleanup phase), you couldn't --continue because it was
unable to pop a rule. Let's just skip the rule execution phase of --continue if
there are no more rules.
2015-05-01 15:45:07 -07:00
Durham Goode
be15b493fa histedit: fix serializing of None backupfile
If the histedit backupfile was None (like if evolve is enabled) it would get
serialized as 'None' into the state file. Later if the histedit was aborted and
the top most commit was unreachable (ex: if it was obsolete or stripped),
histedit would try to unbundle the backupfile and try to read .hg/None.

This fixes it to not serialize None. Since it only happens with evolve, I'm not
sure how to add test coverage here.
2015-05-01 15:28:47 -07:00
Durham Goode
d8291a43e1 histedit: fix --edit-plan
--edit-plan was completely broken from the command line because it used an old
api that was not updated (it would crash with a stack trace). Let's update it
and add tests to catch this.
2015-04-22 15:53:03 -07:00
FUJIWARA Katsunori
cc87b5c26d histedit: fix reST syntax problem of example code in help document
To show example code correctly in online help, text block of it should
be preceded by "::" and indented.
2015-04-28 23:27:18 +09:00
Wagner Bruna
9e590e39d1 histedit: fix typo in abort message 2015-04-21 21:01:17 -03:00
Durham Goode
f289436208 histedit: fix rollup prompting for a commit message (issue4606)
Commit 960f8ca79ab1 broke histedit's rollup by causing it to open the editor.
Turns out I missed a spot where the rollup option was read.

This fixes that and adjusts the test to catch this case.
2015-04-20 18:44:57 -07:00
Durham Goode
71ec25235f histedit: change state format to allow non-hash lines
The existing state serialization format assumed the rule line consisted of an
action and a hash. In our external extension that adds 'exec' this is not the
case (there is no hash, just the shell command). So let's change the format to
be more generic with just an action and a remainder, and the various commands
can handle it as they wish.

Flagged for stable since we want to get this format tweak in before the new
format goes live in the release.
2015-04-17 09:46:43 -07:00
Durham Goode
7f3a86f2d3 histedit: delete all non-actionclass related code
Now that all actions have been migrated to the class format, we can delete all
the unnecessary code that supported the old function format.
2015-04-04 02:16:48 -07:00
Durham Goode
adafa999c2 histedit: improve roll action integration with fold
Previously the fold action would inspect it's class to figure out if it was a
rollup or not. This was hacky. Now that finishfold is inside the fold class,
let's modify it to check a function (which roll can override) to determine if it
should be prompting for a commit message.
2015-04-04 02:12:53 -07:00
Durham Goode
e4084f95da histedit: move finishfold into fold class
Let's move the finishfold function into the fold class so we can modify it from
the roll class more easily.
2015-04-04 02:12:24 -07:00
Durham Goode
cdb6754f26 histedit: convert fold/roll actions into a class
This converts the fold/roll actions into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.

The tests changed for two reasons:

1) We get a new 'empty changeset' warning because we now warn more consistently
between normal histedit and --continue about commits disappearing.

2) Previously we were not putting the histedit-source extra field on the
temporary fold commit during normal runs, but we were on --continue runs. By
unifying these code paths we now consistently put histedit-source on the
temporary fold commit, which changes some of the hashes in the backup bundles.
2015-04-04 02:03:27 -07:00
Durham Goode
162b56f0ee histedit: convert edit action into a class
This converts the edit action into a histeditclass instance, as part of an
ongoing effort to refactor histedit for maintainability and robustness.
2015-04-04 01:00:51 -07:00