Commit Graph

586 Commits

Author SHA1 Message Date
Pierre-Yves David
a6bc441291 revert: detect unknown files in the same path as files marked as removed
Such unknown files may need to be backed up. Having them identified beforehand
will help simplify the backup logic.

We now use different sets with different backup strategies.
2014-08-30 02:00:20 +02:00
Pierre-Yves David
f77e0eb240 revert: cache working context in a variable
During the silicon age, humans on planet Earth discovered the use of
variables. This marvelous invention let them improve both code
readability and performance.
2014-08-30 01:52:08 +02:00
Martin von Zweigbergk
e95a8f8fb9 cmdutil: avoid the confusing name 'patch' for a matcher 2014-08-31 07:45:50 -07:00
Pierre-Yves David
884e556964 revert: drop now useless conditional in the backup check
Now that we removed the (hopeless) attempt to backup file we knew to be
missing in the target changeset, we can stop checking if the file exists in
the target changeset.
2014-08-30 01:51:02 +02:00
Pierre-Yves David
d51e1ac08b revert: no backup for dsadded set
There is only one case where a backup is required in the `dsadded` set, and the
current backup mechanism fails to handle it. So we stop trying to do backups at
all for now. This will help us to simplify the backup code and finally fix
this backup issue.
2014-08-30 01:49:28 +02:00
Pierre-Yves David
5fca88c509 revert: add more padding in the dispatch list
We are going to add more sets and some of them will have longer names. We add
padding in a standalone patch for readbility purposes.
2014-08-30 16:06:09 +02:00
Pierre-Yves David
b34b8413be revert: add documentation in the dispatch table
More sets are coming so documenting the existing ones will help.
2014-08-30 01:48:58 +02:00
Pierre-Yves David
2554c150e4 revert: add a way for external extensions to prefetch file data
This allow extensions that mess with the storage layer (remotefilelog,
largefile) to prefetch any data that will be accessed during the revert
operation.

We are currently fetching more data than theoretically required because the
backup code is a bit stupid. Future patches will improve that.
2014-08-30 02:47:59 +02:00
Matt Mackall
3ce3f9064f merge with stable 2014-08-27 18:35:34 +02:00
FUJIWARA Katsunori
5c74f6bc14 import: show the warning message for failure of merging
Before this patch, no message is shown for failure of merging at "hg
import".

In such case, merging patch is imported as a normal revision silently,
and it may confuse users.

For simplicity, this patch recommends just using "--exact", even
though importing the merging patch itself is possible without it if:

  - the hash of the 1st parent in the patch is equal to one of the
    patch imported just before (or the parent of the working
    directory, for the 1st patch of the series), and

  - the hash of the 2nd parent in the patch is known in the local
    repository
2014-08-27 23:10:06 +09:00
Sean Farley
a5ff857520 log: use correct phase info for parent field (issue4347)
Previously, there was a copy / paste error with using the current changeset's
phase information. We now look up the parent context explicitly.

The line was too long so it is stored into a variable first.
2014-08-23 17:03:08 -05: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
FUJIWARA Katsunori
baa5c6430a import: avoid editor invocation when importing with "--exact" for exact-ness
Before this patch, external editor is invoked when imported patch has
no commit message, even if "--exact" is specified. Then, exact-ness is
broken, because empty commit message causes failure of committing.

This patch avoids editor invocation at importing with "--exact" for
exact-ness, because commit message in the patch should be kept as it
is in such case, even if it is empty.
2014-08-23 23:03:50 +09:00
Siddharth Agarwal
f07a4ceb07 cmdutil: add a hook for making custom non-follow log file matchers
This will be used by largefiles (and basically only by largefiles) in an
upcoming patch.
2014-08-13 15:17:03 -07:00
Siddharth Agarwal
b112932fc1 cmdutil: rename _makelogfilematcher to _makefollowlogfilematcher
We're going to add a _makenofollowlogfilematcher in an upcoming patch.
2014-08-13 15:15:13 -07:00
Yuya Nishihara
4d834f9237 log: do not use exact matcher for --patch --follow without file (issue4319)
5d9f39626224 is valid only if file argument is specified.  If no pattern
specified, it can simply fall back to the original matcher.
2014-08-01 21:36:56 +09:00
Matt Mackall
f648f507dd templates: re-add template listing support
We used to have --style nosuch to list templates, but --style is now
merged with --template/-T where random strings are acceptable
templates. So we reserve 'list' to allow listing templates.
2014-07-25 15:35:09 -05:00
FUJIWARA Katsunori
f9743bb802 cmdutil: make commit message shown in text editor customizable by template
This patch makes commit message shown in text editor customizable by
template. For example, this can advertise:

  - sample commit messages for routine works,
  - points to call attention before commit,
  - message of the day, and so on

