Commit Graph

292 Commits

Author SHA1 Message Date
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
Sean Farley
1002b6c612 memfilectx: call super.__init__ instead of duplicating code
This patch changes the calling signature of memfilectx's __init__ to fall in
line with the other file contexts.

Calling code and tests have been updated accordingly.
2013-08-15 16:49:27 -05:00
FUJIWARA Katsunori
876753dee7 histedit: use "getcommiteditor()" instead of explicit editor choice for "--continue"
This omits (redundant) adding "\n' to "message", because:

  - empty line is inserted by "commitforceeditor", if editor is invoked
  - tail white-spaces are stripped at storing into chaneglog, otherwise

This patch also enhances "test-histedit-edit.t", because "hg histedit"
hasn't been explicitly tested around editor invocation and
"--continue" option.
2014-05-11 00:49:35 +09:00
FUJIWARA Katsunori
768da96e03 histedit: use "getcommiteditor()" instead of explicit editor choice for "fold"
This patch doesn't change any tests like as preceding patches, because
editor invocation is already tested in "test-histedit-fold.t".
2014-05-11 00:49:35 +09:00
FUJIWARA Katsunori
1d4d1b5665 histedit: use the editor gotten by "getcommiteditor()" for "message"
Before this patch, "hg histedit" for "message" uses "ui.edit()" for
commit message editing.

It shows original commit message, but not detail about the target
revision: status of each modified/added/removed files, for example.

This patch uses the editor gotten by "getcommiteditor()" instead of
"ui.edit()" for "message"

In "test-histedit-edit.t", this patch omits "fixbundle" invocation,
because it prevents from confirming the "HG: added f" line in commit
message by filtering " added " lines.

Omiting "fixbundle" invocation causes that the exit code of "hg
histedit" appears as one of command line: in this case, "hg histedit"
is aborted by (expected) exception raising.
2014-05-11 00:49:35 +09:00
FUJIWARA Katsunori
741eb22d11 histedit: pass "editor" argument to "memctx.__init__()" for "collapse" command
The preceding patch causes that "memctx.__init__()" with "editor"
argument invokes editor and saves edited commit message into
".hg/last-message.txt".

This patch passes "editor" argument to "memctx.__init__()" instead of
explicit invocations of "commitforceeditor()" and
"savecommitmessage()" for "collapse" command.
2014-05-05 21:26:40 +09:00
FUJIWARA Katsunori
6e45a5e5e2 histedit: use "editor" argument of "commit()" instead of explicit "ui.edit()"
Before this patch, "message" action of "hg histedit" uses "ui.edit()"
explicitly to get commit message edited manually.

This requires explicit "localrepository.savecommitmessage()"
invocation to save edited commit message into ".hg/last-message.txt",
because unexpected exception raising may abort command execution
before saving it in "localrepository.commit()".

This patch uses "editor" argument of "localrepository.commit()"
instead of explicit "ui.edit()" invocation for "message" action of "hg
histedit"

"localrepository.commit()" will invoke "editor()" function newly added
in this patch, and save edited commit message into ".hg/last-message.txt"
automatically.
2014-05-05 21:26:40 +09:00
Wagner Bruna
7f9ce654b1 histedit, i18n: replace '+' with concatenation to make hggettext happy 2014-04-22 10:14:16 -03:00
Matt Mackall
6f3036019b merge with stable 2014-04-14 15:14:02 -04:00
FUJIWARA Katsunori
89625609bb histedit: save manually edited commit message into ".hg/last-message.txt"
Before this patch, manually edited commit message for "message"
command in histedit-ing is not saved into ".hg/last-message.txt" until
it is saved by "localrepository.savecommitmessage()" in
"localrepository.commit()".

This may lose such commit message, if unexpected exception is raised.

This patch saves manually edited commit message for "message" comand
in histedit-ing into ".hg/last-message.txt" just after user editing.

This is the simplest implementation to fix on stable. Editing and
saving commit message should be centralized into the framework of
"localrepository.commit()" with "editor" argument in the future.

