Commit Graph

24539 Commits

Author SHA1 Message Date
Mads Kiilerich
8561ae6b39 rpms: create missing builds dir if it doesn't exist 2015-04-14 23:51:02 -04:00
Mads Kiilerich
ea7df88985 rpms: for packages with their own python, put it in /opt/python-hg
This is more compliant with the FHS and Fedora packaging guidelines.
2015-04-14 23:44:03 -04:00
Mads Kiilerich
f11e1d55b9 branchcache: stay silent if failing to read cache files
The warning has in some cases incorrectly attributed unrelated problems to rbc.

Instead, just do like the branch head cache does and stay quiet when reading
fails. The cache will be missing the first time a repo is used. It is a normal
situation and there is no reason to make a note of that.
2015-01-14 01:15:26 +01:00
Mads Kiilerich
17c4f7c523 merge: better debug messages before/after invoking external merge tool 2015-03-19 22:22:50 +01:00
FUJIWARA Katsunori
bb58089c88 subrepo: use vfs.walk instead of os.walk
"dirpath" in the tuple yielded by "vfs.walk()" is relative one from
the root of specified vfs, and absolute path in the warning message is
composed by "vfs.join()".

On the other hand, target file "f" exists in "dirpath", and
"reljoin()" is needed to unlink "f" by "vfs.unlink()".
2015-04-11 23:00:04 +09:00
FUJIWARA Katsunori
57690add3e vfs: add walk
To eliminate "path prefix" (= "the root of vfs") part from "dirpath"
yielded by "os.walk()" correctly, "path prefix" should have "os.sep"
at the end of own string, but it isn't easy to ensure it, because:

  - examination by "path.endswith(os.sep)" isn't portable

    Some problematic encodings use 0x5c (= "os.sep" on Windows) as the
    tail byte of some multi-byte characters.

  - "os.path.join(path, '')" isn't portable

    With Python 2.7.9, this invocation doesn't add "os.sep" at the end
    of UNC path (see issue4557 for detail).

Python 2.7.9 changed also behavior of "os.path.normpath()" (see *) and
"os.path.splitdrive()" for UNC path.

    vfs root        normpath       splitdrive          os.sep required
    =============== ============== =================== ============
    z:\             z:\            z: + \              no
    z:\foo          z:\foo         z: + \foo           yes
    z:\foo\         z:\foo         z: + \foo           yes

    [before Python 2.7.9]
    \\foo\bar       \\foo\bar      '' + \\foo\bar      yes
    \\foo\bar\      \\foo\bar  (*) '' + \\foo\bar      yes
    \\foo\bar\baz   \\foo\bar\baz  '' + \\foo\bar\baz  yes
    \\foo\bar\baz\  \\foo\bar\baz  '' + \\foo\bar\baz  yes

    [Python 2.7.9]
    \\foo\bar       \\foo\bar      \\foo\bar + ''      yes
    \\foo\bar\      \\foo\bar\ (*) \\foo\bar + \       no
    \\foo\bar\baz   \\foo\bar\baz  \\foo\bar + \baz    yes
    \\foo\bar\baz\  \\foo\bar\baz  \\foo\bar + \baz    yes

If it is ensured that "normpath()"-ed vfs root is passed to
"splitdrive()", adding "os.sep" is required only when "path" part of
"splitdrive()" result isn't "os.sep" itself. This is just what
"pathutil.nameasprefix()" examines.

This patch applies "os.path.normpath()" on "self.join(None)"
explicitly, because it isn't ensured that vfs root is already
normalized: vfs itself is constructed with "realpath=False" (= avoid
normalizing in "vfs.__init__()") in many code paths.