To show commit message correctly even in problematic encoding, this
patch chooses the latter below:

  - replace "buildcommittext" with "buildcommittemplate" completely

  - invoke "buildcommittemplate" only if '[committemplate] changeset'
    is configured explicitly

For example, if multibyte character ending with backslash (0x5c) is
followed by ASCII character 'n' in the customized template, sequence
of backslash and 'n' is treated as line-feed unexpectedly (and
multibyte character is broken, too).

This corruption occurs in 'decode("string-escape")' while parsing
template string.
2014-07-15 23:34:13 +09:00
Matt Mackall
b221e35cf4 commiteditor: refactor default extramsg 2014-07-18 23:15:28 -05:00
Pierre-Yves David
1119f2b21b debugobsolete: display parents information from markers
Now that we have a new field, we need a way to visualize it.
2014-08-18 17:17:23 -07:00
FUJIWARA Katsunori
6ff720dff7 import: change "editform" to distinguish merge commits from others
"editform" argument for "getcommiteditor" is decided according to the
format below:

  COMMAND[.ROUTE]

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

This patch uses "normal.normal" and "normal.merge" as ROUTE of
"editform" instead of "normal", to distinguish merge commits from
other in "hg import" without "--bypass" case.

This patch assumes "editform" variations for "hg import" below:

    import.normal.normal
    import.normal.merge
    import.bypass.normal
    import.bypass.merge

Unlike other patches in this series, this patch uses "editor.sh"
instead of "checkeditform.sh" for the name of the script to check
"HGEDITFORM", because it has to do more than checking "HGEDITFORM".

To invoke editor forcibly in "test-import-merge.t", this patch creates
the patch not having patch description as "merge.nomsg.diff".
2014-08-16 10:43:59 +09:00
FUJIWARA Katsunori
1d0310bb6c commit: change "editform" to distinguish merge commits from other (--amend)
"editform" argument for "getcommiteditor" is decided according to the
format below:

  COMMAND[.ROUTE]

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

This patch uses "amend.normal" and "amend.merge" as ROUTE of
"editform" instead of "amend", to distinguish merge commits from other
in "hg commit --amend" case.
2014-08-16 10:43:59 +09:00
FUJIWARA Katsunori
df8f4a6663 commit: change "editform" to distinguish merge commits from others
"editform" argument for "getcommiteditor" is decided according to the
format below:

  COMMAND[.ROUTE]

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

This patch uses "normal.normal" and "normal.merge" as ROUTE of
"editform" instead of "normal", to distinguish merge commits from
others in "hg commit" without "--amend" case.

This patch assumes "editform" variations for "hg commit" below:

    commit.normal.normal
    commit.normal.merge
    commit.amend.normal
    commit.amend.merge

"mergeeditform" is factored out for subsequent patches. It takes
"ctxorbool" argument, because context object can't be passed in some
cases.
2014-08-16 10:43:59 +09:00
Pierre-Yves David
6fc35a917d revert: drop dead code for untracked files
Untracked files are handled through status now.
2014-06-25 00:02:17 +01:00
Pierre-Yves David
6f03c922f1 revert: handle unknown files through status
This will allow us to drop the code dedicated to this special case.
2014-06-25 00:01:30 +01:00
Pierre-Yves David
aee89be787 revert: drop more dead code
Now that we detect all clean files, we do not need this clause anymore.
2014-06-24 23:55:43 +01:00
Pierre-Yves David
f409864957 revert: add a message to noop action
This prepares for the arrival of a second "not touching file" action:
revert of an untracked file.
2014-08-02 13:07:01 -07:00
Pierre-Yves David
5dc6cf75e9 revert: simplify loop conditional
The two breaks can be joined into one. The code gains one level of indent.
2014-08-01 11:41:56 -07:00
Pierre-Yves David
84467bf1a9 revert: explode the action tuple in the for loop
noop is about to gain a message.
2014-06-24 18:04:13 +01:00
Pierre-Yves David
110f9a614a revert: use actions[...] in all disptable cases
1. Special cases are not special enough

2. There are two cases where nothing is done and a message is displayed. This
   prepares it.
2014-08-02 12:45:34 -07:00
Pierre-Yves David
5b69082d6e revset: factorize backup decision
The conditional controlling the creation of backup is fairly big. We move config
related decisions outside of the loop.
2014-06-24 17:54:33 +01:00
Pierre-Yves David
8af395dddd revert: use a flat dispatch table
Now that the table is simpler, remove one level of depth from it. This
simplifies its usage in the for loop.
2014-06-24 17:44:31 +01:00
Pierre-Yves David
a3e6a74916 debugobsolete: explicitly display date in the output
As the date is becoming a first-class citizen, we are displaying it in an
explicit field. As a bonus it is now readable by humans.
2014-08-13 23:42:36 -07:00
Pierre-Yves David
b1789db911 obsmarker: add a flags method
We introduce a proper method to access the flag information.
2014-08-15 09:41:30 -07:00
Pierre-Yves David
fbb01f1dde revert: add an XXX about rename tracking
We check for rename information in the dirstate. This is probably not enough to
preserve this behavior when using an explicit target rev.

