Commit Graph

8455 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
e9656a280f rebase: use dirstateguard instead of dirstate.invalidate
Before this patch, "rebase.concludenode()" uses "dirstate.invalidate()"
as a kind of "restore .hg/dirstate to the original status" during a failure.

But it just discards changes in memory, and doesn't actually restore
".hg/dirstate". Then, it can't work as expected, if "dirstate.write()"
is executed while processing.

This patch uses "dirstateguard" instead of "dirstate.invalidate()" to
restore ".hg/dirstate" during a failure even if "dirstate.write()" is
executed before a failure.

This patch also removes "beginparentchage()" and "endparentchange()",
because "dirstateguard" makes them useless.

This is a part of preparations to fix the issue that the recent (in
memory) dirstate isn't visible to external processes (e.g. "precommit"
hook).

After this patch, the changed dirstate becomes visible to external
"precommit" hooks during "hg rebase" in "test-largefiles-misc.t",
because "dirstateguard()" writes it out. But this content isn't yet
correct, because:

  - "normal3" should be marked as "A"(dded) at committing

    It is newly added in the changeset being rebased.

  - but it is marked as "M"(odified)

    The result of "repo.setparents()" after "dirstateguard()" isn't
    yet written out before "precommit". So, merging is still in
    progress for "hg status" in it.

    This causes marking the file newly added on "other" branch as "A".

This will be fixed by subsequent patch.
2015-05-07 12:07:11 +09:00
FUJIWARA Katsunori
10baf11523 localrepo: use changelog.hasnode instead of self.__contains__
Before this patch, releasing the store lock implies the actions below, when
the transaction is aborted:

  1. "commithook()" scheduled in "localrepository.commit()" is invoked
  2. "changectx.__init__()" is invoked via "self.__contains__()"
  3. specified ID is examined against "repo.dirstate.p1()"
  4. validation function is invoked in "dirstate.p1()"

In subsequent patches, "dirstate.invalidate()" invocations for
discarding changes are replaced with "dirstateguard", but discarding
changes by "dirstateguard" is executed after releasing the store lock:
resources are acquired in "wlock => dirstateguard => store lock" order,
and are released in reverse order.

This may cause that "dirstate.p1()" still refers to the changeset to be
rolled-back at (4) above: pushing multiple patches by "hg qpush" is
a typical case.