This normalization should be much cheaper than subsequent file I/O for
directory traversal.
2015-04-11 23:00:04 +09:00
FUJIWARA Katsunori
e6ce58b269 subrepo: pass wvfs to _sanitize instead of absolute path to a subrepository
As a preparation for vfs migration of "_sanitize()", this patch passes
"wvfs" to "_sanitize()" and use "wvfs.base" instead of absolute path
to a subrepository.
2015-04-11 23:00:04 +09:00
Gregory Szorc
5b06fcaa29 repoview: move function for computing filtered hash
An upcoming patch will establish per-filter tags caches. We'll want
to use the same cache validation logic as the branch cache. Prepare
for that by moving the logic for computing a filtered view hash
to somewhere central.
2015-04-01 18:43:29 -07:00
Gregory Szorc
7498d10d47 revset: don't import discovery at module level
discovery.py imports a lot of the world. Pierre-Yves told me to move it
to a function-level import to avoid an import cycle in a future patch.
2015-04-14 12:54:16 -04:00
Michael O'Connor
d4eb35d7ec transaction: add missing newline to message
Add a missing newline to the "journal was created by a
different version of Mercurial" message.
2015-04-14 10:59:26 -04:00
Yuya Nishihara
15789cf528 cat: disable optimization of single file case for workingctx
It crashes because workingctx has no manifest.
2015-04-05 13:16:46 +09:00
Yuya Nishihara
0301f78f70 committablectx: override manifestnode() to return None
wctx.manifestnode() crashed before because it has no _changeset. Instead of
crashing, just return None like wctx.node().
2015-04-09 22:18:55 +09:00
Yuya Nishihara
97905d5b99 cat: use ctx.manifestnode() in place of ctx._changeset[0] 2015-04-11 16:01:42 +09:00
Matt Harbison
75f10ee474 changegroup: flush the ui stdio buffers after adding a changegroup
This eliminates the following test failure on Windows, as well as a similar one
in evolve's test-wireproto.t.  See the previous patch for details on the
problem.

  --- e:/Projects/hg/tests/test-init.t
  +++ e:/Projects/hg/tests/test-init.t.err
  @@ -216,10 +216,10 @@
      * test                      0:08b9e9f63b32
     $ hg clone -e "python \"$TESTDIR/dummyssh\"" local ssh://user@dummy/remote-bookmarks
     searching for changes
  +  exporting bookmark test
     remote: adding changesets
     remote: adding manifests
     remote: adding file changes
     remote: added 1 changesets with 1 changes to 1 files
  -  exporting bookmark test
     $ hg -R remote-bookmarks bookmarks
        test                      0:08b9e9f63b32
2015-04-10 23:34:06 -04:00
Matt Harbison
14e6825ce0 hook: forcibly flush stderr for Windows test stability
There are a handful of SSH related test failures on Windows.

  --- c:/Users/Matt/Projects/hg/tests/test-bundle2-exchange.t
  +++ c:/Users/Matt/Projects/hg/tests/test-bundle2-exchange.t.err
  @@ -305,16 +305,16 @@
     remote: added 1 changesets with 1 changes to 1 files
     remote: 1 new obsolescence markers
     updating bookmark book_5fdd
  +  pre-close-tip:02de42196ebe draft book_02de
  +  postclose-tip:02de42196ebe draft book_02de
  +  txnclose hook: HG_SOURCE=push-response HG_TXNNAME=push-response
  +  ssh://user@dummy/other HG_URL=ssh://user@dummy/other
     remote: pre-close-tip:5fddd98957c8 draft book_5fdd
     remote: pushkey: lock state after "bookmarks"
     remote: lock:  free
     remote: wlock: free
     remote: postclose-tip:5fddd98957c8 draft book_5fdd
     remote: txnclose hook: (env vars truncated)
  -  pre-close-tip:02de42196ebe draft book_02de
  -  postclose-tip:02de42196ebe draft book_02de
  -  txnclose hook: HG_SOURCE=push-response HG_TXNNAME=push-response
  -  ssh://user@dummy/other HG_URL=ssh://user@dummy/other
     $ hg -R other log -G
     o  6:5fddd98957c8 draft Nicolas Dumazet <...> book_5fdd C
     |

  --- c:/Users/Matt/Projects/hg/tests/test-ssh.t
  +++ c:/Users/Matt/Projects/hg/tests/test-ssh.t.err
  @@ -438,12 +438,12 @@
     $ hg push
     pushing to ssh://user@dummy/remote
     searching for changes
  +  local stdout
     remote: adding changesets
     remote: adding manifests
     remote: adding file changes
     remote: added 1 changesets with 1 changes to 1 files
  -  remote: KABOOM
  -  local stdout
  +  remote: KABOOM\r (esc)

     $ cd ..


What is happening is that no data is available in 'sshpeer.pipee' while the
command is executing.  As the command completes, local output is printed, and
then sshpeer.cleanup() is called.  When it calls 'self.pipeo.close()', the child
process is shutdown, flushing stderr.

