Commit Graph

874 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
86d8361294 mq: fold the code paths to invoke editor into specific logic (qrefresh/qfold)
This factoring simplifies the succeeding patch to switch from
"ui.edit()" to "getcommiteditor()" for qrefresh/qfold.
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
55e621635c mq: use the editor gotten by "getcommiteditor()" instead of "ui.edit()" (qnew)
This patch also replaces "editor = False" by "editor =
cmdutil.getcommiteditor()", because:

  - the latter allows to hook commit message determination easily,
    even in the case without "--edit"

  - the latter can avoid regression (or additional care) around saving
    "last-message.txt", even if MQ's "newcommit()" changes its
    implementation logic from "localrepository.commit" to
    "localrepository.commitctx" with "memctx" in the future

    to save commit message into "last-messge.txt" with "memctx",
    "editor" should be valid function.
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
5d5193e6c8 mq: fold the code path to invoke editor into specific logic (qnew)
This factoring simplifies the succeeding patch to switch from
"ui.edit()" to "getcommiteditor()" for qnew.
2014-05-11 00:49:36 +09:00
FUJIWARA Katsunori
0c74e7c7d1 mq: eliminate unused variable for test-check-pyflakes.t
"user" in "fold()" has become useless since ab68b153ce34.
2014-05-09 08:44:53 +09:00
FUJIWARA Katsunori
8430e60754 qrefresh: use "editor" argument of "commit()" instead of explicit "ui.edit()"
Before this patch, "hg qrefresh" and "hg qfold" invoke "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 "hg qnew" and "hg qfold"

"localrepository.commit()" will invoke "desceditor()" function newly
added by this patch, and save edited commit message into
".hg/last-message.txt" automatically.

This patch passes not "editor" but "desceditor" to "commit()", because
"hg qnew" and "hg qfold" require editor function to return edited
message (and invoke "patchheader.setmessage()" with it) if not empty,
or default message otherwise.

This patch also avoids "not q.applied" check at "hg qrefresh --edit",
because it is also checked in "queue.refresh()", and it is not needed
to get commit message from patch header before "queue.refresh()".
2014-05-05 21:26:40 +09:00
FUJIWARA Katsunori
0a1ee5ebe2 qrefresh: relocate message/patch-header handling to delay message determination
Before this patch, commit message for refreshed MQ changeset is
determined, and written into refreshed patch file before
"localrepository.commit()" invocation.

This makes refactoring to use "editor" argument of "commit()" instead
of explicit "ui.edit()" invocation in succeeding patch difficult.

This patch relocates message/patch-header handling to delay message
determination.
2014-05-05 21:26:40 +09:00
FUJIWARA Katsunori
9cb2df4ecc qnew: use "editor" argument of "commit()" instead of explicit "ui.edit()"
Before this patch, "hg qnew" invokes "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 "hg qnew".

"localrepository.commit()" will invoke "desceditor()" function newly
added by this patch, and save edited commit message into
".hg/last-message.txt" automatically.

This patch passes not "editor" but "desceditor" to "commit()", because
"hg qnew" requires editor function to return edited message if not
empty, or default message otherwise.

This patch applies "rstrip()" on "defaultmsg" at comparison between
"nctx.description()" and "defaultmsg", because the former should be
stripped by "changelog.stripdesc()" and the latter may have tail white
spaces inherited from "patchfn".
2014-05-05 21:26:40 +09:00
Mads Kiilerich
a0586f61a1 mq: repo['.'] is not a wctx, repo[None] is
The parameters passed to subrepo.submerge are confusing anyway.
2014-04-07 23:10:20 +02:00
Pierre-Yves David
8ab4eab6ab push: pass a pushoperation object to localrepo.checkpush
The `pushoperation` object contains strictly more data the arguments currently
passed to `localrepo.checkpush` we pass the new object instead. This function is
used by MQ to abort push that includes MQ changesets.

