Commit Graph

25855 Commits

Author SHA1 Message Date
Gregory Szorc
83c1331bbb commands.push: use paths API
ui.path instances now collect most of the data used by commands.push().
Move away from ui.expandpath() and call ui.paths.getpath() to get a
path instance.

Some "pushing to" output was dropped as one test demonstrates. I believe
the dropped message was redundant with the error message and the change
to be acceptable.
2015-08-07 22:39:47 -07:00
Gregory Szorc
6ade48b23b ui: move URL and path detection into path API
ui.expandpath() has code for recognizing URLs or local filesystem
paths. Our goal is to use ``path`` class instances everywhere a path
is represented.

Changing ui.expandpath() to return path instances is a lot of work.
Our goal is to slowly marginalize it by moving logic into the paths
API and to convert callers to the paths API.

Many callers of ui.expandpath() pass in a value that could be a
local filesystem path or URI. We move the detection of these strings
from ui.expandpath() to paths.getpath() and path.__init__(). To do
this properly in a way that is compatible with future callers, we
need to parse the "#branch" syntax out of locations. This is a bit
complicated, but it is necessary.

The code for URL parsing is essentially a copy of hg.parseurl().
Once all consumers are speaking the paths API, it is likely that
this function won't be called any more and it can be deleted.
2015-08-08 00:16:02 -07:00
Yuya Nishihara
ecea4ee80c reachableroots: return list of revisions instead of set
Now we don't need a set of reachable revisions, and the caller wants a sorted
list of revisions, so constructing a set is just a waste of time.

  revset #0: 0::tip
  2) 0.002536
  3) 0.001598  63%

PyList_New() should set an appropriate exception on error, so we don't need
to call PyErr_NoMemory() manually.

This patch lacks error handling of PyList_Append() as it was before for
PySet_Add(). It should be fixed later.
2015-08-14 15:52:19 +09:00
Yuya Nishihara
72474b8722 reachableroots: use internal "revstates" array to test if rev is reachable
This is faster than using PySet_Contains().

  revset #0: 0::tip
  1) 0.003678
  2) 0.002536  68%
2015-08-14 15:49:11 +09:00
Yuya Nishihara
7f0aba37f0 reachableroots: use internal "revstates" array to test if rev is a root
The main goal of this patch series is to reduce the use of PyXxx() function
that is likely to require ugly error handling and inc/decref. Plus, this is
faster than using PySet_Contains().

  revset #0: 0::tip
  0) 0.004168
  1) 0.003678  88%

This patch ignores out-of-range roots as they are in the pure implementation.
Because reachable sets are calculated from heads, and out-of-range heads raise
IndexError, we can just take out-of-range roots as unreachable. Otherwise,
the test of "hg log -Gr '. + wdir()'" would fail.

"heads" argument is changed to a list. Should we have to rename the C function
as its signature is changed?
2015-08-14 15:43:29 +09:00
Augie Fackler
7b20700303 parsers: set exception when there's too little string data to extract parents
Previously we were returning NULL from this function without actually
setting up an exception. This fixes that problem, which was detected
with cpychecker.
2015-08-18 16:40:10 -04:00
Augie Fackler
71f1912b43 parsers: drop spurious check of readlen value
We're about to check if len < 40 after assigning readlen to len, which
means that if len < 40 we'll still abort, but I'm about to add a
sensible exception to that failure, so let's just discard this useless
check.
2015-08-18 16:39:26 -04:00
Augie Fackler
f28f2e0f50 pathencode: check result of .digest() method in sha1hash
Without this it was theoretically possible .digest() would fail and
return NULL but we wouldn't notice. Detected with cpychecker.
2015-08-18 16:32:41 -04:00
Augie Fackler
d203bdeed3 parsers: correctly decref normed value after PyDict_SetItem
Previously we were leaving this PyObject* with a refcount that was one
too high. Detected with cpychecker.
2015-08-18 16:43:26 -04:00
Augie Fackler
b4e44876ff parsers: fix two leaks in index_ancestors
Both happy paths through this function leaked the returned list:

1) If the list was of size 0 or 1, it was retained an extra time and then
   returned.

2) If the list was passed to find_deepest, it was never released before
   exiting this function.