As an experiment, I printed a line to stdout and another to stderr instead this
flush().  The stdout data was immediately available to the hg client, and none
of the stderr data was until the child exited.  At that point, pipee has all of
the buffered data, and it is read out and printed before the pipe is closed in
sshpeer.cleanup().  This is probably a known issue, since ui.write_err()
mentions that stderr may be buffered, and also flushes stderr.

It would be nice if there was a more general fix (there is one more test that
fails), but I'm not sure what it is.  I've seen (ancient) references [1] to
setvbuf() "crashing spectacularly" on some systems if any I/O has been done
already, so it seems worth avoiding.


https://sourceware.org/ml/gdb-patches/2013-08/msg00422.html

[1] https://groups.google.com/forum/#!msg/comp.lang.python/JT8LiYzYDEY/Qg9d1HwyjScJ
2015-04-10 22:30:19 -04:00
Gregory Szorc
205d244aa3 json: implement {fileannotate} template 2015-04-10 22:37:40 -04:00
Gregory Szorc
173c4bfaea json: implement {comparison} template
Similar to {filediff}, we abbreviate some property names to cut down on
string bloat.
2015-04-10 22:26:53 -04:00
Gregory Szorc
2f0000c95a json: implement {filediff} template
Single letter properties are used to keep payload size down, as diff
representation can be quite large and longer property names can create a
lot of extra work for parsers.

Rename is not yet captured. This can be done in a follow-up.
2015-04-10 22:39:22 -04:00
Gregory Szorc
07417ade7a hgweb: expose raw line numbers to templates
Surpringly, the templates didn't receive an unmodified version of the
line numbers. Expose it to make implementing the JSON templates easier.

In theory, we could post-process an existing template variable. But
extra string manipulation seems quite wasteful, especially on items that
could occur hundreds or even thousands of times in output.
2015-04-10 22:34:12 -04:00
Pierre-Yves David
712fee42ec revert: stop marking files clean after interactive revert (issue4592)
The goal of 'hg revert --interactive' is usually to keep some change in the
revert file, so the files -must-not- be marked as clean. We want the status
logic to do its usual job here.

For unclear reasons (probably timing related), I was unable to build an automated
test that reproduced issue4592 but manual testing shows this is fixed.
2015-04-11 11:54:09 -04:00
Augie Fackler
5e2ccad13e lazymanifest: prevent leak when updating an entry more than once
__setitem__ on the lazymanifest C type wasn't checking to see if a
line had previously been malloced before replacing it, leading to
leaks if files got updated multiple times in the course of a task.

I was able to reproduce the leak with this change to test-manifest.py:

diff --git a/tests/test-manifest.py b/tests/test-manifest.py
--- a/tests/test-manifest.py
+++ b/tests/test-manifest.py
@@ -456,6 +456,16 @@ class basemanifesttests(object):
                 ['a/b/c/bar.txt', 'a/b/c/foo.txt', 'a/b/d/ten.txt'],
                 m2.keys())

+    def testManifestSetItem(self):
+        m = self.parsemanifest('')
+        for x in range(3):
+            m['file%d' % x] = BIN_HASH_1
+        for x in range(3):
+            m['file%d' % x] = BIN_HASH_2
+        import time
+        time.sleep(4)
+
+

along with the commands:

 $ make local
 $ PYTHONPATH=. SILENT_BE_NOISY=1 python tests/test-manifest.py testmanifestdict.testManifestSetItem &
 $ sleep 4
 $ leaks $(jobs -p | tee /dev/stderr | awk '{print $3}')
 $ wait

in an interactive shell on OS X. As far as I can tell, it had to be an
interactive shell so that I could get the pid of the test run using
the jobs builtin. Prior to this change, I was leaking several strings,
and after this change leaks reports no leaks.