Note: extension that may use this function will have to align.
2014-04-01 13:45:48 -07:00
FUJIWARA Katsunori
ccc7916e45 localrepo: omit ".hgsubstate" also from "added" files
Before this patch, "localrepository.commit()" omits ".hgsubstate" from
"modified" (changes[0]) and "removed" (changes[2]) file list before
checking subrepositories, but leaves one in "added" (changes[1]) as it
is.

Then, "localrepository.commit()" adds ".hgsubstate" into "modified" or
"removed" list forcibly, according to subrepository statuses.

If "added" contains ".hgsubstate", the committed context will contain
two ".hgsubstate" in its "files": one from "added" (not omitted one),
and another from "modified" or "removed" (newly added one).

How many times ".hgsubstate" appears in "files" changes node hash,
even though revision content is same, because node hash calculation
uses the specified "files" directly (without duplication check or so).

This means that node hash of committed revision changes according to
existence of ".hgsubstate" in "added" at "localrepository.commit()".

".hgsubstate" is treated as "added", not only in accidental cases, but
also in the case of "qpush" for the patch adding ".hgsubstate".

This patch omits ".hgsubstate" also from "added" files before checking
subrepositories. This patch also omits ".hgsubstate" exclusion in
"qnew"/"qrefresh" introduced by changeset bbb8109a634f, because this
patch makes them meaningless.

"hg parents --template '{files}\n'" newly added to "test-mq-subrepo.t"
enhances checking unexpected multiple appearances of ".hgsubstate" in
"files" of created/refreshed MQ revisions.
2014-03-22 23:39:51 +09: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
FUJIWARA Katsunori
e280ea2008 mq: omit ".hgsubstate" from qnew/qrefresh target list for consistent node hash
Before this patch, even if specified file patterns and -I/-X options
cause listing ".hgsubstate" up in the target list, qnew/qrefresh put
".hgsubstate" into the target list individually and forcibly.

This changes how many times ".hgsubstate" appear in the target list
according to run-time conditions, and causes inconsistent node hash,
even though revision content is same, because node hash calculation
uses the specified target list directly (without duplication check or
so).

This patch always omits ".hgsubstate" from qnew/qrefresh target list
for consistent node hash.

This omitting doesn't miss including ".hgsubstate" changes, because:

  - "localrepository.commit()" puts ".hgsubstate" into the target list
    for "commitctx()" forcibly if needed

  - "mq.putsubstate2changes()" puts ".hgsubstate" into the target list
    for "patch.diff()" if it is not yet listed up
2014-03-20 00:10:45 +09:00
FUJIWARA Katsunori
ff356918e1 qnew: omit meaningless and harmful putting subrepositories into target list
Before this patch, qnew puts updated subrepositories into target list
forcibly, if any of -I, -X or patterns are specified.