When releasing the store lock, such changesets are:

  - not contained in "repo.changelog", if it is reloaded from
    ".hg/00changelog.i", as that file was already truncated by
    "transaction.abort()"

  - still contained in it, otherwise
    (this "dirty read" problem is discussed in "Transaction Plan"
     http://mercurial.selenic.com/wiki/TransactionPlan)

Validation function shows "unknown working parent" warning in the
former case, but reloading "repo.changelog" depends on the timestamp
of ".hg/00changelog.i". This causes occasional test failures.

In the case of scheduled "commithook()", it just wants to examine
whether "node ID" of committed changeset is still valid or not. Other
examinations implied in "changectx.__init__()" are meaningless.

To avoid showing the "unknown working parent" warning irregularly, this
patch uses "changelog.hasnode()" instead of "node in self" to examine
existence of committed changeset.
2015-05-07 12:07:10 +09:00
Matt Mackall
82d521ccc3 merge with stable 2015-05-10 14:45:13 -05:00
Pierre-Yves David
0cae7109a3 test-run-test: unset run-test specific environment variables
Otherwise variable set for the real test run interfere with the test runner
tests.
2015-05-08 11:32:24 -07:00
Yuya Nishihara
fe4df27bf6 hgweb: bring back infinite scroll in shortlog of paper style
Since e902e55c3d0b, column headers are wrapped by <thead> element, so the first
and only <tbody> contains changelog data. I got the following error without
this patch:

    Uncaught TypeError: Cannot read property 'lastElementChild' of null
      scrollHandler @ mercurial.js:375
2015-05-07 07:46:39 +09:00
Yuya Nishihara
60069c670b templater: strictly parse leading backslashes of '{' (issue4569) (BC)
Because double backslashes are processed as a string escape sequence, '\\{'
should start the template syntax. On the other hand, r'' disables any sort
of \-escapes, so r'\{' can go either way, never start the template syntax
or always start it. I simply chose the latter, which means r'\{' is the same
as '\\{'.
2015-05-04 10:17:34 +09:00
Yuya Nishihara
6b7d953b63 templater: do not process \-escapes at parsestring() (issue4290)
This patch brings back pre-2.8.1 behavior.

The result of parsestring() is stored in templater's cache, t.cache, and then
it is parsed as a template string by compiletemplate(). So t.cache should keep
an unparsed string no matter if it is sourced from config value. Otherwise
backslashes would be processed twice.

The test vector is borrowed from 83ff877959a6.
2015-05-04 09:54:01 +09:00
Durham Goode
86da5b2adb histedit: fix test-histedit-edit on vfat
test-histedit-edit was broken because it relied on the HGEDITOR script being
executable. Instead, lets just execute 'sh' and pass it the script to run. This
seems to be the pattern followed in other tests.
2015-05-05 11:15:17 -07:00
Matt Harbison
7ae29b6407 archive: always use portable path component separators with subrepos
The previous behavior when archiving a subrepo 's' on Windows was to internally
name the file under it 's\file', due to the use of vfs.reljoin().  When printing
the file list from the archive on Windows or Linux, the file was named
's\\file'.  The archive extracted OK on Windows, but if the archive was brought
to a Linux system, it created a file named 's\file' instead of a directory 's'
containing 'file'.

*.zip format achives seemed not to have the problem, but this was definitely an
issue with *.tgz archives.

Largefiles actually got this right, but a test is added to keep this from
regressing.  The subrepo-deep-nested-change.t test was repurposed to archive to
a file, since there are several subsequent tests that archive to a directory.
The output change is losing the filesystem prefix '../archive_lf' and not
listing the directories 'sub1' and 'sub1/sub2'.
2015-05-04 22:33:29 -04:00
Durham Goode
d8291a43e1 histedit: fix --edit-plan
--edit-plan was completely broken from the command line because it used an old
api that was not updated (it would crash with a stack trace). Let's update it
and add tests to catch this.
2015-04-22 15:53:03 -07:00
Alexander Drozdov
f95ceba6f9 revset: id() called with 40-byte strings should give the same results as for short strings
The patch solves two issues:
1. id(unknown_full_hash) aborts, but id(unknown_short_hash) doesn't
2. id(40byte_tag_or_bookmark) returns tagged/bookmarked revision,
   but id(non-40byte_tag_or_bookmark) doesn't

After the patch:
1. id(unknown_full_hash) doesn't abort
2. id(40byte_tag_or_bookmark) returns empty set
2015-04-20 10:52:20 +03:00
Yuya Nishihara
9420a5f503 templater: fix crash by passing invalid object to date() function
"date information" is somewhat obscure, but we call it that way in
templatekw.showdate().
2015-05-03 17:33:14 +09:00
Siddharth Agarwal
c4e0365d23 util.checkcase: don't abort on broken symlinks
One case where that would happen is while trying to resolve a subrepo, if the
path to the subrepo was actually a broken symlink. This bug was exposed by an
hg-git test.
2015-05-03 12:49:15 -07:00
FUJIWARA Katsunori
2d5a78fede tests: make tests with temporary environment setting portable
With "dash" (as "/bin/sh" on Debian GNU/Linux), command execution in
"ENV=val foo bar" style doesn't work as expect in test script files,
if "foo" is user-defined function: it works fine, if "foo" is existing
commands like "hg".

5acecb004820 introduced tests for HGPLAIN and HGPLAINEXCEPT into
test-revset.t, and all of them are in such style.

This patch doesn't:

  - add explicit unsetting for HGPLAIN and HGPLAINEXCEPT

    they are already introduced by 5acecb004820

  - write assignment and exporting in one line

    "ENV=val; export ENV" for two or more environment variables in one
    line causes failure of test-check-code-hg.t: it is recognized as
    "don't export and assign at once" unfortunately.
2015-05-02 00:15:03 +09:00
Matt Harbison
f2ad8f39e0 debuginstall: expand the editor path before searching for it (issue4380)
The editor launches without expanding the path with commits because the shell
does that for us.

If the path isn't an executable, the expanded path is displayed, which is
probably more useful than the unexpanded path.  For example, in cmd.exe, '~'
expands to C:\Users\$user.  But it expands to C:/mingw/msys/1.0/home/$user in
MinGW.
2015-04-30 23:02:52 -04:00
Ryan McElroy
c2a7f23bdb templater: fail more gracefully for blank strings to word 2015-04-30 12:33:36 -07:00
Matt Harbison
9d40fb3218 windows: make shellquote() quote any path containing '\' (issue4629)
The '~' in the bug report is being expanded to a path with Windows style slashes
before being passed to shellquote() via util.shellquote().  But shlex.split()
strips '\' out of the string, leaving an invalid path in dispatch.aliasargs().

This regressed in 72640182118e.

For now, the tests need to be conditionalized for Windows (because those paths
are quoted).  In the future, a more complex regex could probably skip the quotes
if all component separators are double '\'.  I opted to glob away the quotes in
test-rename-merge2.t and test-up-local-change.t (which only exist on Windows),
because they are in very large blocks of output and there are way too many diffs
to conditionalize with #if directives.  Maybe the entire path should be globbed
away like the following paths in each changed line.  Or, letting #if directives
sit in the middle of the output as was mentioned a few months back would work
too.

Unfortunately, I couldn't figure out how to test the specific bug.  All of the
'hg serve' tests have a #require serve declaration, causing them to be skipped
on Windows.  Adding an alias for 'expandtest = outgoing ~/bogusrepo' prints the
repo as '$TESTTMP/bogusrepo', so the test runner must be changing the
environment somehow.
2015-04-29 21:14:59 -04:00
Matt Harbison
40ef0473bf test-commit-interactive: add more globs for no-execbit platforms
The ability to set the exec bit on Windows would be real handy for this test..
2015-04-29 23:55:25 -04:00
Siddharth Agarwal
eba77fa34f ui: disable revsetaliases in plain mode (BC)
ui.plain() is supposed to disable config options that change the UI to the
detriment of scripts. As the test demonstrates, revset aliases can actually
override builtin ones, just like command aliases. Therefore I believe this is a
bugfix and appropriate for stable.
2015-04-30 07:46:54 -07:00
Yuya Nishihara
dcadb4da71 bundlerepo: disable filtering of changelog while constructing revision text
This avoids the following error that happened if base revision of bundle file
was hidden. bundlerevlog needs it to construct revision texts from bundle
content as revlog.revision() does.

  File "mercurial/context.py", line 485, in _changeset
    return self._repo.changelog.read(self.rev())
  File "mercurial/changelog.py", line 319, in read
    text = self.revision(node)
  File "mercurial/bundlerepo.py", line 124, in revision
    text = self.baserevision(iterrev)
  File "mercurial/bundlerepo.py", line 160, in baserevision
    return changelog.changelog.revision(self, nodeorrev)
  File "mercurial/revlog.py", line 1041, in revision
    node = self.node(rev)
  File "mercurial/changelog.py", line 211, in node
    raise error.FilteredIndexError(rev)
  mercurial.error.FilteredIndexError: 1
2015-04-29 19:47:37 +09:00
Matt Harbison
7422218b87 merge: run update hook after the last wlock release
There were 2 test failures in 3.4-rc when running test-hook.t with the
largefiles extension enabled.  For context, the first is a commit hook:

  @@ -618,9 +621,9 @@
     $ echo 'update = hg id' >> .hg/hgrc
     $ echo bb > a
     $ hg ci -ma
  -  223eafe2750c tip
  +  d3354c4310ed+
     $ hg up 0
  -  cb9a9f314b8b
  +  223eafe2750c+ tip
     1 files updated, 0 files merged, 0 files removed, 0 files unresolved

   make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui

In both cases, largefiles acquires the wlock before calling into core, which
also acquires the wlock.  The first case was fixed in 4100e338a886 by ensuring
the hook only runs after the lock has been fully released.  The full release is
important, because that is what writes dirstate to the disk, allowing external
hooks to see the result of the update.  This simply changes how the update hook
is called, so that it too is deferred until the lock is finally released.

There are many uses of mergemod.update(), but in terms of commands, it looks
like the following commands take wlock while calling mergemod.update(), and
therefore will now have their hook fired at a later time:

    backout, fetch, histedit, qpush, rebase, shelve, transplant

Unlike the others, fetch immediately unlocks after calling update(), so for all
intents and purposes, its hook invocation is not deferred (but the external hook
still sees the proper state).
2015-04-29 15:52:31 -04:00
Pierre-Yves David
e5b26a2e94 bundle2: disable ouput capture unless we use http (issue4613 issue4615)
The current bundle2 processing was capturing all output. This is nice as it
provide better meta data about what output what, but this was changing two
things:

1) adding a prefix "remote: " to "other" output during local push (issue4613)
2) local and ssh push does not provide real time output anymore (issue4615)