Both paths spotted by cpychecker.
2015-08-18 17:15:04 -04:00
Matt Mackall
9bea9bc9bb merge with stable 2015-08-18 18:38:56 -05:00
Matt Mackall
fbcf862706 merge with i18n 2015-08-18 18:37:50 -05:00
Augie Fackler
dd2db8e9c7 test-convert-git: work around output format changes in git
git version 2.4.3:
--- /home/augie/hg/tests/test-convert-git.t
+++ /home/augie/hg/tests/test-convert-git.t.err
@@ -659,7 +659,7 @@
   $ touch a && git add a && git commit -am "commit a"
   [master (root-commit) 8ae5f69] commit a
    Author: nottest <test@example.org>
    1 file changed, 0 insertions(+), 0 deletions(-)
    create mode 100644 a
   $ cd ..
   $ git clone git-repo7 git-repo7-client

git version 1.7.9.5:
--- /home/augie/hg/tests/test-convert-git.t
+++ /home/augie/hg/tests/test-convert-git.t.err
@@ -659,7 +659,7 @@
   $ touch a && git add a && git commit -am "commit a"
   [master (root-commit) 8ae5f69] commit a
    Author: nottest <test@example.org>
-   1 file changed, 0 insertions(+), 0 deletions(-)
+   0 files changed
    create mode 100644 a
   $ cd ..
   $ git clone git-repo7 git-repo7-client

I don't know when this changed in git and am too lazy to try and
bisect it, so just work around the change.
2015-08-17 19:03:58 -04:00
Yuya Nishihara
fe0b1b769d reachableroots: extend "revstates" to array of bit flags 2015-08-14 15:30:52 +09:00
Yuya Nishihara
548434fd88 reachableroots: rename "seen" array to "revstates" for future extension
It will be an array of bit flags, SEEN | ROOT | REACHABLE.
2015-08-14 15:23:42 +09:00
Yuya Nishihara
8267d3bb5d reachableroots: give anonymous name to short-lived "numheads" variable
I'll reuse it for the length of the roots list.
2015-08-15 18:29:58 +09:00
Yuya Nishihara
8743607a4d reachableroots: reduce nesting level by jumping to next iteration by continue
This can eliminate lines over 80 columns. No code change except for the
outermost "if" condition.
2015-08-15 18:03:47 +09:00
Augie Fackler
25ce37007c histedit: correct spelling etc in more comments
Spotted during review of another patch.
2015-08-17 22:56:12 -04:00
Wagner Bruna
d9218da8c7 i18n-pt_BR: synchronized with 936c4f790419 2015-08-13 16:50:05 -03:00
Pierre-Yves David
be40ed237e rebase: lock the repo during the full rebase operation
Running `hg pull --rebase` would move bookmarks without any repository locking.
So we now lock the repository. For good measure and avoiding sneaky race
conditions, we lock the repository for the whole operation.

There is no code change besides the indentation.
2015-08-11 16:45:11 -07:00
Pierre-Yves David
4cfd7f9399 update: wlock the repo for the whole 'hg update' command
The update command is touching the repository and should lock it for
the length of its operations. Equally importantly, it should lock the
repository when it is writing bookmarks. It wasn't doing so until now,
leaving doors open for all kinds of drunk beaver parties.

This results in some minor tests changes, and the fixing of a couple
of bugs from race conditions.

Code does not receive any changes beside extra indentation.
2015-08-11 16:26:12 -07:00
Wagner Bruna
71656a9d4f help: fix typo in scripting documentation 2015-08-13 11:09:36 -03:00
FUJIWARA Katsunori
e919bf727c hg: avoid auto sharing when the clone destination is remote
Before this patch, when auto sharing is enabled, 'hg.clone()' tries to
create local clone regardless of locality of the clone destination on
the host, and causes failure.

To avoid auto sharing when the clone destination is remote, this patch
adds examination of 'islocal(dest)' before auto sharing in
'hg.clone()'.

'islocal(dest)' is examined after 'sharepool', because:

  - the former is more expensive than the latter
  - without enabling share extension, the later is always negative
2015-08-13 15:07:07 +09:00
Matt Harbison
dd27c92fee largefiles: ensure lfutil.getstandinmatcher() only matches standins
Previously, simply having the largefiles extension loaded without any largefiles
added would crash when amending with -I.  The problem was with no files in the
matcher, the pattern list of files joined with 'standindir' was empty, and
scmutil.match() would match everything.  In lfutil.composestandinmatcher(), the
match function is used to test if the file is a standin, and after getting a
false positive, proceeds to call lfutil.splitstandin().  This returns None
because it isn't a standin, which blows up when passed to rmatcher.matchfn().