But this is meaningless and harmful, because:

  - putting subrepositories into target list doesn't affect the result
    of "localrepository.status()"

    "dirstate.status()" invoked via "localrepository.status()" always
    omits subrepositories from the result of it

  - any -I/-X opts and empty "pats" causes unexpected failure

    when any -I/-X opts are specified, "inclsubs" are always added to
    "pats", even if "pats" is empty.

    but this changes meaning of "pats" from "including all to be
    included" to "including only listed subrepositories"

    this may exclude ".hgsub" and cause unexpected exception raising
    ("can't commit subrepos without .hgsub" ).

  - qnew at other than repository root (with -I, -X or any patterns)
    causes unexpected failure

    "scmutil.match()" treats pattern without syntax type as 'relpath'
    type (= one rooted at cwd).

    but qnew puts subrepository paths rooted at the repository root,
    and it causes unexpected exception raising ("SUBREPO not under
    root ROOT" in "pathutil.canonpath()"), if "hg qnew" is executed at
    other than repository root with -I, -X or any patterns.

This patch omits meaningless and harmful putting subrepositories into
target list.

This omitting doesn't miss including updated subrepositories, because
subrepositories are specified to "scmutil.matchfiles()" directly, to
get "match" object for "localrepository.commit()".
2014-03-20 00:10:45 +09:00
Matt Mackall
ea6ffc9a80 merge with stable 2014-03-18 14:25:28 -05:00
FUJIWARA Katsunori
d87cd6b53c qfold: save manually edited commit message into ".hg/last-message.txt"
Before this patch, manually edited commit message for "hg qfold -e"
isn't 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 "hg qfold -e" into
".hg/last-message.txt" just after user editing. This patch doesn't
save the message specified by -m/-l options as same as other commands.

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-03-19 01:07:41 +09:00
FUJIWARA Katsunori
84f2d9a815 qnew: save manually edited commit message into ".hg/last-message.txt"
Before this patch, manually edited commit message for "hg qnew -e"
isn't 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 "hg qnew -e" into
".hg/last-message.txt" just after user editing. This patch doesn't
save the message specified by -m/-l options as same as other commands.

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-03-19 01:07:41 +09:00
Yuya Nishihara
16bbd89ec4 cmdserver: recreate mq object on runcommand in case queue path was changed
repo.mq needs to be recreated after queue path change.  Since there is little
benefit to keep invalidated mq object, it always delete repo.mq.
2014-03-03 19:41:30 +09:00
Yuya Nishihara
ff2e18c10c cmdserver: reload mq on each runcommand request to avoid corruption
If mq was changed by another process, command server should invalidate caches.
Otherwise, mq status would go wrong.
2014-03-03 19:41:26 +09:00
Lucas Moscovicz
e0f8aa1f35 hgext: updated extensions to return a baseset when adding symbols 2014-02-11 09:00:38 -08:00
Matt Mackall
a08d7350cb mq: fix qimport url check 2014-02-09 17:30:49 -06:00
Matt Mackall
5f4b3d5487 qimport: allow importing URLs 2014-02-07 17:54:10 -06:00
Kevin Bullock
938beaeee7 mq: prefer a loop to a double-for list comprehension
The [x for y in l for x in y] syntax is nigh-incomprehensible, and this
is a particularly easy case to expand into a loop since there's no 'if'
condition in the list comprehension.
2013-11-24 17:29:10 -06:00
Mads Kiilerich
429aab87ea mq: don't add '* * *' separators when there is no commit message 2013-11-16 15:46:28 -05:00
Simon Heimberg
25ae76fc48 documentation: add an extra newline after note directive
Like this no docutils version interprets any line in the following text as
argument of note.
2013-11-05 08:59:55 +01:00
Mads Kiilerich
eabc047878 spelling: random spell checker fixes 2013-10-24 01:49:56 +08:00
Brodie Rao
e5bfb7187d mq: refactor usage of repo.branchmap().iteritems() with itervalues() 2013-04-01 20:01:16 -07:00
David Soria Parra
e6d74860f3 shelve: allow shelving of a change with an mq patch applied
We allow shelving of of changes on top of a MQ repository. MQ will
not allow repository changes on top of applied patches. We introduce
checkapplied in MQ to bypass this check.
2013-08-29 09:22:15 -07:00
Pierre-Yves David
9a065a615c mq: extract strip function as its standalone extension (issue3824)
Strip now lives in its own extension

reminder: The extension is surprisingly called `strip`.  The `mq` extension
force the use of the strip extension when its enabled. This is both necessary
for backward compatibility (people expect `mq` to comes with strip) and become
some utility function used by `mq` are now in the strip extension.
2013-09-26 23:57:21 +02:00
Pierre-Yves David
7d361f0e67 strip: move the strip helper function for mq to strip
The next patch finally move the command. No joke! (hey, this is for issue3824)
2013-09-26 23:43:00 +02:00
Pierre-Yves David
c041cca5aa strip: move checklocalchanges from mq to strip
One more step for issue3824.
2013-09-26 23:32:52 +02:00
Pierre-Yves David
c91342584d strip: move checksubstate from mq to strip
One more step for issue3824
2013-09-26 23:12:43 +02:00
Pierre-Yves David
7cc217e108 mq: prepare a strip extension for extraction
Strip will lives in its own extension. The extension is surprisingly called
`strip`. (as discussed in issue3824) The `mq` extension force the use of the
strip extension when its enabled. This will both necessary for backward
compatibility (people expect `mq` to comes with strip) and become some utility
function used by `mq` will move in the strip extension.
2013-09-26 23:10:11 +02:00
Pierre-Yves David
775803a1d5 mq: have the strip command functionnal on repo without mq
This is the last step before being able to extract `strip` in its own extension.
The changes are made in mq to allow a move only extraction without touching a
line of code.
2013-09-25 14:16:51 +02:00
Pierre-Yves David
a85f87aed5 mq: extract mq.queue.strip
It does not depend on `mq.queue` anymore.
2013-09-25 14:07:37 +02:00
Pierre-Yves David
b35e49d479 mq: drop the use of mq.queue.qparent in mq.queue.strip
Same as in the previous changeset, rev is never `None`. We can just copy the two
relevant lines in in `queue.strip`. This help having `queue.strip` independent
from `queue`. One further step toward the extraction of `strip` in an independent
extension. (As discussed in issue3824).
2013-09-25 13:41:43 +02:00
Pierre-Yves David
e78203d763 mq: drop the use of mq.queue.qparent in mq.strip
In this case, rev is never `None`. We can just copy the two relevant lines in
in `strip`. This help having `strip` independent from `queue` one
further step toward its extraction in an independent extension. (As
discussed in issue3824).
2013-09-25 14:10:34 +02:00
Pierre-Yves David
cdfc54ba34 mq: document repo.mq.qparents
The function is not very complex but writing this doc helped me to check if
I got everything right.
2013-09-25 19:34:45 +02:00
Pierre-Yves David
63702d52a8 mq: use the new checklocalchange in the strip command
The strip command never use the `refresh` argument. So we can use the function
we just extracted.
2013-09-25 19:32:53 +02:00
Pierre-Yves David
c66ccb3bbf mq: extract checklocalchanges from mq.queue
The core part of `checklocalchanges` is now mq independent. We can extract it in
a standalone function to help the extraction of `strip` as discussed in issue3824.

A `checklocalchanges` function stay in `mq.queue` with the part related to
"refresh first" messages.
2013-09-25 12:43:14 +02:00
Pierre-Yves David
b30305598b mq: extract checksubstate from the queue class
This function does not need any of the the `mq.queue` method or attributes. It
is indirectly used by the `strip` command. We are trying to extract this command
in a standalone extension as discussed in issue issue3824.
2013-09-25 11:24:43 +02:00
Pierre-Yves David
0f912df18c mq: simplifies the refresh hint in checklocalchanges
The `checklocalchanges` function in the `mq.queue` class takes a `refresh` argument that
changes the error message of raised exception. When refresh is
`True` the exception message is "local changes found, refresh first" otherwise,
the message is just "local changes found".

This changeset is the first of a series that extract `strip` into a standalone
extension (as discussed in issue3824). This `checklocalchanges` function is
indirectly used by the strip command. But in a standalone strip extension the
concept of "refresh first" has no sense. In practice, When used in the context
of the strip commands `refresh`'s value is always `False`.

So my final goal is a be able to extract the `checklocalchanges` logic in a
standalone extension but to keep the part related to "refresh first" in the mq
extension. However the refresh handling is deeply entangled into the
`checklocalchanges` code. It is handled as low a possible at the point we raise
the exception.

So we moves handling of refresh upper in the `checklocalchanges` code. This will
allow the extraction of a simple version in the strip extension while mq can
still inject its logic when needed.

Two helper functions `localchangesfound` and `localchangedsubreposfound` died in
the process they are replaced by simple raise lines.
2013-09-25 12:28:40 +02:00
Matt Mackall
ef33fd3506 merge with stable 2013-09-20 11:47:03 -05:00
Sean Farley
6064a14daf strip: set current bookmark to None if stripped 2013-09-07 15:07:10 -05:00
Brodie Rao
cb4c4b7e31 mq: remove unused repo._committingpatch-related code
This was introduced in f59671804f58 but its usage was removed in
ffd6ded23224.
2013-09-16 01:08:29 -07:00
Augie Fackler
a3022f6834 mq: rename next() to nextpatch() to avoid confusing a future check-code patch
next() is a builtin starting in 2.6, so it's also nice to avoid
shadowing the builtin.
2013-07-25 10:42:36 -04:00
Angel Ezquerra
98ae79f962 mq: update subrepos when applying / unapplying patches that change .hgsubstate
Up until now applying or unapplying a patch that modified .hgsubstate would not
work as expected because it would not update the subrepos according to the
.hgsubstate change. This made it very easy to lose subrepo changes when using
mq.

This revision also changes the test-mq-subrepo test so that on the qpop / qpush
tests. We no longer use the debugsub command to check the state of the subrepos
after the qpop and qpush operations. Instead we directly run the id command on
the subrepos that we want to check. The reason is that using the debugsub
command is misleading because it does not really check the state of the subrepos
on the working directory (it just returns what the change that is specified on a
given revision). Because of this the tests did not detect the problem that this
revision fixes (i.e. that applying a patch did not update the subrepos to the
corresponding revisions).


# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1376350710 -7200
#      Tue Aug 13 01:38:30 2013 +0200
# Node ID 60897e264858cdcd46f89e27a702086f08adca02
# Parent  2defb5453f223c3027eb2f7788fbddd52bbb3352
mq: update subrepos when applying / unapplying patches that change .hgsubstate

Up until now applying or unapplying a patch that modified .hgsubstate would not
work as expected because it would not update the subrepos according to the
.hgsubstate change. This made it very easy to lose subrepo changes when using
mq.

This revision also changes the test-mq-subrepo test so that on the qpop / qpush
tests. We no longer use the debugsub command to check the state of the subrepos
after the qpop and qpush operations. Instead we directly run the id command on
the subrepos that we want to check. The reason is that using the debugsub
command is misleading because it does not really check the state of the subrepos
on the working directory (it just returns what the change that is specified on a
given revision). Because of this the tests did not detect the problem that this
revision fixes (i.e. that applying a patch did not update the subrepos to the
corresponding revisions).
2013-08-13 01:38:30 +02:00
Angel Ezquerra
d278e5fc26 mq: look for modified subrepos when checking for local changes
It was possible to apply, unapply, fold, patches (etc) with modified subrepos,
which resulted in surprising behavior. For example it was easy to apply a patch
with a modified subrepo, and then the refresh it and accidentally end up
including the modified subrepo on the refreshed patch.

A test has been added to verify this new check.


# HG changeset patch
# User Angel Ezquerra <angel.ezquerra@gmail.com>
# Date 1375742979 -7200
#      Tue Aug 06 00:49:39 2013 +0200
# Node ID a5c90acff5e61aae714ba6c9457d766c54b4f124
# Parent  bacc55ce64d5de9d1eb7fcefccd3829161d5dcf7
mq: look for modified subrepos when checking for local changes

It was possible to apply, unapply, fold, patches (etc) with modified subrepos,
which resulted in surprising behavior. For example it was easy to apply a patch
with a modified subrepo, and then the refresh it and accidentally end up
including the modified subrepo on the refreshed patch.

A test has been added to verify this new check.
2013-08-06 00:49:39 +02:00
Matt Mackall
99270e3bb3 mq: add checkunfinished support (issue3955) 2013-07-25 00:00:47 -05:00
Matt Mackall
8954b4fab8 mq: remove reference to tip 2013-07-11 19:25:44 -05:00
Pierre-Yves David
3defa86817 mq: use an unfiltered property cache for the queue object
The same `queue` object should be used in all situations. This allows to store
global states on the object (like the reworked shelve extension plans to).  The
queue object does not need to be distinct for all possible views (no reference
to the repo/view used at creation time) it's even a bit surprising that mq still
works with the current code.
2013-07-14 17:23:07 +02:00