As we are unsure about what form should be used in (1) and how to solve (2) we
disable output capture in this two cases. Output capture can be forced using an
experimental option.
2015-04-28 17:38:02 -07:00
Jordi Gutiérrez Hermoso
13181e1909 tests: add a new commit to test-commandline-template
This commit modifies, adds, renames, removes files all at once. It
will be mostly interesting for an upcoming test relating to the status
log template.
2015-05-05 14:45:09 -04:00
Pierre-Yves David
f0df3e65f1 run-tests: spread and document the content of time tuple
The spreading will make future modification clearer. The documentation improve
code readability.
2015-05-07 23:25:13 -07:00
Pierre-Yves David
3e15bcde32 run-tests: when building json, get time data in the same order as elsewhere
The json code was changing the order of the time tuple for unclear reasons. We
now use the same order as everywhere else.
2015-05-07 23:16:57 -07:00
Pierre-Yves David
21ad43905d run-tests: stop explicit expansion of time data
We are about to record more complex time-related data, which will require
repeated changes of every loop touching times data. That will also extend such
lines to a point where things become too long. Instead, we iterate on each entry
and expand values in the loops. We keep intermediate variables in most cases to
preserve readability.

The loop producing json data does a strange inversion for no obvious reason. We
preserved that for now and will fix it in another changeset.
2015-05-07 20:45:51 -07:00
Pierre-Yves David
809300b3ff run-tests: refactor json entry creation logic
We are about to add more timing related information to each entry. Having a
single place where the json entry is created is going to be much simpler.
2015-05-08 10:51:18 -07:00
Pierre-Yves David
84230712d6 run-tests: when building json, use result.failures instead of result.faildata
It is unclear to me why 'faildata' was used. Let's use the same kind of attribute
as for the other groups.
2015-05-07 23:20:24 -07:00
Pierre-Yves David
9f318745fd run-test: add a test for json output when -i is used
The -i can apparently confused some internal data structure, we want to make
sure we do not regress.
2015-05-08 19:32:11 -07:00
Pierre-Yves David
89d70011f0 run-test: ensure the test ports are available before launching test
I'm running into a systematic issue because there is always some port taken in the
1500-wide range of ports used by the test (3 for each test file).
2015-05-07 17:14:00 -07:00
Yuya Nishihara
42c8c2abc2 templater: strip single backslash before quotation mark in quoted template
e926f2ef639a fixed the issue of double escapes, but it made the following
template fail with syntax error because of <\">. Strictly speaking, <\">
appears to be invalid in non-string part, but we are likely to escape <">
if surrounded by quotes, and we are used to write such templates by trial
and error.

  [templates]
  sl = "{tags % \"{ifeq(tag,'tip','',label('log.tag', ' {tag}'))}\"}"

