Commit Graph

22025 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
8c6b77e441 largefiles: use "normallookup" on "lfdirstate" while reverting
Before this patch, largefiles gotten from revisions other than the
parent of the working directory at "hg revert" become "clean"
unexpectedly in steps below:

    1. "repo.status()" is invoked (for status check before reverting)
      1-1 "dirstate" entry for standinfile SF is "normal"-ed
     (1-2 "lfdirstate" entry of largefile LF (for SF) is "normal"-ed)

    2. "cmdutil.revert()" is invoked
      2-1 standinfile SF is updated in the working directory
      2-2 "dirstate" entry for SF is NOT updated

    3. "lfcommands.updatelfiles()" is invoked (by "overrides.overriderevert()")
      3-1 largefile LF (for SF) is updated in the working directory
      3-2 "dirstate" returns "n" and valid timestamp for SF (by 1-1 and 2-2)
      3-3 "lfdirstate" entry for LF is "normal"-ed
      3-4 "lfdirstate" is written into ".hg/largefiles/dirstate", and
          timestamp of LF is stored into "lfdirstate" file (by 3-3)
          (ASSUMPTION: timestamp of LF differs from one of "lfdirstate" file)

Then, "hs status" treats LF as "clean", even though LF is updated by
"other" revision (by 3-1), because "lfilesrepo.status()" always treats
"normal"-ed files (by 3-3 and 3-4) as "clean".

When largefiles are reverted, they should be "normallookup"-ed
forcibly.

This patch uses "normallookup" on "lfdirstate" while reverting, by
passing "True" to newly added argument "normallookup".

Forcible "normallookup"-ing is not so expensive, because list of
target largefiles is explicitly specified in this case.

This patch uses "[debug] dirstate.delaywrite" feature in the test, to
ensure that timestamp of the largefile gotten from "other" revision is
stored into ".hg/largefiles/dirstate" (for ASSUMPTION at 3-4)
2014-07-23 00:10:24 +09:00
FUJIWARA Katsunori
f5a07da3f0 largefiles: invoke "normallookup" on "lfdirstate" for merged files
Before this patch, largefiles gotten from "other" revision (with
conflict) at "hg merge" become "clean" unexpectedly in steps below:

    1. "repo.status()" is invoked (for status check before merging)
      1-1 "dirstate" entry for standinfile SF is "normal"-ed
      1-2 "lfdirstate" entry of largefile LF (for SF) is "normal"-ed

    2. "merge.update()" is invoked
      2-1 SF is updated in the working directory
          (ASSUMPTION: user choice "other" at conflict)
      2-2 "dirstate" entry for SF is "merge"-ed

    3. "lfcommands.updatelfiles()" is invoked (by "overrides.hgmerge()")
      3-1 largefile LF (for SF) is updated in the working directory
      3-2 "dirstate" returns "m" for SF (by 2-2)
      3-3 "lfdirstate" entry for LF is left as it is
      3-4 "lfdirstate" is written into ".hg/largefiles/dirstate", and
          timestamp of LF is stored into "lfdirstate" file (by 1-2)
          (ASSUMPTION: timestamp of LF differs from one of "lfdirstate" file)

Then, "hs status" treats LF as "clean", even though LF is updated by
"other" revision (by 3-1), because "lfilesrepo.status()" always treats
"normal"-ed files (by 1-2 and 3-4) as "clean".

When state of standinfile in "dirstate" is "m", largefile should be
"normallookup"-ed.

This patch invokes "normallookup" on "lfdirstate" for merged files.