This patch uses repository wrapping class for exception raising before
saving commit message in "localrepository.commit()" easily and
certainly, because such exception requires corner case condition.
2014-04-15 03:21:59 +09:00
FUJIWARA Katsunori
7ccf898121 histedit: save manually edited commit message into ".hg/last-message.txt"
Before this patch, manually edited commit message for "fold" command
in histedit-ing is never saved into ".hg/last-message.txt", because it
uses "localrepository.commitctx()" instead of
"localrepository.commit()": saving into ".hg/last-message.txt" is
executed only in the latter.

This patch saves manually edited commit message for "fold" command in
histedit-ing into ".hg/last-message.txt" just after user editing.

This is the simplest implementation to fix on stable. Editing and
saving commit message for memctx should be centralized into the
framework like "localrepository.commit()" with "editor" argument or so
in the future.
2014-03-19 01:07:41 +09:00
David Soria Parra
8c28662ef9 histedit: select the lowest rev when looking for a root in a revset (bc)
When we specify a revision or a revset we just get the last element from the
list. For revsets this can lead to unintended effects where you specify a
revset like only() but instead histedit selects the highest revision in the
set as root. Therefore we should always use the lowest revision number as
root.
2014-03-13 16:05:06 -07:00
Mads Kiilerich
2629efac4f config: set a 'source' in most cases where config don't come from file but code
Some extensions set configuration settings that showed up in 'hg showconfig
--debug' with 'none' as source. That was confusing.

Instead, they will now tell which extension they come from.

This change tries to be consistent and specify a source everywhere - also where
it perhaps is less relevant.
2014-03-19 02:45:14 +01:00
Matt Mackall
ea6ffc9a80 merge with stable 2014-03-18 14:25:28 -05:00
Olle Lundberg
572e5a90a5 histedit: move logic for finding child nodes to new function
This function will be used in later patches.
2014-03-06 01:24:03 +01:00
Olle Lundberg
eafad841b7 histedit: clean up lock imports
We are alread importing the release function from lock, no need
to actually import the module too.
2014-03-05 22:02:45 +01:00
Matt Mackall
b35d905ff6 histedit: shorten new fold message
Lots of people, like Mr. Check-Code, insist on using 80-column terminals.
2014-02-15 19:12:53 -06:00
Adrian Zgorzałek
4f40289598 histedit: clarify description of fold command
N and (N-1) didn't add any information to description of fold.
More useful is refering to the commit list as it is displayed in editor.
2014-02-13 18:05:35 -08:00
Siddharth Agarwal
def3d4797d histedit: hold wlock and lock while in progress
Currently, histedit acquires and releases lock and wlock several times during
its run. This isn't great because it allows other hg processes to come in and
change state. With this fix, lock and wlock are acquired and released exactly
once.

The change to test-histedit-drop.t is a minor implementation one -- the cache
is still correctly invalidated, but it just happens a little later and only
gets printed out because of the unrelated --debug flag.
2013-11-17 15:11:09 -08:00
FUJIWARA Katsunori
6371252cb7 histedit: add description about exit code 2013-10-27 00:24:25 +09:00
Matt Mackall
7b8a7d221c merge with stable 2013-10-01 17:00:03 -07:00
FUJIWARA Katsunori
da45f9c6a0 histedit: suggest "histedit --abort" for inconsistent histedit state
Mercurial earlier than 2.7 allows users to do anything other than
starting new histedit, even though current histedit is not finished or
aborted yet. So, unfinished (and maybe inconsistent now) histedit
states may be left and forgotten in repositories.

Before this patch, histedit extension shows the message below, when it
detects such inconsistent state:

   abort: REV is not an ancestor of working directory
   (update to REV or descendant and run "hg histedit --continue" again)

But this message is incorrect, unless old Mercurial is re-installed,
because Mercurial 2.7 or later disallows users to update the working
directory to another revision.

This patch changes the hint message to suggest "hg histedit --abort".
2013-10-01 00:35:07 +09:00
FUJIWARA Katsunori
0aaf5e6516 histedit: add more detailed help about "--outgoing" 2013-10-01 00:12:34 +09:00
FUJIWARA Katsunori
e27c19b1b7 histedit: abort if there are multiple roots in "--outgoing" revisions
Before this patch, if there are multiple roots in "--outgoing"
revisions, result of "histedit --outgoing" depends on the parent of
the working directory. It succeeds only when the parent of the working
directory is a descendant of the oldest root in "--outgoing"
revisions, and fails otherwise.

