Commit Graph

8228 Commits

Author SHA1 Message Date
Siddharth Agarwal
8b07d14666 commands.diff: add support for diffs relative to a subdirectory
Previous patches added all the backend support for this. This exposes this
option in the UI.
2015-03-17 15:46:30 -07:00
Siddharth Agarwal
52e04b718f test-fileset.t: remove 'bar ' and 'baz\' from tested filenames
This test is guarded by a '#if no-windows', but they can't be written out on
vfat on Linux either. con.xml can, and for testing that's good enough.

Also clean up a stray 'ls' that I mistakenly left in while writing the test.
2015-03-22 19:19:16 -07:00
Gregory Szorc
f0e6b05c9b commands.push: abort when revisions evaluate to empty set (BC)
If the "-r" argument is specified to "hg push," the user has expressed
an intent for a specific changeset to be present on the remote. If that
expression cannot be mapped to a known changeset, the user's intent is
ambiguous and cannot be acted upon without making assumptions.

Previously, if arguments to `push -r <rev>` evaluated to an empty set
(perhaps the user specified a revset that didn't evaluate to anything),
the empty "revs" list would be passed down to "exchange.push" where
it appears the empty list was being interpreted as "push everything."

This patch adds validation to the "-r" argument to the push command. If
the argument is specified but doesn't resolve to a changeset, the
command will abort instead of doing something potentially unexpected.

This patch is technically breaking backwards compatibility. I believe
this is justified because the new behavior closes a crack that could
result in undefined or under-defined behavior. Also, this patch doesn't
drop client capabilities because if users really wanted to push all
changesets, they can simply omit the "-r" argument from push completely.
2015-03-23 18:21:01 -07:00
Matt Harbison
2e1bbe621d test-fileset: forget non-portable files to avoid failures on Windows
The 3 deleted lines appeared on Windows, because the files were never created in
the first place.
2015-03-21 01:24:17 -04:00
Matt Harbison
430072a9cc crecord: conditionalize the imports that are not available on Windows
'fcntl', 'termios' and 'wcurses' are not available on the default Windows python
installation, and importing them caused widespread carnage in the test suite.
There were 29 different changed test files (on top of unrelated errors), mostly
in the form of an ImportError.

The failures weren't related to actual crecord use, and followed the import
chain:

    'localrepo' -> 'subrepo' -> 'cmdutil' -> 'crecord' -> 'fcntl'
2015-03-20 23:32:00 -04:00
Yuya Nishihara
676ee8092d annotate: add option to annotate working-directory files
Working revision or node is displayed with "+" suffix in plain output, but
null/None in machine-readable format.
2014-08-16 17:50:55 +09:00
Yuya Nishihara
4290eff5ce revset: add wdir() function to specify workingctx revision by command
The main purpose of wdir() is to annotate working-directory files.

Currently many commands and revsets cannot handle workingctx and may raise
exception. For example, -r ":wdir()" results in TypeError. This problem will
be addressed by future patches.

We could add "wdir" symbol instead, but it would conflict with the existing
tag, bookmark or branch. So I decided not to.

List of commands that will potentially support workingctx revision:

  command   default  remarks
  --------  -------  -----------------------------------------------------
  annotate  p1       useful
  archive   p1       might be useful
  cat       p1       might be useful on Windows (no cat)
  diff      p1:wdir  (default)
  export    p1       might be useful if wctx can have draft commit message
  files     wdir     (default)
  grep      tip:0    might be useful
  identify  wdir     (default)
  locate    wdir     (default)
  log       tip:0    might be useful with -p or -G option
  parents   wdir     (default)
  status    wdir     (default)

This patch includes minimal test of "hg status" that should be able to handle
the workingctx revision.
2014-08-16 13:44:16 +09:00
Matt Harbison
3ea5067ed3 subrepo: add basic support to hgsubrepo for the files command
Paths into the subrepo are not yet supported.

The need to use the workingctx in the subrepo will likely be used more in the
future, with the proposed working directory revset symbol.  It is also needed
with archive, if that code is to be reused to support 'extdiff -S'.
Unfortunately, it doesn't seem possible to put the smarts in subrepo.subrepo(),
as it breaks various status and diff tests.

I opted not to pass the desired revision into the subrepo method explicitly,
because the only ones that do pass an explicit revision are methods like status
and diff, which actually operate on two contexts- the subrepo state and the
explicitly passed revision.
2015-03-18 23:03:41 -04:00
Siddharth Agarwal
63850f5fd4 fileset: add a fileset for portable filenames
This has mostly the same semantics as the files that the 'ui.portablefilenames'
config option would warn or abort about. The only difference is filenames that
case-fold to the same string -- given a set of filenames we've already
checked we can check whether a new one collides with them, but we don't have a
way to tell which filename it collided with.
2015-03-19 21:26:18 -07:00
FUJIWARA Katsunori
928dad06e6 bookmarks: rewrite comparing bookmarks in commands.summary() by compare()
This patch adds utility function "summary()", to replace comparing
bookmarks in "commands.summary()". This replacement finishes
centralizing the logic to compare bookmarks into "bookmarks.compare()".

This patch also adds test to check summary output with
incoming/outgoing bookmarks, because "hg summary --remote" is not
tested yet on the repository with incoming/outgoing bookmarks.

This test uses "(glob)" to ignore summary about incoming/outgoing
changesets.
2015-03-19 23:36:06 +09:00
Matt Mackall
9de10bc107 tests: avoid deprecation warning 2015-03-19 15:21:08 -05:00
Siddharth Agarwal
4a073b9113 patch._applydiff: resolve prefix with respect to the cwd
This has several advantages compared to resolving it relative to the root:

- '--prefix .' works as expected.
- consistent with upcoming 'hg diff' option to produce relative patches

(I made sure to put in the (glob) annotations this time!)
2015-03-19 10:18:05 -07:00
Yuya Nishihara
86c988c8d2 test-revert-interactive: eliminate bashism in wildcard pattern
The test failed with Debian dash.
2015-03-20 00:22:37 +09:00
Pierre-Yves David
62e2c05058 devel: also warn about transaction started without a lock
Nobody should start a transaction on an unlocked repository. If
developer warnings are enabled this will be reported. This use the
same config as bad locking order since this is closely related.
2015-03-10 21:03:45 -07:00
Pierre-Yves David
19f197befa devel: move the lock-checking code into core
If the developer warnings are enabled, bad locking order will be
reported without the need for the contrib extension.
2015-01-16 02:51:10 -08:00
Siddharth Agarwal
400fb488cd patch.pathtransform: prepend prefix even if strip is 0
Silly oversight by me.
2015-03-18 20:59:06 -07:00
Martin von Zweigbergk
500314e378 context.walk: walk all files when file and '.' given
When both '.' (the working copy root) and an explicit file (or files)
are in match.files(), we only walk the explicitly listed files. This
is because we remove the '.' from the set too early. Move later and
add a test for it. Before this change, the last test would print only
"3".
2015-03-18 11:42:09 -07:00
Durham Goode
e0b3f09a3b revbranchcache: write cache even during read operations
Previously we would only actually write the revbranchcache to disk if we were in
the middle of a write operation (like commit). Now we will also write it during
any read operation. The cache knows how to invalidate itself, so it shouldn't
become corrupt if multiple writers try at once (and the write-on-read
behavior/risk is the same as all our other caches).
2015-02-24 18:43:31 -08:00
Durham Goode
6d370da089 revbranchcache: add test for when the cache is not writable
The revbranchecache code already handled the case when the cache file wasn't
writable, but let's add a test as well so future changes don't regress this.
2015-03-17 14:29:56 -07:00
Yuya Nishihara
bbf743afcb fetch: use an abort hint where appropriate 2015-03-17 20:36:33 +09:00
Yuya Nishihara
610665ea76 commands: say "working directory" in full spelling 2015-03-17 21:53:17 +09:00
Yuya Nishihara
53f1e7866c commands: replace "working copy" with "working directory" in help/messages
"working directory" is the standard term, we should use it consistently.

But I didn't touch the hint, "run 'hg update' to get a working copy", because
"get a working directory" sounds a bit odd.
2015-03-17 22:47:08 +09:00
Matt Harbison
8a3f14eed1 test-commit-interactive-curses: #require 'tic'
When run on Windows, this test aborts:

@@ -20,7 +20,8 @@
   > X
   > EOF
   $ hg commit -i  -m "a" -d "0 0"
-  no changes to record
+  abort: No module named fcntl!
+  [255]
   $ hg tip
   changeset:   -1:000000000000
   tag:         tip

Maybe there's another way to get the screen size on Windows (it dies in
crecord.gethw()), but for now, quiet the test noise by skipping it if terminal
info compiler is unavailable.
2015-03-17 22:21:09 -04:00
Matt Harbison
9741c43e48 tests: replace uses of 'seq' with portable 'seq.py' 2015-03-17 21:47:47 -04:00
Matt Harbison
dc4a0aa2d2 tests: introduce 'seq.py' as a portable replacement for 'seq'
OS X 10.6.8 doesn't have it, while 10.10 does.  I'm not sure when it was added.
It may be missing from other platforms as well.