Manually overriding _always in getstandinmatcher() probably isn't necessary
anymore, but we leave well enough alone on stable.  This regressed in
78632d61a993.
2015-08-12 12:26:39 -04:00
Pierre-Yves David
618daeb9ac strip: use the 'finally: tr.release' pattern during stripping
The previous code, was calling 'abort' in all exception cases. This was wrong
when an exception was raised by post-close callback on the transaction. Calling
'abort' on an already closed transaction resulted in a error, shadowing the
original error.

We now use the same pattern as everywhere else. 'tr.release()' will abort the
transaction if we escape the scope without closing it. We add a test to make
sure we do not regress.
2015-08-08 14:50:03 -07:00
Matt Harbison
3c940eb21b match: fix a caseonly rename + explicit path commit on icasefs (issue4768)
The problem was that the former name and the new name are both normalized to the
case in dirstate, so matcher._files would be ['ABC.txt', 'ABC.txt'].
localrepo.commit() calls localrepo.status(), passing along the matcher.  Inside
dirstate.status(), _walkexplicit() simply grabs matcher.files() and processes
those items.  Since the old name isn't present, it is silently dropped.  There's
a fundamental tension here, because the status command should also accept files
that don't match the filesystem, so we can't drop the normalization in status.
The problem originated in d70aa474bd84.

Unfortunately with this change, the case of the old file must still be specified
exactly, or the old file is again silently excluded.  I went back to
d70aa474bd84^, and that had the same behavior, so we are no worse off.  I'm open
to ideas from a matcher or dirstate expert on how to fix that half.
2015-08-06 21:00:16 -04:00
Durham Goode
8f62a68933 convert: fix git copy file content conversions
There was a bug in the git convert code where if you copied a file and modified
the copy source in the same commit, and if the copy dest was alphabetically
earlier than the copy source, the converted version would use the copy dest
contents for both the source and the target.

The root of the bug is that the git diff-tree output is formatted like so:

:<mode> <mode> <oldhash>    <newhash>    <state> <src>   <dest>
:100644 100644 c1ab79a15... 3dfc779ab... C069    oldname newname
:100644 100644 c1ab79a15... 03e2188a6... M       oldname

The old code would always take the 'oldname' field as the name of the file being
processed, then it would try to do an extra convert for the newname. This works
for renames because it does a delete for the oldname and a create for the
newname.

For copies though, it ends up associating the copied content (3dfc779ab above)
with the oldname. It only happened when the dest was alphabetically before
because that meant the copy got processed before the modification.

The fix is the treat copy lines as affecting only the newname, and not marking
the oldname as processed.
2015-08-06 17:21:46 -07:00
Yuya Nishihara
6bf30cb038 revset: prevent crash caused by empty group expression while optimizing "or"
An empty group expression "()" generates None in AST, so it should be tested
before destructuring a tuple.

"A | ()" is still evaluated to an error because I'm not sure whether "()"
represents an empty set or an empty expression (= a unit value). They are
identical in "or" operation, but they should be evaluated differently in
"and" operation.

  expression  empty set  unit value
  ----------  ---------  ----------
  ()          {}         A
  A & ()      {}         A
  A | ()      A          A
2015-08-09 16:09:41 +09:00
Yuya Nishihara
1ebcb08eb6 revset: prevent crash caused by empty group expression while optimizing "and"
An empty group expression "()" generates None in AST, so the optimizer have
to test it before destructuring a tuple. The error message, "missing argument",
is somewhat obscure, but it should be better than crash.
2015-08-09 16:06:36 +09:00
Anton Shestakov
6a4a921104 filesets: ignore unit case in size() predicate for single value
When specifying one plain value in size(), e.g. size(1k), fileset tries to
guess the upper bound automatically (see the comment in _sizetomax()). It
didn't ignore the specified unit's case, and so size("1 GB"), for example,
produced this error:

hg: parse error: couldn't parse size: 1 GB

Let's do the same thing that util.sizetoint() does: .lower().