It seems to be ambiguous and difficult for users.

This patch makes "histedit --outgoing" abort if there are multiple
roots in "--outgoing" revisions always.
2013-10-01 00:12:34 +09:00
FUJIWARA Katsunori
e190bd65ec histedit: add more detailed help about "--outgoing" 2013-10-01 00:12:34 +09:00
FUJIWARA Katsunori
cd5b67960a histedit: abort if there are multiple roots in "--outgoing" revisions
Before this patch, if there are multiple roots in "--outgoing"
revisions, result of "histedit --outgoing" depends on the parent of
the working directory. It succeeds only when the parent of the working
directory is a descendant of the oldest root in "--outgoing"
revisions, and fails otherwise.

It seems to be ambiguous and difficult for users.

This patch makes "histedit --outgoing" abort if there are multiple
roots in "--outgoing" revisions always.
2013-10-01 00:12:34 +09:00
David Soria Parra
22083388ea histedit: remove unused parents() call 2013-09-26 14:47:19 +02:00
FUJIWARA Katsunori
ca113e2a18 histedit: add description about "histedit --outgoing" to command help
Before this patch, there is no explicit description that argument is
treated as the URL of the destination repository when "--outgoing" is
specified.

This patch adds description about "histedit --outgoing" to command
help of it.
2013-08-26 16:11:21 +09:00
FUJIWARA Katsunori
bc5efe5be4 histedit: add description about basic histedit function to command help
Before this patch, there is no explicit description that histedit
edits changesets between specified ancestor and the parent of the
working directory: users may notice it by error message "REV is not an
ancestor of working directory".

This patch adds description about basic histedit function to command
help of it.

This patch uses term "ancestor" instead of "parent", because it seems
to be more suitable, and almost all (error) messages already use it.
2013-08-26 16:11:21 +09:00
Matt Mackall
d52228b61b histedit: don't clobber working copy on --abort if not on histedit cset
Similar to issue4009, 2.7 will force people to abort histedits before
doing interesting things. Without this fix, people with histedit
sessions they wandered away from before upgrading to 2.7 could clobber
their working copy for no reason.
2013-08-01 19:55:02 -05:00
Matt Mackall
6d0d30f28a checkunfinished: accommodate histedit quirk
Turns out histedit actually intends for commits (but not other
operations like update) to be possible during its operation.
2013-07-25 02:17:52 -05:00
FUJIWARA Katsunori
08d72f6934 histedit: discard meaningless comment about 'hexlify node'
Refactoring in c253d4a7ab54 made this comment meaningless. The node
gotten by "discovery.findcommonoutgoing()" is hexlified in "between()"
by "repo.set('%n::%n', old, new)".
2013-08-26 16:11:21 +09:00
FUJIWARA Katsunori
61c090bc67 histedit: add description about "histedit --outgoing" to command help
Before this patch, there is no explicit description that argument is
treated as the URL of the destination repository when "--outgoing" is
specified.

This patch adds description about "histedit --outgoing" to command
help of it.
2013-08-26 16:11:21 +09:00
FUJIWARA Katsunori
0d68f18089 histedit: add description about basic histedit function to command help
Before this patch, there is no explicit description that histedit
edits changesets between specified ancestor and the parent of the
working directory: users may notice it by error message "REV is not an
ancestor of working directory".

This patch adds description about basic histedit function to command
help of it.

This patch uses term "ancestor" instead of "parent", because it seems
to be more suitable, and almost all (error) messages already use it.
2013-08-26 16:11:21 +09:00
Matt Mackall
90a5bc169d histedit: add checkunfinished support (issue3955)
The tests contain a couple corner cases where workarounds are now
required. Strictly speaking, these are behavior regressions, but of an
extremely obscure and marginal sort. Commits or updates in the middle
of a histedit would have almost always been fairly serious user error.
2013-07-24 23:51:44 -05:00
Augie Fackler
190da7405a histedit: refuse to edit history that contains merges (issue3962) 2013-07-24 17:39:29 -04:00
Augie Fackler
7ec2710f5c Merge histedit fixes from stable. 2013-07-16 11:13:18 -05:00
Martin Geisler
ed39a6fe25 histedit: use base for computing renames when folding (issue3729)
When a file was renamed in the very first changeset being histedited,
the rename was not detected. Consider a history like this:

   0  base: add a.txt
   1  first: rename a.txt to b.txt
   2  last: edit b.txt