This currently doesn't handle the string manipulation options (-f, -s and -w in
MinGW anyway), since there is currently no need for it.  Since xrange defaults
to starting at 0 instead of 1, and treats the end as exclusive instead of
inclusive, the args need to be extracted instead of doing:

        xrange(*[int(a) for a in sys.argv[1:]])

Therefore, the step might as well be added, even though there is no current use.
2015-03-17 20:59:23 -04:00
Laurent Charignon
f97eaa8ce4 revert: add flag to make revert interactive 2015-03-16 16:33:59 -07:00
FUJIWARA Katsunori
d8359fb8e3 bookmarks: reuse @number bookmark, if it refers changeset referred remotely
Before this patch, "@number" suffixed bookmark may be newly created at
each "hg pull" from the remote repository, if the bookmark in remote
repository diverges from one in local one.

This causes unexpected increase of "@number" suffixed bookmarks.

This patch reuses "@number" suffixed bookmark, if it refers the
changeset which is referred by the same bookmark in the remote
repository.
2015-03-17 18:20:24 +09:00
FUJIWARA Katsunori
2ae4c00003 bookmarks: prevent divergent bookmark from being updated unexpectedly
Before this patch, "@99" suffixed bookmark may be updated unexpectedly
by the bookmark value on the remote side at "hg pull", if all of "@1"
to "@99" suffixed bookmarks exist in the local repository, because
variable "n" still refers "@99" suffixed bookmark after the loop to
examine "@num" suffixes, even though it already exists in the local
repository.