I thought there was a bug filed for this in bugzilla, but I can't find
it either in bugzilla or by searching my email.
2015-04-11 11:56:21 -04:00
Matt Mackall
bfad591c42 strip: properly clear resolve state with --keep (issue4593)
Normal updates automatically clean up the resolve state, but strip
--keep does a "manual" update that bypasses the normal machinery. This
adds a mergestate reset.
2015-04-13 07:42:25 -05:00
Ryan McElroy
0bcb80448a revsets: more informative syntax error message
I came across a case where an internal command was using a revset that I didn't
immediately pass in and it was difficult to debug what was going wrong with the
revset. This prints out the revset and informs the user that the error is with
a rebset so it should be more obvious what and where the error is.
2015-04-13 20:53:05 -07:00
Ryan McElroy
7500433d6e revsets: show current revset abort behavior 2015-04-13 21:06:21 -07:00
Gregory Szorc
cbc3d51109 tests: move blackbox testing of tags to test-tags.t
We're going to refactor tags cache shortly. It is easier to test the
blackbox logging if these tests are in test-tags.t.
2015-04-13 13:28:37 -04:00
Gregory Szorc
bc524f4cd2 tests: move mock blackbox extension into own file
Having all blackbox log testing in test-blackbox.t isn't scalable. Move
the mock blackbox extension into its own file so we can start to move
blackbox logging into other tests.
2015-04-13 09:36:33 -04:00
Pierre-Yves David
f0ebfa4a59 shelve: acquire lock in the right order
Text book says that 'wlock' should be acquired before 'lock'.
Caught through developer warning.
2015-04-12 14:59:31 -04:00
Pierre-Yves David
812e82cf4f check-commit: be more picky about detection of wrong bug tag
The check-commit script search for "bug" withing bracket and ask people to use
(issueXXXX) instead. The test was too wide and matching any "(+b+u+g"sequence.
2015-04-12 14:54:53 -04:00
Michael O'Connor
824e19a989 discovery: don't compute allfuturecommon when it won't be used
In repos with many changesets, the computation of allfuturecommon
can take a significant amount of time.  Since it's only used if
there's an obsstore, don't compute it otherwise.
2015-04-13 09:54:36 -04:00
Martin von Zweigbergk
63f47478d7 treemanifest: separate flags for trees in memory and trees on disk
When we start writing tree manifests with one manifest revlog per
directory, it will still be nice to be able to run tests using tree
manifests in memory but writing to a flat manifest to a single
revlog. Let's break the current '_usetreemanifest' flag on the revlog
into '_treeinmem' and '_treeondisk'. Both are populated from the same
config, but after this change, one can temporarily hard-code
_treeinmem=True to see that tests still pass.
2015-04-10 18:54:33 -07:00
Martin von Zweigbergk
320b8b5298 manifestdict: drop empty-string argument when creating empty manifest
manifestdict() creates an empty manifestdict, so let's consistently
use that instead of explicitly parsing an empty string (which does
result in an empty manifest).
2015-04-10 18:13:01 -07:00
Mike Hommey
50ad077324 lazymanifest: fix memory leak in lmiter_iterentriesnext() after e3b881ea6832 2015-04-12 06:51:13 -07:00
Pierre-Yves David
9ec3313e25 revert: do not requires '--all' if '--interative' is present
The '--all' option have been introduced in 0a81b7721d8f (August 2006), most
probably to prevent user shooting themselves in the foot. As the record process
will let you, view and select the set of files and change you want to revert, I
feel like the '--all' flag is superfluous in the '--interactive' case.
2015-04-11 12:26:54 -04:00
Pierre-Yves David
fd6a1d024d bundle2: drop the experimental hooks
The series at a17556fc1521::77b112363d48 introduced generic transaction level
hooking. This makes the experimental bundle2 specific hooks redundant, we drop
them.
2015-04-09 16:18:38 -04:00
Pierre-Yves David
393230ee25 bundle2: advertise bundle2 by default
That way, any new server will be ready to accept bundle2 payload. The decision
for the client to use it is still off by default so this is not turning bundle2
everywhere.

We introduce a new kill switch for this in case stuff goes wrong.
2015-04-10 15:41:33 -04:00
Matt Harbison
de8806d8c6 subrepo: convert the os.path references in git to vfs
There are a handful of os.path references in the free functions at the top of
the module that will be trickier to remove.
2015-02-07 12:57:40 -05:00
FUJIWARA Katsunori
1de7607de0 subrepo: use vfs.removedirs instead of os.removedirs
This patch also removes useless composing absolute path by "repo.wjoin()".
2015-04-11 00:47:09 +09:00
FUJIWARA Katsunori
798e1be41f vfs: add removedirs 2015-04-11 00:47:09 +09:00
FUJIWARA Katsunori
d376c990a1 util: add removedirs as platform depending function
According to 6b1369445b7b introducing "windows._removedirs()":

    If a hg repository including working directory is a reparse point
    (directory symlinked or a junction point), then using
    os.removedirs will remove the reparse point erroneously.