When 1 and 2 are edited, copies.pathcopies(first, last) correctly
returns that nothing was renamed. We must instead use
copies.pathcopies(first, last) to detect the initial rename.
2013-07-15 15:04:42 +02:00
Simon Heimberg
ca09e06304 histedit: raise ImportError when demandloading is enabled 2013-06-05 21:16:49 +02:00
Pierre-Yves David
c044ef8de0 histedit: more precise user message when changeset is missing
Now that we explicitly detect duplicated changesets, we can explicitly
detect missing ones. We cover the same cases as before, some others
and we offer a better error message in all cases.
2013-04-18 15:27:50 +02:00
Pierre-Yves David
f340c552d8 histedit: protect against duplicated entries
Before this change one would issue rules with duplicated entries. For
this to happen some other changeset had to be missing to maintain the
rules length.
2013-04-18 15:22:24 +02:00
Pierre-Yves David
f70c25782a histedit: track short hash instead of changectx object
This simplifies set usage and allow us to add a missing revision check
in a later commit.
2013-04-18 15:13:35 +02:00
Pierre-Yves David
1df8cacc3e histedit: ensure rules return short hex at all time
Handling homogeneous data is both simpler and safer.
2013-04-18 15:10:01 +02:00
Pierre-Yves David
96ebb157a6 histedit: handle multiple spaces between action and hash (issue3893)
There is some clue that the previous code intended to handle that but it was
actually not the case.

As a result action could apply to the empty string '' changeset,
leading to the use the current working directory parent in some
operations.
2013-04-18 11:52:34 -04:00
Pierre-Yves David
5aac367884 histedit: move outgoing processing to its own function
Every piece of code extracted from the main command is a win. We simplify
changeset determination in the process. Parent ceases being a list before
becoming a node. We how have a root variable containing a node all the time.
2013-04-16 21:14:50 +02:00
Pierre-Yves David
8136aa6698 histedit: move all arguments checks to the beginning of the command
This changeset move all checks and raises related to arguments
validation to the top of the file. This gathers all the logic in one
place and clarifies the code doing actual work. This paves the way for
splitting this gigantic function in separated functions.

A `goal` variable is introduced in the process. It holds the action to
be done by this invocation (new, continue or abort).

An invalid invocation is found in the process (the new code is a bit stricter).
2013-04-16 21:17:13 +02:00
Pierre-Yves David
aabd767b0a histedit: allow "-" as a command file
When "-" is specified as a command file, we read rules from stdin. Alter a
single test to demo the behavior, but most of them could benefit from this.

There is minor change in test output resulting from the fact we no
longer change log messages.
2013-04-16 20:48:37 +02:00
Pierre-Yves David
ab56a3f4b1 histedit: properly handle --continue on empty fold
When all changes from the fold have been dropped, the --continue code was
confused. This changeset handles this case.

The test for this case existed but was broken.
2013-04-16 16:58:25 +02:00
FUJIWARA Katsunori
8a7f148b06 histedit: make "hg histedit" sensitive to branch in URL
Before this patch, "hg histedit" are not sensitive to the branch
specified in the URL of the destination repository, even though "hg
push"/"hg outgoing" are so:

Invocation of "discovery.findcommonoutgoing()" without "onlyheads"
argument treats revisions on branches other than the one specified in
the URL as outgoing ones unexpectedly.

