Commit Graph

163 Commits

Author SHA1 Message Date
Durham Goode
8cf27316ea histedit: allow histedit --continue when not on a descendant (BC)
Previously we would not allow --continue if the current working copy parent was
not a descendant of the commit produced by the previous histedit step. There's
nothing really blocking us from continuing the histedit in this situation, so
let's stop aborting in this case.

This is technically a BC change, but it is making things more forgiving so I
think it's ok.

In the future we will likely add an 'exec' action to histedit, which means the
user can do whatever they want during the middle of a histedit (like perhaps
calling 'hg update'), which means we'll need to support this case eventually
anyway.
2015-04-04 01:00:05 -07:00
Durham Goode
2d8e97020e histedit: store backup file before histedit
It's possible for the user to delete some of the commits they started with
during a histedit, and aborting the histedit doesn't bring them back. Let's
store a backup bundle so we can always recover the stack of commits from before
they began.
2015-04-04 02:37:43 -07:00
Durham Goode
ecf9be40a5 histedit: replace pickle with custom serialization
Pickle is undesirable, so let's serialize it ourselves. We keep the ability to
parse existing pickle blobs for now.
2015-04-13 08:23:57 -07:00
Durham Goode
04eb9da604 histedit: fix preventing strips during histedit
We were trying to prevent strips of important nodes during histedit,
but the check was actually comparing the short hashes in the rules to
the exact value the user typed in, so it only ever worked if the user
typed a 12 character hash.
2015-04-04 11:24:48 -07:00
Durham Goode
e49196de24 histedit: remove extra histedit constructor call
In a previous commit we removed the extra histedit object instance being
constructed in --continue and --abort. The new --edit-todo missed this fix
though (which means the state object it produces doesn't have the locks on it).
It's not breaking anything now, but let's go ahead and clean that up before we
forget.
2015-03-11 07:19:55 -07:00
Anton Shestakov
638673ec74 histedit: use better meta-variable names than VALUE in help text
Before this change hg help histedit would use the default variable label:

    --commands VALUE
...
 -r --rev VALUE [+]

With this change the text will be in the usual help text style and a bit more
explanatory:

    --commands FILE
...
 -r --rev REV [+]
2015-03-09 14:32:17 +08:00
Anton Shestakov
23b1ae0b86 histedit: tweak --commands help text
The rest of help messages for command arguments are simple phrases without any
ending punctuation, so having this text be a complete sentence didn't really
fit.
2015-03-09 14:10:42 +08:00
Mateusz Kwapich
0ddde4bfd1 histedit: add a config allowing changing histedit rule line length limit
Since many users are using terminals wider than 80 chars there should be an
option to have longer lines in histedit editor.

Even if the summary line is shorter than 80 chars after adding action line
prefixes (like "pick 7c2fd3b9020c") it doesn't fit there anymore. Setting
it to for example 110 would be a  nice option to have.
2015-01-21 14:45:24 -08:00
Matt Mackall
94d4298620 histedit: fix style of new error message
- lowercase
- no punctuation
- brief
- short node
2015-03-03 17:28:05 -06:00
Mateusz Kwapich
f867af76c9 histedit: add --edit-plan option to histedit
--edit-plan allows user to edit remaining histedit rules in the middle of
histedit process
2015-01-22 12:36:38 -08:00
Mateusz Kwapich
ddb3155c4d histedit: generalize makedesc
Allow makedesc to generate description for any action - not only pick.
(to be used in histedit --edit-plan)
2015-01-22 10:52:50 -08:00
Mateusz Kwapich
3735b62df2 histedit: extract method ruleeditor
Extract functionality of editing histedit rules to separate method so we can
reuse it in upcoming --edit-plan option.
2015-02-23 10:57:27 -08:00
Durham Goode
8504194a9f histedit: don't recreate state object
Previously, the histedit state object was being recreated during continue/abort.
This meant that the locks that were held on the original state object were not
available to actions, which meant actions could not release the lock on the
repository (like an 'exec' action would need to do).

This affected our internal extension that added the 'exec' action.
2015-02-17 19:59:26 -08:00
Mateusz Kwapich
d8c405977d histedit: switch state to store node instead of ctx
Currently, if the node no longer exists, the state object fails to load
and pukes with an exception. Changing the state object to only store the
node allows callers to handle these cases.  For instance, in
bootstrapcontinue we can now detect that the node doesn't exist and exit
gracefully.

The alternative is to have the state object store something like None
when the node doesn't exist, but then outside callers won't be able to
access the old node for recovery (unless we store both the node and the
ctx, but why bother).

More importantly it allows us to detect this case when doing hg histedit
--abort.  Currently this situation results in both --continue and
--abort being broken and the user has to rm .hg/histedit-state to unwedge
their repo.
(description by Durham Goode)
2015-02-05 13:10:07 -08:00
Mateusz Kwapich
aa07ec44a0 histedit: don't allow to strip nodes which are necessary to continue histedit
During histedit we don't want user to do any operation resulting in
stripping nodes needed to continue history editing. This patch
wraps the strip function to detect such situations.
2015-01-30 16:47:35 -08:00
Durham Goode
14bdd4051b histedit: allow configuring default behavior
Adds a configuration setting for allowing users to specify the default behavior
of 'hg histedit' without arguments. This saves users from having to manually
figure out the bottom commit or a complicated revset. My current revset of
choice is "only(.) & draft() - ::merge()"

The commits that histedit can work with is usually quite limited, so if this
feature ends up working well, we may want to consider making "only(.) & draft()
- ::merge()" the default behavior for everyone.
2015-02-02 16:19:35 -08:00
Mateusz Kwapich
4e97391ce2 histedit: store full node hash in rules
Previously histedit only stored the short version of the rule nodes in the
state. This meant that later we couldn't resolve a rule node to its full
form if the commit had been deleted from the repo.

Let's store the full form from the beginning.
2015-01-26 15:18:07 -08:00
Augie Fackler
fae3cac059 histedit: miscellaneous style cleanups
Fix some mis-wrapped lines, re-wrap some lines to be more compact,
remove superfluous parens.
2014-10-16 14:55:45 -04:00
Augie Fackler
7c83341fc3 histedit: update docstring on histeditstate.read()
The docstring showed the previous class-less heritage of read(). Now
that it's classy, update the docstring.
2014-10-16 14:51:15 -04:00
Augie Fackler
09cf4ee603 histedit: remove now-superfluous repo argument from processreplacement
Spotted by Olle on the mailing list during review.
2014-10-16 14:49:46 -04:00
David Soria Parra
c65ab5256c histedit: move locks into state
Allow action functions to control the locks. This is necessary for
an implementation of x/exec or similar.
2014-10-15 08:38:36 -07:00
David Soria Parra
682ab7e2b3 histedit: read state from histeditstate
Read the state in histeditstate. This allows us to correctly update
internal variables when necessary without having to recreate a new
state.  When we read a state in _histedit state while we will already
have state passed from histedit(), we can read the state in place
and don't have to merge two histeditstates.
2014-10-15 08:38:16 -07:00
David Soria Parra
11e6c07280 histedit: pass state to action functions 2014-10-15 08:18:26 -07:00
David Soria Parra
458406fb0a histedit: pass state to processreplacement 2014-10-16 10:06:49 -07:00
David Soria Parra
f49484c47e histedit: pass state to boostrapcontinue
Pass the state to boostrapcontinue and remove the unecessary passing
of repo.
2014-10-15 08:06:15 -07:00
David Soria Parra
e76bcb59ab histedit: let the state expose a context but serialize correctly to nodes
The histedit code often expects a context. However histedit hands
around the tuple for the serialization and therefore hand over a
parentctxnode. This leads to code having to return a context based
on the parentctxnode. We let the state only return a context but
correctly serialize and deserialze to a node.
2014-10-15 17:11:54 -07:00
David Soria Parra
98dfaf4629 histedit: add clear method to remove state
Encapsulate the unlinking histedit-state and use the vfs layer instead of
os.unlink.
2014-10-15 17:30:57 -07:00
David Soria Parra
db9d057e8e histedit: use state object where necessary
We are using the properties from the state object where necessary and
ensure that the state is set correctly.
2014-10-14 20:35:17 -07:00
David Soria Parra
80d1c27177 histedit: add histedit state class
Add an histeditstate class that is intended to hold the current
state.  This allows us encapsulate the state and avoids passing
around a tuple which is based on the serialization format. In
particular this will give actions more control over the state and
allow external sources to have more control of histedits behavior,
e.g. an external implementation of x/exec.
2014-10-15 17:17:12 -07:00
Durham Goode
faa1c33f8b obsolete: add allowunstable option
This option allows the creation of unstable commits. This allows things like
amending in the middle of a stack of commits, etc.
2014-10-14 13:25:13 -07:00
Durham Goode
18f3737f3a obsolete: add createmarkers option
The basic obsolete option is allowing the creation of obsolete markers. This
does not enable other features, such as allowing unstable commits or exchanging
obsolete markers.
2014-10-14 13:23:52 -07:00
Martin von Zweigbergk
c8176c1f40 histedit: access status fields by name rather than index 2014-10-04 21:19:44 -07:00
Matt Mackall
a61dbef490 histedit: use merge.graft 2014-10-13 17:12:47 -05:00
Matt Mackall
f663e5fc01 duplicatecopies: move from cmdutil to copies
This is in preparation for moving its primary caller into merge.py,
which would be a layering violation in the current location.
2014-10-13 14:33:13 -05:00
Matt Mackall
9286044a06 histedit: fix indent
The duplicatecopies call should be part of the rebase block.
2014-10-13 14:04:11 -05:00
Pierre-Yves David
256f11e0d3 histedit: stabilise the order nodes that are stripped
The `nodes` object is a set. We sort it to get stable order. This is going to
prevent revsets from getting confused when removing a `.set()` call in `roots`.
2014-10-10 13:31:00 -07:00
Augie Fackler
2ecee11b67 histedit: check mutability of contexts correctly
The right way to check if a context is mutable is to call .mutable(),
not to compare .phase() with public.
2014-08-19 14:33:01 -04:00
Durham Goode
a5a69f0001 dirstate: wrap setparent calls with begin/endparentchange (issue4353)
This wraps all the locations of dirstate.setparent with the appropriate
begin/endparentchange calls. This will prevent exceptions during those calls
from causing incoherent dirstates (issue4353).
2014-09-05 11:36:20 -07:00
Kevin Bullock
6cd9563e40 merge with stable 2014-09-07 11:46:11 -05:00
Siddharth Agarwal
ca3e00a8e3 histedit: abort gracefully on --continue/--abort with no state
Previously we'd print an ugly message saying that the histedit-state file
doesn't exist in the repo.
2014-09-03 20:42:51 +02:00
Mads Kiilerich
4dd236da3f convert: use None value for missing files instead of overloading IOError
The internal API used IOError to indicate that a file should be marked as
removed.

There is some correlation between IOError (especially with ENOENT) and files
that should be removed, but using IOErrors to represent file removal internally
required some hacks.

Instead, use the value None to indicate that the file not is present.

Before, spurious IO errors could cause commits that silently removed files.
They will now be reported like all other IO errors so the root cause can be
fixed.
2014-08-26 22:03:32 +02:00
Mike Edgar
7d4f56ed60 histedit: use str.startswith to check for comments in action list 2014-08-22 16:40:34 -04:00
Mike Edgar
f32b610c93 histedit: drop duplicate line extracting keep option 2014-08-22 16:37:55 -04:00
Martin von Zweigbergk
69e9a354a2 histedit: preserve initial author on fold (issue4296)
When the authorship of the changeset folded in does not match that of
the base changeset, we currently use the configured ui.username
instead. This is especially surprising when the user is not the author
of either of the changesets. In such cases, the resulting authorship
(the user's) is clearly incorrect. Even when the user is folding in a
patch they authored themselves, it's not clear whether they should
take over the authorship. Let's instead keep it simple and always
preserve the base changeset's authorship. This is also how
"git rebase -i" handles folding/squashing.
2014-08-13 11:50:13 -07:00
Augie Fackler
73aafc176d histedit: respect revsetalias entries (issue4311)
We now expand user-provided revsets before using repo.revs() to locate
the root(s) of the user-specified set.
2014-07-28 19:20:13 -04:00
Matt Mackall
25d1182c5d merge with stable 2014-08-14 15:21:48 -05:00
Mike Edgar
fb41d0ff84 histedit: add "roll" command to fold commit data and drop message (issue4256)
This new histedit command (short for "rollup") is a variant of "fold" akin to
"hg amend" for working copy: it accumulates changes without interrupting
the user and asking for an updated commit message.
2014-08-06 16:51:41 -04:00
Matt Mackall
7cba48bf37 whitespace: nuke triple blank lines in **.py 2014-08-07 14:58:12 -05:00
FUJIWARA Katsunori
f3bc52a2ae histedit: pass 'editform' argument to 'cmdutil.getcommiteditor'
This patch passes 'editform' argument according to the format below:

  EXTENSION[.COMMAND][.ROUTE]

  - EXTENSION: name of extension
  - COMMAND: name of command, if there are two or more commands in EXTENSION
  - ROUTE: name of route, if there are two or more routes for COMMAND

In this patch:

  - 'edit', 'fold', 'mess' and 'pick' are used as COMMAND
  - ROUTE is omitted

'histedit.pick' case is very rare, but possible if:

  - target revision causes conflict at merging (= requires '--continue'), and
  - description of it is empty ('hg commit -m " "' can create such one)

In the code path for 'histedit --continue' (the last patch hunk),
'canonaction' doesn't contain the entry for 'fold', because 'fold'
action causes:

  - using temporary commit message forcibly, and
  - making 'editopt' False always (= omit editor invocation if commit
    message is specified)
2014-08-02 21:46:26 +09:00
FUJIWARA Katsunori
9aa5fab4ec histedit: use 'util.ellipsis' to trim description of each changesets
Before this patch, trimming description of each changesets in histedit
may split at intermediate multi-byte sequence.

This patch uses 'util.ellipsis' to trim description of each changesets
instead of directly slicing byte sequence.

Even though 'util.ellipsis' adds '...' as ellipsis when specified
string is trimmed (= this changes result of trimming), this patch uses
it, because:

  - it can be used without any additional 'import', and
  - ellipsis seems to be better than just trimming, for usability
2014-07-06 02:56:41 +09:00