So, for backward compatibility between 2.8.1 and 3.4, a single backslash
before quotation mark is stripped only in quoted template. We don't care
for <\"> in string literal in quoted template, which never worked as expected
before.

  template  result
  --------- ------------------------
  {\"\"}    parse error
  "{""}"    {""} -> <>
  "{\"\"}"  {""} -> <>
  {"\""}    {"\""} -> <">
  '{"\""}'  {"\""} -> <">
  "{"\""}"  parse error (don't care)
2015-05-08 18:11:26 +09:00
Pierre-Yves David
3df7550e71 run-tests: implement Test._testMethodName
This methods is needed internally by utilities like __repr__. I do not see any
harm in having it declared. Any actual attempt to use it to call a test would
crash, but at least random debug print in the test runner will no longer crash.

Another approach would have been to redefine the __repr__ function, but I think
it a good thing to have some respect for the base class API.
2015-05-07 23:18:48 -07:00
Pierre-Yves David
f490dd76e1 test-subrepo-git: ignore pax_global_header when listing archive
d6f3cca7f3a5 is adding a new tar call but forgot to filter out the
pax_global_header file that some tar versions write. This is similar to what
happened in 686775e575f3.
2015-05-07 16:43:58 -07:00
Pierre-Yves David
6a8561c0f3 test-subrepo-recursion: glob out all the date listed by unzip -l
This date output is unstable (01-01-1980 vs 1980-01-01). As the test is not
about the modification date, we glob the data out.