This patch uses "[debug] dirstate.delaywrite" feature in the test, to
ensure that timestamp of the largefile gotten from "other" revision is
stored into ".hg/largefiles/dirstate". (for ASSUMPTION at 3-4)
2014-07-23 00:10:24 +09:00
FUJIWARA Katsunori
c24b717f3e largefiles: use "normallookup", if "mtime" of standin is unset
Before this patch, largefiles gotten from "other" revision (without
conflict) at "hg merge" become "clean" unexpectedly in steps below:

    1. "merge.update()" is invoked
      1-1 standinfile SF is updated in the working directory
      1-2 "dirstate" entry for SF is "normallookup"-ed

    2. "lfcommands.updatelfiles()" is invoked (by "overrides.hgmerge()")
      2-1 largefile LF (for SF) is updated in the working directory
      2-2 "dirstate" returns "n" for SF (by 1-2)
      2-3 "lfdirstate" entry for LF is "normal"-ed
      2-4 "lfdirstate" is written into ".hg/largefiles/dirstate", and
          timestamp of LF is stored into "lfdirstate" file
          (ASSUMPTION: timestamp of LF differs from one of "lfdirstate" file)

Then, "hs status" treats LF as "clean", even though LF is updated by
"other" revision (by 2-1), because "lfilesrepo.status()" always treats
"normal"-ed files (by 2-3 and 2-4) as "clean".

When timestamp is not set (= negative value) for standinfile in
"dirstate", largefile should be "normallookup"-ed regardless of
rebasing or not, because "n" state in "dirstate" doesn't ensure
"clean"-ness of a standinfile at that time.

This patch uses "normallookup" instead of "normal", if "mtime" of
standin is unset

This is a temporary way to fix with less changes. For fundamental
resolution of this kind of problems in the future, "lfdirstate" should
be updated with "dirstate" simultaneously while "merge.update"
execution: maybe by hooking "recordupdates"

It is also why this patch (temporarily) uses internal field "_map" of
"dirstate" directly.

This patch uses "[debug] dirstate.delaywrite" feature in the test, to
ensure that timestamp of the largefile gotten from "other" revision is
stored into ".hg/largefiles/dirstate". (for ASSUMPTION at 2-4)

This patch newly adds "test-largefiles-update.t", to avoid increasing
cost to run other tests for largefiles by subsequent patches
(especially, "[debug] dirstate.delaywrite" causes so).
2014-07-22 23:59:34 +09:00
FUJIWARA Katsunori
2fdcc0328a dirstate: delay writing out to ensure timestamp of each entries explicitly
Even though "dirstate.write()" is invoked explicitly after "normal"
invocations, timestamp field of entries may be still "unset" in the
"dirstate" file itself , because "pack_dirstate" drops it when it is
equal to the timestamp of "dirstate" file itself.

This can avoid overlooking modification of files, which are updated at
same time in the second. But on the other hand, this may hide timing
critical problems.

For example, incorrect "normal"-ing (or lack of "normallookup"-ing on
the already "normal"-ed entry) is visible only when:

  - the target file is modified in the working directory at T1, and
  - "dirstate" file is written out at T2 (!= T1)

Otherwise, T1 is dropped by "pack_dirstate" in "dirstate.write()"
invocation, and "unset" is stored into "dirstate" file.

It often fails to reproduce problems from incorrect "normal"-ing by
Mercurial testset, because automated actions in the small repository
almost always causes that T1 and T2 are same.

This patch adds the debug feature to delay writing out to ensure
timestamp of each entries explicitly.

This feature is used to make timing critical "dirstate" problems
reproducable in subsequent patches.
2014-07-22 23:59:30 +09:00
Danek Duvall
151b68d8da tests: cat error messages are different on Solaris 2014-07-21 11:27:24 -07:00
Wagner Bruna
d98e4eed2d i18n-pt_BR: synchronized with 4bd0f3b99c93 2014-07-20 18:08:29 -03:00
Wagner Bruna
00765540ed commands: fix typo in import documentation 2014-07-20 15:06:12 -03:00
Matt Mackall
7c1189ac2d Added signature for changeset 4bd0f3b99c93 2014-07-19 00:11:40 -05:00
Matt Harbison
f0308c64dd revset: avoid a ValueError when 'only()' is given an empty set
This previously died in _revdescendants() taking the min() of the first set to
only(), when it was empty.  An empty second set already worked.  Likewise,
descendants() already handled an empty set.
2014-07-18 19:46:56 -04: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
Angel Ezquerra
38433239a4 filemerge: add internal:tagmerge merge tool
Add a new internal:tagmerge merge tool which implements an automatic merge
algorithm for mercurial's tag files