This patch specifies list of head revisions, which are already
detected by "hg.addbranchrevs()" from URL and looked up against local
repository, as "onlyheads" to "discovery.findcommonoutgoing()" to
limit calculation of outgoing revisions.
2013-04-09 23:40:10 +09:00
Matt Mackall
1035a87704 merge with stable 2013-06-07 16:59:59 -05:00
Bryan O'Sullivan
fdf311e2c6 summary: add a histedit hook 2013-05-14 11:23:18 -07:00
Augie Fackler
45ed657bf8 histedit: switch from util.Abort to util.InterventionRequired where appropriate (bc) 2013-02-08 16:27:49 -06:00
Bryan O'Sullivan
434777d4af histedit: support editing of the first commit (issue3767) 2013-04-12 16:01:18 -07:00
Mads Kiilerich
5787baee50 spelling: fix some minor issues found by spell checker 2013-02-10 18:24:29 +01:00
Simon Heimberg
d394522225 histedit: always abort with same message when working dir is wrong.
Using only one message makes live easier for translators. The clearer
error message was supposed by Augie Fackler.
2013-08-03 16:40:13 +02:00
Simon Heimberg
6e94c23bab histedit: report when revisions to edit are not ancestors of working dir
Editing the history only is possible when the working dir is a descendant of
the revisions to edit. When this happens explain it by writing
  abort: %s is not an ancestor of working directory
2013-08-03 16:37:17 +02:00
Augie Fackler
404721d3a3 histedit: prevent parent guessed via --outgoing from being a revset (issue3770)
If the binary hash of the parent node guessed via --outgoing happened
to contain a special revset character (":" was specified in the bug),
the revset parser would abort. Hexlifying the node before passing it
to the revsingle call should fix that.
2013-01-30 10:57:28 -05:00
Pierre-Yves David
f52bcf462a histedit: proper phase conservation (issue3724)
Before this changeset, histedit created all new changesets according
phases.new-commit option without any regards for the phases of the original
changesets.

This changeset fix that using the phase of rewritten changeset to decide the
phase of the resulting changeset. In case of reordering or folding, we keep
secret item secret as it seems the safer path.

temporary commit creation are not affected. They are head only and stripped at
the end of the histedit.

As for the resolution of issue3681 (obsolescence cycle prevention), we do not
handle changesets created by edit command.
2013-01-16 19:21:03 +01:00
Pierre-Yves David
5bda497c6d histedit: record histedit source (issue3681)
Have histedit record the hex of the original changeset as already done by:
- graft
- commit --amend
- rebase

My main motivation for adding this is to prevent the creation of obsolescence cycle
(see issue3681).

Note that commit created during edit are not affected yet.
2013-01-16 19:14:22 +01:00
Pierre-Yves David
e9b9dbf10f histedit: factor most commit creation in a function
Later commits add two important items to histedit:
- Obsolescence cycle prevention
- Proper phase conservation

Those logics must be applied to all simple operations (pick, edit, mess) and
will require verbose code.

So we introduce a new function that will provide an entry point for this new.
logic.