The two test lines without output just check that there are no parse errors.
2015-08-08 14:42:27 +08:00
Laurent Charignon
c906fe19bb parsers: fix memory leak in compute_phases_map_sets
PySet_Add increments the reference of the added object to the set, see:
https://hg.python.org/cpython/file/2.6/Objects/setobject.c#l379
Before this patch we were forgetting to decrement the reference count after
adding objects to the phaseset. This patch fixes the issue and makes the
reference count right so that these objects can be properly garbage collected.
2015-08-06 22:54:28 -07:00
Javi Merino
32400ff369 help: fix typo familar -> familiar 2015-08-03 20:34:36 +01:00
Pierre-Yves David
6b2961e47a histedit: backout 3e883e7ec57b
The faulty changeset use obsolescence marker to roll the repository back on
--abort. This is a problematic approach because --abort should be as close as an
actually transaction rollback as possible stripping all created data from the
repository (cf `hg rebase --abort` stripping all created changesets). Instead
3e883e7ec57b made all content created during the aborted histedit still
available in the repository adding obsolescence marker to make them hidden. This
will cause trouble to evolution user as a re-run of the same histedit (with
success) will likely result in the very same node to be "recreated" while
obsolescence marker would be in place for them. And canceling an obsoletion is
still a fairly complicated process.

This also rollback using obsmarkers instead of strip to clean up temporary node
on successful histedit run because the two change were not split in separated
changeset. Rolling that part back does not have significant consequence a will
have to be resubmitted independently
2015-07-31 15:11:07 -07:00
Pierre-Yves David
d1822462df histedit: add a missing "s" in a comment 2015-07-31 12:54:16 -07:00
Durham Goode
e41971b2a5 convert: fix convert dropping p2 contents during filemap merge
When converting a merge commit using a filemap convert (i.e. when moving
contents from the root of the repo into subdir1/), convert would silently drop
the entire contents of the target repo's p2. This was because when it built the
target commit, it did so by taking the target p1 and adding only the files that
changed in the source repo's merge commit.

This breaks in the case where the target repo has files that are unrelated to
the source repo (like in the case where you use convert to import a repo as a
subdirectory of another).

The fix is to use Mercurial's merge logic to detect which files in p2 we should
carry over to the merge. It follows three rules:

1) if the file belongs to the source, don't try to merge it. Rely on the list of
files provided to putcommit to be correct.

2) if the file requires merging or user input (change vs deleted), throw an
exception. We don't have enough info to do this.

3) if p2 has the newest, non-merge-requiring version of the file, take it

I've also added a test to cover this issue.
2015-08-14 15:22:47 -07:00
Durham Goode
447360b0c9 convert: implements targetfilebelongstosource for filemap source
This is an implementation of the new targetfilebelongstosource() function for
the filemapper. It simply checks if the given file name is prefixed by any of
the rename destinations.

It is not a perfect implementation since it doesn't account for the filemap
specifying includes or excludes, but that makes the problem much harder, and
this implementation should suffice for most cases.
2015-08-15 13:46:30 -07:00
Durham Goode
a17be08d31 convert: add function to test if file is from source
This adds a base implementation of a function that tests if a given file from a
target repo came from the source repo. This will be used later to detect which
files did not come from the source repo during a merge, so we can merge those
files correctly instead of dropping them.
2015-08-15 13:44:55 -07:00
Yuya Nishihara
da13a040c4 revsetbenchmarks: run make after update so that C extensions are built 2015-08-15 17:50:59 +09:00
Yuya Nishihara
dd91337869 reachableroots: fix memleak of integer objects at includepath loop
In the first visit loop, val is decref-ed correctly after PySet_Add().
Let's do the same for the includepath loop.
2015-08-14 12:36:41 +09:00
Yuya Nishihara
814039db26 reachableroots: bail if integer object cannot be allocated
This patch also replaces Py_XDECREF() by Py_DECREF() because we known "val"
and "p" are not NULL.