The tagmerge algorithm is able to resolve most merge conflicts that
currently would trigger a .hgtags merge conflict. The only case that
it does not (and cannot) handle is that in which two tags point to
different revisions on each merge parent _and_ their corresponding tag
histories have the same rank (i.e. the same length). In all other
cases the merge algorithm will choose the revision belonging to the
parent with the highest ranked tag history. The merged tag history is
the combination of both tag histories (special care is taken to try to
combine common tag histories where possible).

The algorithm also handles cases in which tags have been manually
removed from the .hgtags file and other similar corner cases.

In addition to actually merging the tags from two parents, taking into
account the base, the algorithm also tries to minimize the difference
between the merged tag file and the first parent's tag file (i.e. it
tries to make the merged tag order as as similar as possible to the
first parent's tag file order).

The algorithm works as follows:
1. read the tags from p1, p2 and the base
    - when reading the p1 tags, also get the line numbers associated to each
      tag node (these will be used to sort the merged tags in a way that
      minimizes the diff to p1). Ignore the file numbers when reading p2 and
      the base
2. recover the "lost tags" (i.e. those that are found in the base but not on p1
   or p2) and add them back to p1 and/or p2
    - at this point the only tags that are on p1 but not on p2 are those new
      tags that were introduced in p1. Same thing for the tags that are on p2
      but not on p2
3. take all tags that are only on p1 or only on p2 (but not on the base)
    - Note that these are the tags that were introduced between base and p1 and
      between base and p2, possibly on separate clones
4. for each tag found both on p1 and p2 perform the following merge algorithm:
    - the tags conflict if their tag "histories" have the same "rank" (i.e.
      length) _AND_ the last (current) tag is _NOT_ the same
    - for non conflicting tags:
        - choose which are the high and the low ranking nodes
            - the high ranking list of nodes is the one that is longer.
              In case of draw favor p1
            - the merged node list is made of 3 parts:
                - first the nodes that are common to the beginning of both the
                  low and the high ranking nodes
                - second the non common low ranking nodes
                - finally the non common high ranking nodes (with the last one
                  being the merged tag node)
            - note that this is equivalent to putting the whole low ranking node
              list first, followed by the non common high ranking nodes
    - note that during the merge we keep the "node line numbers", which will
      be used when writing the merged tags to the tag file
5. write the merged tags taking into account to their positions in the first
   parent (i.e. try to keep the relative ordering of the nodes that come
   from p1). This minimizes the diff between the merged and the p1 tag files
   This is done by using the following algorithm
    - group the nodes for a given tag that must be written next to each other
        - A: nodes that come from consecutive lines on p1
        - B: nodes that come from p2 (i.e. whose associated line number is None)
             and are next to one of the a nodes in A
        - each group is associated with a line number coming from p1
    - generate a "tag block" for each of the groups
        - a tag block is a set of consecutive "node tag" lines belonging to the
          same tag and which will be written next to each other on the merged
          tags file
    - sort the "tag blocks" according to their associated number line
        - put blocks whose nodes come all from p2 first
    - write the tag blocks in the sorted order

Notes:
- A few tests have been added to test-tag.t. These tests are very specific to
the new internal:tagmerge tool, so perhaps they should be moved to their own
test file.
- The merge algorithm was discussed in a thread on the mercurial mailing list.
In http://markmail.org/message/anqaxldup4tmgyrx a slightly different algorithm
was suggested. In it the p1 and p2 tags would have been interleaved instead of
put one before the other. It would be possible to implement that but my tests
suggest that the merge result would be more confusing and harder to understand.
2014-06-26 01:20:25 +02:00
Matt Mackall
dcb326f0e5 filemerge: use non-minimal conflict marker regions (BC)
As extensively detailed by Pierre-Yves[1], simplemerge's minimal
markers can result in hopeless confusion for many common merges. As it
happens, we accidentally inherited this behavior when we borrowed
simplemerge from bzr; it is not the behavior used by RCS's merge(1),