The function build a closure to have a clear distinction between commit
arguments and data provided to the function to fulfil its logic.
2013-01-16 19:11:06 +01:00
Mads Kiilerich
b76126725e histedit: process bookmarks in sorted order 2012-12-12 02:38:14 +01:00
Kevin Bullock
bd7b56e105 merge with stable 2013-01-14 10:17:06 -06:00
FUJIWARA Katsunori
573ec722a6 histedit: correct the number of added revisions in online help
In the context of help document on which this patch focuses, the
example repository, which is source of cloning, should be already
histedit-ed, and contain only 3 revisions (rev # 0 to 2). So, not 3,
but 4 revisions should be added to the destination repository of
cloning, if it contains 7 revisions (rev # 0 to 6).

This patch also adds modifier "histedit-ed" to "example repository",
to make context clear.
2013-01-14 23:14:45 +09:00
FUJIWARA Katsunori
75da74f62e histedit: correct changeset IDs in online help
There is no '633536316234' revision in the example repository. It
should be 'c561b4e977df', according to the revisions in it and
explanation in help document.
2013-01-14 23:14:45 +09:00
Pierre-Yves David
d625ea9d23 clfilter: drop unnecessary explicit filtering on histedit
Hidden changeset filtering is now done at repo level. The orphaned
children computation will not include any (unless you add --hidden).
2012-12-24 12:00:08 +01:00
Pierre-Yves David
febbf1f08f histedit: allow operation from non-head if obsolete is enabled
Obsolescence markers can represent this situation just fine. Rewritten
revisions are marked as precursors of the ones creates by
histedit. Unaffected descendants become "unstable".

If obsolescence is not enabled we keep the current behavior of
aborting. This new behavior only applies when obsolete is
enabled and is subject to future discussion and changes.
2012-12-31 17:46:22 -06:00
Augie Fackler
9766845689 bookmarks: introduce a bmstore to manage bookmark persistence
Bookmarks persistence still showed a fair amount of its legacy as a
monkeypatching extension. This encapsulates all bookmarks
serialization and parsing in a single class, and offers a single
location where other bookmarks storage engines can be substituted
in. As a result, many files no longer import the bookmarks module,
which strikes me as an encapsulation win.

This doesn't do anything to the current bookmark state yet, but I'm
hoping put that in the bmstore class as well.
2012-11-07 16:21:39 -06:00
Pierre-Yves David
4c13968496 histedit: create obsolescence markers in deterministic order
I arbitrary use the revnum of the precursor because it sound a right order.
2012-10-16 16:56:14 +02:00
Thomas Arendsen Hein
4ab7bd04fc histedit: max(x, key=y) and min(x, key=y) are not available in python 2.4
Use sorted(x, key=y)[-1] or sorted(x, key=y)[0] instead.
2012-10-16 16:04:28 +02:00
Pierre-Yves David
e5dbcdf7b1 histedit: do not use "min" on ctx
It does not crash but does not compare revision number at all. We actually
remove any call to min because the list is already topologically sorted.
2012-10-14 23:49:28 +02:00
Pierre-Yves David
29277d440c histedit: clean abort when there is nothing to edit 2012-10-14 23:58:02 +02:00
Pierre-Yves David
c86f3a557a histedit: rename revs in ctxs inside the between function
The variable content is actually contexts, not revision numbers.
2012-10-15 00:05:16 +02:00
Pierre-Yves David
f329dd0261 histedit: refuse to edit public changeset
Public changeset are immutable. This changeset enforce that in histedit.
2012-10-12 21:41:08 +02:00
Pierre-Yves David
2237d9bd3f histedit: ignores hidden revision when checking for orphaned nodes
We do not want hidden revision to block histedit. They are already "dead"
and we do not care about dead orphans. see similar changeset 40db49347807 for
rebase.
2012-09-27 14:00:52 +02:00
Pierre-Yves David
3607c94328 histedit: simplify computation of edited set (issue3620)
This complex code can be replaced by two simple revset calls.
2012-10-10 06:27:06 +02:00
Pierre-Yves David
e4f0351734 histedit: add obsolete support
When the obsolete feature is enabled, histedit creates obsolescence marker
instead of stripping replaced changesets.

For now, we keep stripping temporary nodes created along the way.
2012-09-27 13:59:48 +02:00
Pierre-Yves David
c922450686 histedit: replace various nodes lists with replacement graph (and issue3582)
This changeset rewrites the change tracking logic of histedit to record every
operation it does. Tracked operations record the full list of "old" node that
will eventually be removed to the list of new nodes that replace it. Operations
on temporary nodes are tracked too. Dropped changesets are also recorded as an
"old" node replacement by nothing. This logic is similar to the obsolescence
marker one and will be used for this purpose in later commit.

This new logic implies a big amount of change in the histedit code base.

histedit action functions now always return a tuple of

    (new-ctx, [list of rewriting operations])

The old `created`, `replaced` and `tmpnodes` are no longer returned and stored
during histedit operation. When such information is necessary it is computed
from the replacement graph. This computation is done in the `processreplacement`
function.

The `replacemap` is also dropped. It is computed at the end of the command from the
graph.  The `bootstrapcontinue` methods are altered to compute this different kind of
information.

This new mechanism requires much less information to be written on disk.

Note:

    This changes allows a more accurate bookmark movement. bookmark on dropped
    changeset are now move of their parent (or replacement of their parent)
    instead of their children.

    This fix issue3582
2012-10-11 08:36:50 +02:00
Matt Mackall
5047212c31 merge with durin42 2012-10-12 15:52:59 -05:00
Pierre-Yves David
8b8b1a2322 histedit: update bookmark movement notice
New format is:

    histedit: moving bookmarks <bookmark> from <old> to <new>
2012-10-10 05:54:38 +02:00
Pierre-Yves David
4a01290b0d histedit: simplify computation of newchildren during --continue
We are now checking for any changesets between the previous `parentctx` and the
current working directory parent. If the current working directory parent is
inconsistent, we abort.

This change is useful as it simplifies the --continue process, easing upcoming
changes.

While working on this changeset, I spotted an unhandled corner case. This corner
case is now documented and have an appropriate issue in the tracker (issue3655).
However, the corner case is still unhandled. handling this test case would
required some additional work:

- actually decide what the proper behavior should be:
- change content of "histedit-state" to add missing data necessary to detect
  the situation
- add proper testcase,

But leaving the case unhandled is "okay":

- this is not a regression,
- this is not the purpose of the current series,
- the freeze was near and I had more critical stuff to attend to,
- this is a simple but non trivial, (see above)
2012-10-10 06:20:14 +02:00
Pierre-Yves David
2448b893df histedit: move continue logic into a dedicated function
When histedit "continue", there is several complicated logic to apply in order to
detect intermediate changeset and concluded pending operation.

This changeset extract this logic in a dedicated function to lighten the main
one. No alteration to the logic is done.
2012-09-27 13:54:47 +02:00
Pierre-Yves David
a1ed29a5c8 histedit: rename tip to topmost
I expected `tip` to be repo's tip when it was the rewritten set tip. I rename
the variable to the less ambiguous `topmost`.
2012-09-26 18:13:00 +02:00
Pierre-Yves David
b30bd4fe4d histedit: factorise node stripping logic
Create a function dedicated to stripping a group of node. All existing
duplicated code is replaced by call to this function.

This new function take care of stripping known and relevant node only.
2012-09-26 14:46:08 +02:00
Pierre-Yves David
650044fefe histedit: extract bookmark logic in a dedicated function
This lighten the main function and will help to see future changes to this
bookmark logic.
2012-09-26 14:19:19 +02:00
Pierre-Yves David
9b26a9a8ee histedit: remove all usages of hex[:12]
- `node.hex(n)[:12]` is the same as `node.short(n)`
- `ctx.hex()[:12]` is the same as `str(ctx)`
2012-09-26 12:57:23 +02:00
Pierre-Yves David
7053ba6e9e histedit: replaces patching logic by merges
The old and fragile patching logic is replaced by smart merges (as rebase and
graft do). This should prevents some conflicts and smoother human resolution.

For this purpose the "foldchanges" function is renamed to "applychanges" and
handle a single revision only.
2012-09-21 19:27:22 +02:00
Pierre-Yves David
f9a739a15f histedit: display action being processed in debug mode
This is very useful when debugging histedit.
2012-09-21 19:25:19 +02:00
Pierre-Yves David
56df9607c6 histedit: fold in memory
Update the folding code to works in memory instead of applying patches on the
working directory. This is cleaner, faster and prepare the removal of the whole
patching logic.

This new collapse function will probably move into core sooner or later. A lot
of other rewriting operation may benefit from it.
2012-09-21 19:24:31 +02:00
Pierre-Yves David
c8363dbc19 histedit: move makedesc function near other rules related function
Having it in the middle of action logic is confusing
2012-09-21 00:33:30 +02:00
Pierre-Yves David
94277b3144 histedit: move between function outside the action logic
Having this function in the middle of action and patching logic did not make
sense
2012-09-21 19:14:04 +02:00
Pierre-Yves David
cb6a116fe7 histedit document the makedest function 2012-09-21 00:30:22 +02:00
Pierre-Yves David
603772df2b histedit: documents the between function 2012-09-21 00:30:07 +02:00
Patrick Mezard
c54ad25151 histedit: fix unused variable warnings spotted by pyflakes 2012-09-05 22:01:09 +02:00
Leah Xue
b766bced84 histedit: factored out diff/patch logic
This patch is the first step towards a refactoring of the histedit
extension to use underlying graft machinery instead of diff/patch as
discussed in issue3527. Replacing diff/patch with graft is necessary
to fix, for example, issue3582.
2012-08-21 16:06:34 -07:00
Matt Mackall
b2cf3ac691 merge with i18n 2012-08-06 12:03:07 -05:00
Wagner Bruna
d09c1ff6cb histedit, i18n: warn translators about edit command names 2012-08-02 11:45:16 -03:00
Wagner Bruna
1d9183c516 histedit: sync docstring with edit comment
The docstring should probably reuse the edit comment string instead.
2012-08-02 11:28:21 -03:00
Augie Fackler
124780aa68 histedit: add proper locking around repair.strip() calls 2012-08-01 09:41:57 -05:00
FUJIWARA Katsunori
846e85b25e histedit: make comment part of the file describing rules as translatable
"i18n.gettext()" invocation for "editcomment" itself should have
little impact for whole initialization cost of histedit, because it is
already invoked for initialization of the command table entry.

'\n\n' has to be added to the text being edited separately from
"editcomment", because leading 'line feed' characters are not exported
to "hg.pot" file correctly.
2012-07-30 03:27:07 +09:00
Mads Kiilerich
ffa7814143 histedit: add trailing newline when editing commit messages
test-histedit-edit.t failed because Solaris sed strips lines not ending with
\n.
2012-07-30 03:53:38 +02:00
FUJIWARA Katsunori
9b75cb3833 histedit: remove updating statistics line from the examples describing rules
Before this patch, updating statistics line appears at the bottom of
the examples describing rules to edit history.

But such line never appear in the file describing rules while
histedit-ing, so this patch removes that line from the examples.
2012-07-29 16:19:32 +09:00
Patrick Mezard
e7c675580e histedit: fix new nodes computation with --continue (issue3534)
When running the following actions:

  pick 617f94f13c0f 1 +4
  drop 888f9082bf99 2 +5
  fold 251d831eeec5 3 +6

if the fold fails, is fixed by the user with a new changeset, --continue
will ignore the new revision when generating the fold changelog. This
was caused by --continue detecting new changesets as descendants of the
parent not descendants of changesets in the initial list. In this case,
dropped changesets must be ignored.

Even with the computation fixed, the 'newchildren' list was always
emptied by the filtering loop and passed empty to finishfold().

Note that changesets dropped and recreated identically will still be
missed. This probably cannot be solved but is unlikely to happen.

Other things, like 'newchildren' having multiple heads, should be
checked as well.
2012-07-25 16:27:26 +02:00
Patrick Mezard
3502d58447 histedit: end folding message with an LF
This is convenient when running tests dumping the editor content, it
avoids the following output line to be mixed with histedit message.
2012-07-25 11:09:51 +02:00
Sune Foldager
ffe56435bf peer: introduce peer methods to prepare for peer classes
This introduces a peer method into all repository classes, which currently
simply returns self. It also changes hg.repository so it now raises an
exception if the supplied paths does not resolve to a localrepo or descendant.

Finally, all call sites are changed to use the peer and local methods as
appropriate, where peer is used whenever the code is dealing with a remote
repository (even if it's on local disk).
2012-07-13 21:46:53 +02:00
Adrian Buehlmann
92055c96e6 histedit: use cmdutil.command decorator 2012-07-06 22:43:10 +02:00
Augie Fackler
0b10b5edb8 histedit: add extension docstring from external README
Made a couple of tweaks to try and fit better with the hg docstring
style and fix up some ReST errors in the README.
2012-07-06 12:17:53 -05:00
Augie Fackler
39b1dce60e histedit: don't crash if the result of fixing up a fold is empty 2012-07-06 11:39:02 -05:00
Augie Fackler
3b175c50a8 histedit: replace hexshort lambda with node.short 2012-07-06 11:06:57 -05:00
Mads Kiilerich
7c32277ff3 histedit: use stable iteration order for processing bookmarks
Random dict iteration order caused test failure in
test-histedit-bookmark-motion.t.
2012-06-30 03:34:41 +02:00
Augie Fackler
a0a7fde1c9 histedit: mark as a first party extension 2012-06-28 08:45:38 -05:00
Augie Fackler
99e113bc35 histedit: remove use of reduce() builtin spotted by check-code 2012-06-27 18:42:48 -05:00
Augie Fackler
8f661724bc histedit: fix most check-code violations 2012-06-27 18:35:33 -05:00
Augie Fackler
526a183684 histedit: new extension for interactive history editing 2012-06-27 17:52:54 -05:00
Mads Kiilerich
588e53b65c spelling: fix minor spell checker issues 2012-10-10 01:29:56 +02:00