"windows._removedirs()" should be used instead of "os.removedirs()" on
Windows.

This patch adds "removedirs" as platform depending function to replace
"os.removedirs()" invocations for portability and safety
2015-04-11 00:47:09 +09:00
FUJIWARA Katsunori
85f9891920 subrepo: use vfs.unlink instead of os.remove
This patch also removes useless composing absolute path by
"os.path.join()".
2015-04-11 00:47:09 +09:00
FUJIWARA Katsunori
3a9e7a3504 subrepo: use vfs.rmtree instead of shutil.rmtree
This patch also removes useless "shutil" import.
2015-04-11 00:47:09 +09:00
FUJIWARA Katsunori
51fdbd9c2a vfs: add rmtree
This duplicates "onerror()" function from "svnsubrepo.remove()" for
equivalence of replacing in subsequent patch.

This "onerror()" function for "shutil.rmtree()" was introduced by
094a056562e7, which avoids failure of removing svn repository on
Windows.
2015-04-11 00:47:09 +09:00
FUJIWARA Katsunori
406aa94dc6 subrepo: use vfs.readdir instead of os.listdir to avoid expensive stat calls
"kind" information given from "vfs.readdir()" makes expensive stat
calls "os.path.isdir()" and "os.path.islink()" useless.
2015-04-11 00:47:09 +09:00
Alexander Drozdov
0af407fa48 editor: prefer 'intermediate-source' extra to use for HGREVISION environment variable
Revision 7fbf0ef28408 ('graft: record intermediate grafts in extras') introduced
'intermediate-source' extra which refers to the closest graft source.

As 'intermediate-source' extra provides more detailed information about the source
changeset than 'source' one, it is better to prefer the first one to use as a
value of HGREVISION environment variable for an editor.
2015-04-10 08:05:50 +03:00
Pierre-Yves David
af7d20b000 bundle2: rename format, parts and config to final names
It is finally time to freeze the bundle2 format! To do so we:
- rename HG2Y to HG20,
- drop "b2x:" prefix from all part names,
- rename capability to "bundle2-exp" to "bundle2"
- rename the hook flag from 'bundle2-exp' to 'bundle2'
2015-04-09 16:25:48 -04:00
Martin von Zweigbergk
4c187a8462 manifestdict: extract condition for _intersectfiles() and use for walk()
The condition on which manifestdict.matches() and manifestdict.walk()
take the fast path of iterating over files instead of the manifest, is
slightly different. Specifically, walk() does not take the fast path
for exact matchers and it does not avoid taking the fast path when
there are more than 100 files. Let's extract the condition so we don't
have to maintain it in two places and so walk() can gain these two
missing pieces of the condition (although there seems to be no current
caller of walk() with an exact matcher).
2015-04-08 09:38:09 -07:00
Martin von Zweigbergk
2592408744 manifestdict.walk: remove now-redundant check for match.files()
When checking whether we can take the fast path of iterating over
matcher files instead of manifest files, we check whether
match.files() is non-empty. However, now that return early for
match.always(), it can only be empty when there are only
include/exclude patterns, but in that case anypats() will be True, so
it's already covered. This makes manifestdict.walk() more similar to
manifestdict.matches().
2015-04-07 22:40:25 -07:00
Martin von Zweigbergk
67897f5b0b manifest.walk: special-case match.always() for speed
This cuts down the run time of

  hg files -r . > /dev/null

from ~0.850s to ~0.780s on the Firefox repo. Note that
manifest.matches() already has the corresponding optimization.
2015-04-07 21:08:23 -07:00
Martin von Zweigbergk
fc5772e190 manifest.walk: use return instead of StopIteration in generator
Using "return" within a generator is supposedly more Pythonic than
raising StopIteration.
2015-04-07 22:36:17 -07:00
Yuya Nishihara
7de01412a9 archive: look for first visible revision to build repo identity (issue4591)
No test for the case where all revisions are hidden because "archive" command
aborts if the target revision is null.
2015-04-08 23:30:02 +09:00