Since merge(1) (and not bzr) is what we aim to emulate when emulating
RCS's merge markers, we simply turn this feature off. This brings us
in line with the behavior of CVS, SVN, and Git as a bonus.

(NB: using conflict markers with Mercurial is discouraged.)

[1] http://markmail.org/message/wj5mh3lc46czlvld

convert glob tessa
2014-07-18 21:49:52 -05:00
Pierre-Yves David
9ce4e0fa84 test: use more elaborated content in `test-conflict.t`
We are going to introduce a setting to control the "minimisation" feature of
``internal:merge``. So we need more interesting conflicting content. We change
the content in an independent changeset to make sure the coming code change
leave the output unchanged.
2014-06-09 03:49:07 -07:00
Matt Mackall
0eb76768ec run-tests: make --view work again 2014-07-18 17:52:18 -05:00
FUJIWARA Katsunori
ba5b3b9f46 filemerge: use 'basic' as the default of '[ui] mergemarkers' for safety
Before this patch, 'detailed' is used as the default of '[ui]
mergemarkers'. This embeds non-ASCII characters in tags, branches,
bookmarks, author and/or commit descriptions into merged files in the
encoding specified by '--encoding' global option, 'HGENCODING' or
other locale setting environment variables.

But, if files to be merged use another encoding, this behavior breaks
consistency of encoding in merged files.

For example, ISO-2022-JP or EUC-JP are sometimes used as the file
encoding for Japanese characters, because of historical and/or
environmental reasons, even though UTF-8 or Shift-JIS are ordinarily
used as the terminal encoding.

This can't be resolved automatically, because Mercurial doesn't aware
encoding of managed files.

This patch uses 'basic' as the default of '[ui] mergemarkers' to avoid
embedding encoding sensitive characters for safety.

This patch puts '[ui] mergemarkers = detailed' into default hgrc file
for tests, to reduce changes for tests in this patch.
2014-07-06 02:56:41 +09:00
Matt Harbison
cbf609dee6 largefiles: avoid unnecessary creation of .hg/largefiles when opening lfdirstate
Previously, the directory '.hg/largefiles' would always be created if it didn't
exist when the lfdirstate was opened.  If there were no standin files, no
dirstate file would be created in the directory.  The end result was that
enabling the largefiles extension globally, but not explicitly adding a
largefile would result in the repository eventually sprouting this directory.

Creation of this directory effectively changes readonly operations like summary
and status into operations that require write access.  Without write access,
commands that would succeed without the extension loaded would abort with a
surprising error when the extension is loaded, but not actively used:

  $ hg sum -R /tmp/thg --config extensions.largefiles=
  parent: 16541:00dc703d5aed
   repowidget: specify incoming bundle by plain file path to avoid url parsing
  branch: default
  abort: Permission denied: '/tmp/thg/.hg/largefiles'


This change is simpler than changing the callers of openlfdirstate() to use the
'create' parameter that was introduced in 74522122b97d, and probably how that
should have been implemented in the first place.
2014-07-17 20:17:17 -04:00
Yuya Nishihara
9f46c8b964 alias: keep error message in "badalias" so that help can see it
Upcoming patches will

 - change help_() to get badalias message without executing cmdalias()
 - raise Abort on bad alias
2014-05-17 21:13:31 +09:00
Yuya Nishihara
9068ad3b7f alias: add test for alias command provided by disabled extension
This should complete cases where "badalias" is set.
2014-05-17 20:47:31 +09:00
Siddharth Agarwal
4b5c9f694a alias: expand "$@" as list of parameters quoted individually (BC) (issue4200)
Before this patch, there was no way to pass in all the positional parameters as
separate words down to another command.