I just spotted this while working on this code, but this is outside the scope
of my series so I'm just adding a comment to highlight this suspicious
situation.
2014-06-24 16:59:40 +01:00
Pierre-Yves David
429f2742a7 revert: inline a now useless closure
Now that a single call site remains, we can just inline its content.
2014-06-24 17:39:43 +01:00
Pierre-Yves David
6088f7f0d0 revert: remove code killed by the double status
All those checks were here to catch cases where files were not modified in
dirstate but were different in the target revision. This is now properly handled
by calling status on the target node too.
2014-06-24 17:37:24 +01:00
Pierre-Yves David
c1c198f25f revert: drop missingmodified set
There cannot be any elements in this set since:

    dsmodified &= modified
2014-06-24 17:36:49 +01:00
Pierre-Yves David
032cc9974f revert: detect files added during a merge
In case of merge, file that are actually added can be reported as modified. This
is currently handled by special-case code. We detect it beforehand instead. This
will lets use remove the special-case code at some point in the future.
2014-06-24 17:28:20 +01:00
Pierre-Yves David
9f80242186 revert: simplify handling of added files
There are multiple possible cases for added files. But it's all handled by magic
much lower in the stack. We document them, simplify the codes and move on.
2014-08-02 11:32:24 -07:00
FUJIWARA Katsunori
e8856bc78d ui: invoke editor for committing with HGEDITFORM environment variable
At the external editor invocation for committing, the value specified
as "editform" for "cmdutil.getcommiteditor" is in "HGEDITFORM".

This enables external editor to do own customization according to
commit types.
2014-08-15 23:05:53 +09:00
Pierre-Yves David
ff3290bfea revert: use modified information from both statuses
Using status information against the target ensures we are catching all
files with modifications that need reverting.

We still need to distinguish fresh modifications for backup purpose.

test-largefile is affected because it reverted a file that needs no content
change.
2014-06-24 17:27:18 +01:00
Pierre-Yves David
56e34a196a revert: drop special case handling for file unknown in parent
We had a special case for file not caught by any categories. It was
aimed at files missing in wc and wc's parent but existing in the target
revision. This is now properly handled using status information.
2014-06-24 16:57:16 +01:00
Pierre-Yves David
911e895e66 revert: use "remove" information from both statuses
Using status information against the target to make sure we are catching all
files that need to be re-added.

We still need to distinguish fresh removal because they use a different
message.
2014-06-24 16:53:22 +01:00
Pierre-Yves David
2cc3d88c5b revert: process removed files missing in target as clean
If a file does not exist in target and is marked as removed in the dirstate, we
can mark it as clean. There are no changes needed to revert it.
2014-08-01 18:27:47 -07:00
Pierre-Yves David
708550e527 revert: also track clean files
Tracking clean files is the simplest way to be able to reports files that need
no changes. So we explicitly retrieve them.

This fixes a couple of test outputs where the lack of changes was not reported.
2014-07-31 15:52:56 -07:00
Pierre-Yves David
df2c9033ac revert: triage "deleted" files into more appropriate categories
Status can return file as "deleted". This is only a special case
related to working directory state: file is recorded as tracked but no
file exists on disk. This will never be a state obtainable from
manifest comparisons.

"Deleted" files have another working directory status shadowed by the lack of
file. They will -alway- be touched by revert. The "lack of file" can be seen as
a modification. The file will never match the same "content" as in the revert
target. From there we have two options:

1. The file exists in the target and can be seen as "modified".
2. The file does not exist in the target and can be seen as "added".

So now we just dispatch elements from delete into appropriate categories.
2014-08-01 18:57:53 -07:00
Matt Mackall
57de8037d2 merge with stable 2014-08-14 16:25:47 -05:00
Pierre-Yves David
5b7e70a4d0 revert: issue "no changes needed" message for files missing on both side
When a file was marked as removed in the working copy and did not existed in the
target of the revert, we did not issued any message pointing that no change was
needed to the file (implicitly saying that revert had changed the file).

We now properly issue a message in this situation. Tests change in and handful
of case where the message was documented as missing.
2014-07-31 16:03:26 -07:00
Pierre-Yves David
b18e801dd3 revert: call status against revert target too
We now call status against the target (and possibly against the working
directory parent is different). We do not use the information from the two
sources yet, but this is coming soon.

We need the status information aganst the dirstate in all case because we need
to be able to backup local modification.
2014-06-24 15:47:12 +01:00