This patch prevents divergent bookmark from being updated
unexpectedly, and shows warning message in such situation.

This patch uses original python script "seq.py" instead of "seq"
command to create sequence numbers in the test, because "seq" command
may not be available: it isn't defined in recent POSIX specification
(POSIX.1-2001 2013 Edition or XPG7)
2015-03-17 18:20:24 +09:00
Mike Edgar
c4ec7b1256 censor: add exchange tests, via local push/pull and bundle/unbundle
These tests exercise the edge cases of exchanging censored commits between
censor-aware Mercurial clients. These tests do not extend to cover
backwards-compatible exchange; such tests require a script which builds older
versions of Mercurial.

For more background on the censorship feature design, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-03-15 21:52:35 -04:00
Mike Edgar
995a7fa51f censor: add censor command to hgext with basic client-side tests
The censor command is a core extension which can replace the contents of a
historical file revision with a censor "tombstone" which can be exchanged
with older clients in place of the real revision data. The command rewrites
the filelog by copying revision-by-revision.

Care must be taken to expand the fulltext of the children of the censored
revision before copying them to the new filelog; they might be stored as
deltas against the uncensored revision, and those deltas will be invalidated.

For more background on the censorship feature design, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-03-15 21:52:17 -04:00
Laurent Charignon
8f36385e6f record: add tests for the curses recording interface 2015-03-12 14:42:55 -07:00
Augie Fackler
ad2c6da74f run-tests: ignore ENOENT failures when removing old .err results
When the same test runs in multiple threads and the previous run was a
failure, the threads can race to delete the error output. This fixes
that.
2015-03-13 13:03:55 -04:00
Augie Fackler
276fc64752 run-tests: stop storing start/stop times in a dict by test name
This resolves the last breakage in run-tests that prevented me from
running a single test many times in several threads in parallel. This
will be useful for testing potential fixes to flaky tests.
2015-03-13 12:50:53 -04:00
Augie Fackler
194ceb2b00 run-tests: avoid running the same test instance concurrently
There's a fair amount of mutable state stored on test case
instances. That causes many weird failures if you try to do something
like `run-tests.py -j16 --loop test-help.t`. The quick fix is this
slightly weird test-reloading dance, which ensures that every time a
test is executed it runs on a fresh instance of the TestCase subclass.
2015-03-13 12:47:16 -04:00
Augie Fackler
3b029f0bf6 run-tests: add --runs-per-test flag
This is useful when you're working with a flaky test and want to run
it (for example) 500 times to see if it'll false-fail. This currently
breaks if you use it with more than one thread, but I'm looking into
that now.
2015-03-13 11:21:53 -04:00
Augie Fackler
21638a3adf convert: adjust progress bar for octopus merges (issue4169)
For merges, we walk the files N-1 times, where N is the number of
parents. This means that for an octopus merge with 3 parents and 2
changed files, we actually fetch 6 files. This corrects the progress
output of the convert command when such commits are encountered.
2015-03-12 21:41:50 -04:00
Augie Fackler
762d998ab9 test-convert-git: show insane progress bar with octopus merge (issue4169)
This is done as a separate change from the fix so that it's obvious
what is corrected by the bugfix.
2015-03-12 21:31:52 -04:00
Matt Mackall
ac615a6f29 merge with stable 2015-03-16 13:41:45 -05:00
Yuya Nishihara
990aa241a1 templates: fix "log -q" output of default style
It was changed at ad92c202bbcd unintentionally due to name conflicts.
2015-03-14 22:34:27 +09:00
Yuya Nishihara
7445ebd638 hgweb: prevent loading style map from directories other than specified paths
A style name should not contain "/", "\", "." and "..". Otherwise, templates
could be loaded from outside of the specified templates directory by invalid
?style= parameter. hgweb should not allow such requests.