(1) $@ (without quotes) would expand to all the parameters separated by a space.
    This would work fine for arguments without spaces, but arguments with spaces
    in them would be split up by POSIX shells into separate words.
(2) '$@' (in single quotes) would expand to all the parameters within a pair of
    single quotes. POSIX shells would then treat the entire list of arguments
    as one word.
(3) "$@" (in double quotes) would expand similarly to (2).

With this patch, we expand "$@" (in double quotes) as all positional
parameters, quoted individually with util.shellquote, and separated by spaces.
Under standard field-splitting conditions, POSIX shells will tokenize each
argument into exactly one word.

This is a backwards-incompatible change, but the old behavior was arguably a
bug: Bourne-derived shells have expanded "$@" as a tokenized list of positional
parameters for a very long time. I could find this behavior specified in IEEE
Std 1003.1-2001, and this probably goes back to much further before that.
2014-08-13 23:21:52 -07:00
Siddharth Agarwal
a15c76a2c8 test-alias: add some tests to ensure we aren't double-substituting
An earlier iteration of an upcoming patch caused inadvertent
double substitution. Ensure we have test coverage for this.
2014-08-13 22:37:09 -07: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
Pierre-Yves David
b263ff2b09 revert: prefix variable names for dirstate status with "ds"
As we are going to introduce status again other revision we needs to distinguish
between data from dirstate status and the other one. We prefix the existing data
with "ds" to highlight this.
2014-06-24 15:35:43 +01:00
Pierre-Yves David
50ccb74146 revert: move manifest membership condition outside of the loop
Currently, revset is using information from dirstate status and alter its
behavior whenever the file exist in the target manifest or not. This tests are
done a big for loop. We move this member ship testing outside of the loop and
simplifies associates data structure.

This is a step toward a cleaner implementation of revert based on status.
2014-06-24 15:28:22 +01: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
David Soria Parra
698eea6e2b repoview: cache hidden changesets
Use the introduced caching infrastructure to cache hidden
changesets. We crosscheck if the content of the cache unless
experimental.verifyhiddencache is set to False. This will be removed
in the future. Without crosschecking the caches speed ups hg status and
other commands:

without caching:
$ time hg status
hg status  0.72s user 0.20s system 100% cpu 0.917 total

with caching
$ time hg status
hg status  0.49s user 0.15s system 100% cpu 0.645 total
2014-08-12 09:39:14 -07:00
David Soria Parra
75f779a75d repoview: add caching bits
Add a caching infrastructure to cache hidden changesets. The cache tries to read
the cache lazily and falls back to recomputing if no wlock can be obtain.
To validate the cache we store a sha of the obstore content and repo heads in
the beginning of the cache which we check every request.
2014-08-12 16:48:54 -07:00
David Soria Parra
c878b027dc repoview: split _gethiddenblockers
Split up _gethiddenblockers into two categories: (1) "static' blockers
that solely rely on the contents of obstore and are visible children of
hidden changsets. (2) "dynamic" blockers, appearing by having wd parents,
bookmarks or tags pointing to hidden changesets.