Caught by buildbot.
2015-05-07 14:57:02 -07:00
Matt Mackall
402cbfd701 merge with stable 2015-05-07 14:19:20 -05:00
Matt Harbison
9fe8bb732e archive: drop the leading '.' path component from the prefix (issue4634)
Unix utilities like tar will happily prefix the files it packs with './', but
annoyingly, Windows Explorer will not show these packed files when it opens the
archive.  Since there doesn't seem to be a point in including './' in the path
names, just drop it.  The default 'hg archive' prefix is the basename of the
archive, so specifying '.' allows for that default to be disabled completely.
2015-05-05 20:52:38 -04:00
Matt Mackall
c2e038efe9 merge with stable 2015-05-07 13:47:45 -05:00
Mathias De Maré
633c0af10d subrepo: correctly handle git subdirectory status change
'git diff-index' by default does not recurse into subdirectories
when changes are found. As a result, the directory is shown as changed,
rather than the files in this directory.
Adding '-r' results in recursing until the blobs themselves are checked.
2015-05-06 17:15:38 +02:00
Matt Mackall
e88fc75dd4 merge with stable 2015-05-06 16:56:28 -05:00
Matt Harbison
1df2171ff6 subrepo: propagate the --hidden option to hg subrepositories
With many commands accepting a '-S' or an explicit path to trigger recursing
into subrepos, it seems that --hidden needs to be propagated too.
Unfortunately, many of the subrepo layer methods discard the options map, so
passing the option along explicitly isn't currently an option.  It also isn't
clear if other filtered views need to be propagated, so changing all of those
commands may be insufficient anyway.