This change means subdir/name is also rejected.
2015-03-13 21:18:59 +09:00
Laurent Charignon
4d37443b63 record: remove duplicated tests
Since the record and commit -i commands are identical we simplify record's test
to just cover the help message and minimal smoke testing.
2015-03-11 16:18:47 -07:00
Jordi Gutiérrez Hermoso
8eb132f5ea style: kill ersatz if-else ternary operators
Although Python supports `X = Y if COND else Z`, this was only
introduced in Python 2.5. Since we have to support Python 2.4, it was
a very common thing to write instead `X = COND and Y or Z`, which is a
bit obscure at a glance. It requires some intricate knowledge of
Python to understand how to parse these one-liners.

We change instead all of these one-liners to 4-liners. This was
executed with the following perlism:

    find -name "*.py" -exec perl -pi -e 's,(\s*)([\.\w]+) = \(?(\S+)\s+and\s+(\S*)\)?\s+or\s+(\S*)$,$1if $3:\n$1    $2 = $4\n$1else:\n$1    $2 = $5,' {} \;

I tweaked the following cases from the automatic Perl output:

    prev = (parents and parents[0]) or nullid
    port = (use_ssl and 443 or 80)
    cwd = (pats and repo.getcwd()) or ''
    rename = fctx and webutil.renamelink(fctx) or []
    ctx = fctx and fctx or ctx
    self.base = (mapfile and os.path.dirname(mapfile)) or ''

I also added some newlines wherever they seemd appropriate for readability