We assume that (1) doesn't change often and can be easily cached with a good
invalidation strategy. (2) change often, but barely produce blockers, so we
can recompute them if necessary.
2014-08-06 13:26:04 -07:00
David Soria Parra
70d1fce0ac repoview: use set for blockers
Blockers should be unique but tags and bookmarks could point to the same rev,
therefore use a set to ensure that we don't have duplicates.
2014-08-12 16:42:24 -07:00
Matt Mackall
6c5b3c4a4c merge with stable 2014-08-13 15:06:58 -05:00
Pierre-Yves David
c2138bc11f test-revert: add case where file is tracked but deleted in working directory 2014-06-25 17:40:41 +01:00
Pierre-Yves David
8168e29d33 test-revert: add case with untracked files with unique content
This test highlights similar misbehavior as its parent changesets.
2014-06-27 18:25:19 +02:00
Pierre-Yves David
82196ae928 test-revert: add case with untracked files with reverted content
This test highlights similar misbehaviors as its parent changesets.
2014-06-27 18:23:45 +02:00
Pierre-Yves David
d7c162a81f test-revert: add case where file exists but is untracked in working directory
This test highlights a small misbehavior in output when reverting to another
revision not including the untracked file.
2014-06-27 18:10:45 +02:00
Pierre-Yves David
c7b21cc553 test-revert: add case where the file is marked as removed in the wc
Unlike untracked, the file is also missing from the working directory.

This test highlights a small misbehavior in output when reverting to another
revision.
2014-06-27 18:09:46 +02:00
Pierre-Yves David
23f0089dda test-revert: add case where wc content is different from "base" and "parent"
This test highlights a case where backups are not created and the user may
lose data.
2014-06-27 18:08:16 +02:00
Pierre-Yves David
412ed73be5 test-revert: add case where wc content is already reverted to base content
This test highlights multiple misbehaviors of revert. We augment the test
comments accordingly.
2014-06-27 18:07:33 +02:00
Pierre-Yves David
a5684d9c69 test-revert: add case where file exists neither in "base" nor in "parent" 2014-06-27 18:02:09 +02:00
Pierre-Yves David
35119be671 test-revert: add case where the file is removed between "base" and "parent" 2014-06-27 18:01:16 +02:00
Pierre-Yves David
545aab87fe test-revert: add case where file is unchanged between "base" and "parent"
This test highlights a minor misbehavior in the message displayed
during an explicit revert with a target revision.
2014-06-27 18:00:49 +02:00
Pierre-Yves David
beef5d2ab3 test-revert: add case where file is added between "base" and "parent" 2014-06-25 17:37:13 +01:00
Matt Mackall
ee564a47d4 merge with stable 2014-08-12 17:22:57 -05:00
Pierre-Yves David
4ab7864481 test-revert: add methodical revert to "base" with explicit file path
We now also test reverting file to another revision's content. However
this differs from previously introduced test by using the explicit path
of each "case file" when calling revert. This should result in the
same result regarding file content and backup creation, but the output
of the `hg revert` call should differ.
2014-06-25 17:31:53 +01:00
Pierre-Yves David
0665e42a28 test-revert: add methodical revert with explicit file path
We now also test reverting file to the working directory parent
content. However this differs from the previously introduced test by using
the explicit path of each "case file" when calling revert. This should
result in the same result regarding file content and backup creation,
but the output of the `hg revert` call should differ.
2014-06-25 17:22:47 +01:00
Pierre-Yves David
dd045fbbfb test-revert: add methodical revert to "base"
We now also test reverting s file to the content of another revision. This is
still done using the `--all` flag.
2014-06-25 17:16:05 +01:00
Pierre-Yves David
c6c8698534 test-revert: add methodical revert to parent for working directory
Now that we can automatically generate states, we need to actually run
revert on them and check the result. While running such tests we are
checking multiple elements. The output of the `hg revert` command, the
resulting content of file, and the creation of backup file.

The first practical test is using the simple case `hg revert --all`, reverting
all files to working directory parent content.
2014-06-25 17:03:55 +01:00
Pierre-Yves David
364e062c1b test-revert: display the list of all generated cases
This will help to track all existing cases.

(still very simple now)
2014-06-25 17:24:18 +01:00
Pierre-Yves David
fa7f47cb83 test-revert: also create a text version of the snapshot
The text version is just a list of existing files with their content. We use a
small custom script for that.

This is going to be very useful for comparing revert results with
revert target content.
2014-06-27 16:08:09 +02:00
Matt Mackall
65aa1f6760 hg-test-mode: make exit code highlight work again 2014-08-12 12:53:23 -05:00