BTW, we can eliminate some of these allocation and error handling of int objects
if the internal "seen" array has more information. For example,

  enum { SEEN = 1, ROOT = 2, REACHABLE = 4 };
  /* ... build ROOT mask from roots argument ... */
  if (seen[revnum + 1] & ROOT) {  /* instead of PySet_Contains(roots, val) */

>From my quick hack, it is 2x faster.
2015-08-14 12:31:56 +09:00
Laurent Charignon
6644ede114 devel-warn: issue a warning when writing bookmarks without holding the wlock
I saw an issue in an extension that we develop where we were writing bookmarks
without holding the wlock. Another extension was taking a lock at the same time
and wiped out the bookmarks we were about to write. This patch adds a
devel-warning to urge people to fix their invalid code.
2015-08-01 05:43:39 -07:00
Matt Mackall
155b19726c merge with stable 2015-08-13 19:37:47 -05:00
Durham Goode
099689de6b dirstate: add --minimal flag to debugrebuilddirstate
On repositories with hundreds of thousands of files, hg
debugrebuilddirstate causes every dirstate entry to be marked lookup,
and the next hg status can take many minutes.

This adds a --minimal flag that allows us to only rebuild the parts of the
dirstate that are inconsistent. This follows two rules:

1) If a file is in the dirstate but not in the parent manifest, and it is not
marked 'add', it is busted and we should drop it.

2) If a file is not in the dirstate at all, but it is in the parent
manifest, it should be added to the dirstate and we need to mark it as
lookup.

This allows us to fix repositories where the dirstate doesn't match
the manifest much more quickly.

Tested by artificially adding bad dirstate entries (via code) for both cases
above.
2015-08-12 19:44:21 -07:00
FUJIWARA Katsunori
6e07d94050 tests: make filterpyflakes.py read target files relatively to cwd
Before this patch, 'filterpyflakes.py' reads target files relatively
to own location.

But this prevents third party tools from using it in own source tree,
because their files are placed separately from 'filterpyflakes.py'.

In fact, 'test-check-pyflakes.t', which is the only user of
'filterpyflakes.py', changes current working directory (cwd) to the
root of "test target" source tree before using it. Therefore,
composing the root of source tree in 'filterpyflakes.py' is redundant.

This patch makes 'filterpyflakes.py' read target files relatively to
cwd by invoking 'open()' without any path composition. This also
removes importing 'os' module, because there is no user of it after
this patch.

This is a one of preparation of issue4677.
2015-08-13 22:10:52 +09:00
Anton Shestakov
69b6eb9543 monoblue: remove duplicate font-family property from td.source 2015-08-11 13:48:57 +08:00
Anton Shestakov
23dddb305b monoblue: remove unused elements and related css
Since f9c487618909 and 9d5bd0e29076, when monoblue was introduced, the code
this patch removes was untouched. Presumably, there supposed to be nice
graphics in the screen corners, but there never were due to:

- the css being commented out
- ids of the elements and of the css selectors being different
- and the png files absent

The "corner" elements were unstyled and didn't affect the rest of the page, so
I think it's safe to remove all this.
2015-08-11 13:45:54 +08:00
Yuya Nishihara
8e8af6e090 revpair: restrict odd-range handling to top-level x:y expression (issue4774)
The odd-range hack was introduced by 9afcfbca1710 for backward compatibility,
but it was too widely applied. I've checked cmdutil.revpair() at 1.6, and
found that ".:", ":0" and ":" are also handled as pairs. So let's enable the
hack only for "x:y", "x:", "y:" and ":".

test-revset.t is updated because "tip^::tip^ or tip^" shouldn't be taken as
an odd range. This patch adds "tip^:tip^" instead.

This patch is written for the default branch because parse() of the stable
branch lacks compatibility hack for "foo+bar" tag. If we want to mitigate the
issue in stable, we can add something like "and '::' in revs[0]".
2015-08-13 16:15:43 +09:00
Yuya Nishihara
de0c78a969 revpair: update test to make a difference if odd range not handled specially
It was added at 9afcfbca1710, but there was no difference between -r2 and -r2:2
because the working directory was clean.
2015-08-13 16:27:32 +09:00
Yuya Nishihara
1566598e14 reachableroots: verify type of each item of heads argument
Though PyInt_AS_LONG() can return a value no matter if it isn't an int object,
it could exceed the boundary of the underlying struct. I think C API should be
defensive to such errors.
2015-08-13 18:59:49 +09:00
Yuya Nishihara
01d4a46e15 reachableroots: verify integer range of heads argument (issue4775)
Now it raises IndexError instead of SEGV for 'wdir()' as it was before.
2015-08-13 18:38:46 +09:00