There are probably a few ersatz ternary operators still in the code
somewhere, lurking away from the power of a simple regex.
2015-03-13 17:00:06 -04:00
Augie Fackler
087f03a71a cvsps: use a different tiebreaker to avoid flaky test
After adding some sneaky debug printing[0], I determined that this
test flaked when a CVS commit containing two files starts too close to
the end of a second, thus putting file "a" in one second and "b/c" in
the following second. The secondary sort key meant that these changes
sorted in a different order when the timestamps were different than
they did when they matched. As far as I can tell, CVS walks through
the files in a stable order, so by sorting on the filenames in cvsps
we'll get stable output. It's fine for us to switch from sorting on
the branchpoint as a secondary key because this was already the point
when we didn't care, and we're just trying to break ties in a stable
way. It's unclear to be if having the branchpoint present matters
anymore, but it doesn't really hurt to leave it.

With this change in place, I was able to run test-convert-cvs over 650
times in a row without a failure.  test-convert-cvcs-synthetic.t
appears to still be flaky, but I don't think it's *worse* than it was
before - just not better (I observed one flaky failure in 200 runs on
that test).

0: The helpful debug hack ended up being this, in case it's useful to
future flaky test assassins:

 --- a/hgext/convert/cvsps.py
 +++ b/hgext/convert/cvsps.py
 @@ -854,6 +854,8 @@ def debugcvsps(ui, *args, **opts):
              ui.write(('Branch: %s\n' % (cs.branch or 'HEAD')))
              ui.write(('Tag%s: %s \n' % (['', 's'][len(cs.tags) > 1],
                                    ','.join(cs.tags) or '(none)')))
 +            if cs.comment == 'ci1' and (cs.id == 6) == bool(cs.branchpoints):
 +                ui.write('raw timestamp %r\n' % (cs.date,))
              if cs.branchpoints:
                  ui.write(('Branchpoints: %s \n') %
                           ', '.join(sorted(cs.branchpoints)))
2015-03-13 14:20:13 -04:00
Matt Mackall
7537e70971 merge with stable 2015-03-13 17:55:04 -05:00
Augie Fackler
cba17710b0 test-histedit-edit.t: demonstrate qnew fails during a histedit (issue4366)
This was accidentally fixed by other work, but given that it's been
broken in the past, I'd like to have a test defending us against
regressions in this area, especially as we add more functionality to
histedit.
2015-03-12 21:49:20 -04:00
Martin von Zweigbergk
ce0723ee16 lazymanifest: make __iter__ generate filenames, not 3-tuples
The _lazymanifest type(s) behave very much like a sorted dict with
filenames as keys and (nodeid, flags) as values. It therefore seems
surprising that its __iter__ generates 3-tuples of (path, nodeid,
flags). Let's make it match dict's behavior of generating the keys
instead, and add a new iterentries method for the 3-tuples. With this
change, the "x" in "if x in lm" and "for x in lm" now have the same
type (a filename string).
2015-03-12 18:18:29 -07:00
Pierre-Yves David
9d2643c9ed amend: check for directory renames for both merge parents (issue4516)
Before this change, amending a merge would lose the rename information for file
adding in the second parents and implicitly renamed into a new directory.

In case of the merge, we also look for directory rename data from the second
parent. This seems to fix the bug and does not show other issues from the test
suite.
2015-03-02 19:01:00 +00:00
Matt Harbison
721f888f2f transaction: really disable hardlink backups (issue4546) 2015-03-02 10:31:22 -05:00
Yuya Nishihara
29fb442439 ssl: set explicit symbol "!" to web.cacerts to disable SSL verification (BC)
The next patch will enable verification by using the system's CA store if
possible, which means we would have to distinguish None (=use default) from
'' (=--insecure). This smells bug-prone and provides no way to override
web.cacerts to forcibly use the system's store by --config argument.

This patch changes the meaning of web.cacerts as follows:

  value   behavior
  ------- ---------------------------------------
  None/'' use default
  '!'     never use CA certs (set by --insecure)
  <path>  verify by the specified CA certificates

Values other than <path> are for internal use and therefore undocumented.
2015-03-04 23:27:04 +09:00
Yuya Nishihara
6b95472c9c test-https: enable dummycert test only if Apple python is used (issue4500)
The dummycert trick works only if Python is linked to Apple's patched OpenSSL.
2015-03-04 22:41:48 +09:00