The specific jam I got into was amending an ancestor of qbase in a subrepo, and
then evolving.  The patch ended up being hidden, and outgoing said it would only
push one unrelated commit.  But push aborted with an 'unknown revision' that I
traced back to the patch.  (Odd it didn't say 'filtered revision'.)  A push with
--hidden worked from the subrepo, but that wasn't possible from the parent repo
before this.

Since the underlying problem doesn't actually require a subrepo, there's
probably more to investigate here in the discovery area.  Yes, evolve + mq is
not exactly sane, but I don't know what is seeing the hidden revision.

In lieu of creating a test for the above situation (evolving mq should probably
be blocked), the test here is a marginally useful case where --hidden is needed
in a subrepo: cat'ing a file in a hidden revision.  Without this change, cat
aborts with:

  $ hg --hidden cat subrepo/a
  skipping missing subrepository: subrepo
  [1]
2015-02-03 15:01:43 -05:00
Matt Harbison
d85501c01b subrepo: don't pass the outer repo's --rev or --branch to subrepo incoming()
When passing a --rev, 'hg incoming -S' previously suffered from the same output
truncation or abort that was fixed for 'hg outgoing -S' in the previous patch,
for the same reasons.

Unlike push, subrepos are currently only pulled when the outer repo is updated,
not when the outer repo is pulled.  That makes matching 'hg pull' behavior
impossible.  Listing all incoming csets in the subrepo seems like the most
useful behavior, and is consistent with 'hg outgoing -S'.
2015-04-27 21:34:23 -04:00
Matt Harbison
87ea927ca1 subrepo: don't pass the outer repo's --rev or --branch to subrepo outgoing()
The previous behavior didn't reflect what would actually be pushed- push will
ignore --rev and --branch in the subrepo and push everything.  Therefore,
'push -r {rev}' would not list everything, unless {rev} was also the revision of
the subrepo's tip.  Worse, if a hash was passed in, the command would abort
because that hash would either not be in the outer repo or not in the subrepo.
2015-04-27 21:15:25 -04:00
Laurent Charignon
18e5516b11 shelve: make the interactive mode experimental
While fixing issue4304: "record: allow editing new files" we introduced
changes in record/crecord. These changes need to be matched with changes in any
command using record. Shelve is one of these commands and the changes have
not been made for this release. Therefore, shelve -i should be an experimental
feature for this release.
2015-04-27 15:36:10 -07:00
Siddharth Agarwal
222edc51db help: also hide options marked EXPERIMENTAL
Similar to DEPRECATED, add a way to indicate that options are EXPERIMENTAL.
2015-04-27 15:12:41 -07:00
Laurent Charignon
a76105b65c record: fix adding new file with record from within a subdir (issue4626)
In my latest change on record (edit newly added file), I forgot the
repo.wjoin() so that record was not computing the paths properly to delete
the backups and was crashing.
2015-04-27 14:02:49 -07:00
Matt Mackall
cc085ed36a tests: fix backslashes in test-casefolding 2015-04-27 16:24:43 -05:00
Matt Harbison
30dc79b90c test-commit-interactive: stablize output for no-execbit platforms 2015-04-26 15:13:13 -04:00
Matt Harbison
a3c34e558c test-bundle2-exchange: make hooks compatible with Windows
The cmd.exe process doesn't fail the hook when "; false" is appended, and its
echo command prints out the quote characters.
2015-04-26 15:10:09 -04:00
Matt Harbison
8ed0a9ea81 subrepo: don't write .hgsubstate lines with empty subrepo state (issue4622)
The '' that is used to represent the state of a not-yet-committed
subrepo cannot be written to the file, because the code that parses
the file splits on ' ' and expects two parts.

Given that the .hgsubstate file is automatically rewritten on commit, it seems
a little strange that the file is written out during a merge.
2015-04-24 23:23:55 -04:00
Matt Harbison
83f972bb8d revert: restore the ability to revert across case only renames (issue4481)
This regressed in 39be809de631, in what looks like an unrelated change.

It seems sufficient to pass 'ignoremissing=True', but the restored try/except
has been there for six years since 3f24f7324cd8, so this seems safer for now.
Note that renaming directories in the filename doesn't appear to work- not sure
if this would end up throwing a different type of error when that is fixed.
2015-04-25 23:54:31 -04:00