Commit Graph

283 Commits

Author SHA1 Message Date
Kevin Bullock
bfd557c35b wlock: use non-context-manager form to restore older hg support 2017-07-24 15:07:44 -05:00
Ryan McElroy
d5704aea60 bookmarks: compatibility with new applychanges api
Recent versions of mercuiral issue a devel-warn if the old recordchange api is
used, but we want to remain backwards-compatible, so this patch refactors things
to be forward-compatible and backwards-compatible.
2017-07-19 05:51:44 -07:00
Durham Goode
cab9b9ec84 wlock: take wlock when writing map file
Upstream Mercurial now has a devel-warning when writing to a file without taking
a lock. Since we already need write access to write the map file, let's take the
wlock as well.
2017-07-17 05:49:23 -07:00
Stanislau Hlebik
c9efe03607 git_handler: explicitly set default branch
In upstream 4b674dc38eeae9fa5e7794da8dc951ebadc23877 there was a refactoring
that caused current named branch to be set if branch wasn't specified. It makes
hg-git tests fail. This diff fixes it by explicitly specifying default named
branch.
2017-06-09 05:49:23 -07:00
Durham Goode
7ddcbbea43 vfs: stop using repo.join/wjoin
Mercurial 4.3 has completelu dropped the join and wjoin functions. Let's use the
appropriate repo.vfs.join and repo.wvfs.join functions instead.

I ran the tests against each version of Mercurial from 2.8 to 4.2. Things
before 2.8 seem to already be broken for unrelated reasons.
2017-05-09 14:33:28 -07:00
Durham Goode
cd4e952326 repo: update repo.join to be repo.vfs.join
Upstream has deprecated repo.join in favor of repo.vfs.join, so let's update to
match them. Old hg should have repo.vfs.join so I don't think this breaks
backwards compatibility.
2017-03-15 13:37:02 -07:00
Arun Kulshreshtha
323fb1f35d git_handler: replace repo.opener with repo.vfs
repo.opener() is now deprecated, so repo.vfs() should be used instead.
2017-03-09 12:33:05 -08:00
timeless@gmail.com
6dd940343e githandler: replace ref with bookmark
Mercurial users are using bookmarks to represent git refs, so when
we are unable to push a git ref to remote, we need to tell
the hg user to add a bookmark (something they understand),
instead of mentioning a ref (which is a foreign concept to them).
2016-11-01 22:20:03 +00:00
Sean Farley
4e76ea0666 git_handler: use remote HEAD for cloned bookmark (BC)
Tests have been updated for new behavior.
2016-01-08 14:02:20 -08:00
Sean Farley
5544f7a66e git_handler: use our read_pkt_refs for fetch_pack 2015-05-15 11:40:49 -07:00
Ryan McElroy
92731f9aa3 githandler: respect mapsavefrequency during export
When importing changesets, hggit uses the config knob hggit.mapsavefrequency to
determine how often to save the mapfile. This allows a user to interrupt the
import without losing all progress.

This patch adds this same functionality to the export mechanism.
2016-10-03 04:43:48 -07:00
Ryan McElroy
10a129544d stop dying if extras is malformed
A commit's extras field should be considered user-supplied input that can take
any form. Trusting it to be properly formatted is dangerous and can prevent
forward progress. Instead, swallow errors due to malformed extras and carry on.
2016-09-05 03:04:24 -07:00
Ryan McElroy
9c40cc4ed3 add progress to commit discovery phase
In large repositories, the commit discovery phase can take minutes. Let's give
the user feedback on how long it will take.
2016-09-05 03:03:24 -07:00
Sean Farley
7e5aa53a36 git_handler: use compat.passwordmgr for hg < 3.9 support 2016-08-04 14:16:44 -07:00
Dan Villiom Podlaski Christiansen
dec685e598 git_handler: detect and reject nested Mercurial repositories
The ReviewBoard repository contains a Mercurial repository within its
Git repository; if you just convert that into Mercurial, you can't
check it out. We handle this similar to invalid Git paths: by default,
refuse the conversion, but with a configuration knob to force it
through with a warning.

See also:

https://github.com/reviewboard/reviewboard/
https://reviewboard.org/bugs/3190
2016-02-04 13:33:32 +01:00
Sean Farley
401a99e1cf push: better formatting of messages from the server 2016-01-11 16:28:28 -08:00
Sean Farley
868bf2a374 git_handler: use util method for writing bookmarks 2016-01-08 13:59:39 -08:00
Augie Fackler
2ee07e0b3b git_handler: work around dulwich using unicode for ref names
Dulwich treats ref names internally as unicode strings (probably
because of Python 3?), which means that at some points it tries to do
os.path.join between the repo path and the unicode of the ref name,
which fails miserably if we construct the repo with a str and not a
unicode. Kludge around this problem.

Fixes issue 172.

This is a roll-forward of 3df4d529a2f2, which should be valid now that
the previous change defends against accidentally writing unicode tags
inside the templater.
2015-12-31 18:49:17 -05:00
Siddharth Agarwal
6b44a596c9 merge 2015-12-31 12:45:30 -08:00
Siddharth Agarwal
bd7830175b git_handler: regularize mercurial imports 2015-12-31 12:25:00 -08:00
Laurent Charignon
4ea775d1ba bookmarks: use bookmarks.recordchange instead of bookmarks.write if available
bookmarks.write is deprecated and it was showing warning messages in
test-hg-branch.t with the latest test runner from core mercurial. Tested with
both hg 2.8 and hg tip.
2015-12-30 10:27:24 -08:00
timeless@gmail.com
14a00dff5c init: handle AttributeError in addition to ImportError
If a module doesn't exist, it yields an ImportError,
if an attribtue doesn't exist on a module, it yields an AttributeError
2015-12-29 18:06:14 +00:00
Sean Farley
37c52e3cab push: print messages from the server
Some servers, for example, Bitbucket, output helpful messages. This patch
reports the output, if any exist, to the user.
2015-12-02 17:26:20 -08:00
Siddharth Agarwal
cfe9c6dc8a Backed out changeset 3df4d529a2f2
This was causing test-encoding.t to fail.
2015-12-01 10:19:50 -08:00
Augie Fackler
28aa302374 git_handler: work around dulwich using unicode for ref names
Dulwich treats ref names internally as unicode strings (probably
because of Python 3?), which means that at some points it tries to do
os.path.join between the repo path and the unicode of the ref name,
which fails miserably if we construct the repo with a str and not a
unicode. Kludge around this problem.

Fixes issue 172.
2015-11-25 17:52:59 -05:00
Siddharth Agarwal
6993d261f6 determine_wants: deal with refs being None
Not clear how this is happening, but this should fix it.

Resolves issue #166.
2015-11-08 21:56:38 -08:00
Sean Farley
12c6012084 update_hg_bookmarks: add wlock 2015-09-24 16:24:27 -07:00
Sean Farley
22991894df git_handler: rename local variable to not shadow import name 2015-05-14 15:15:37 -07:00
Sean Farley
beecd28ea0 git_handler: remove pre-2.8 code for bookmarks 2015-05-15 14:02:55 -07:00
Sean Farley
ef7fa85796 push: use unfiltered repo for looking previously mapped nodes
It looks like this is the only place where this could happen via this
map_hg_get function.
2015-04-27 16:51:27 -07:00
Sean Farley
39fa028455 refs: avoid using dulwich to load refs
We avoid using dulwich's refs method because it is incredibly slow. On a repo
with a few hundred branches and a few thousand tags, dulwich took about 200ms
to load everything.

This patch only traveses the remote ref directory and cuts that time down to
about 50ms.
2015-09-24 14:06:36 -07:00
Sean Farley
6bc1a87edc refs: use dulwich to read remote refs
It is unclear to me why we keep a file (which can become out of sync) of remote
refs instead of just using dulwich. This caught a missing remote ref in the
test suite.
2015-05-16 19:43:26 -07:00
Sean Farley
4d5f0b97d4 git_handler: test for a raw git ssh uri
By testing the uri early, we can reuse logic later in the method to parse the
git uri. We rely on the isgitsshuri heuristic to return True or False, and if
True, prepend 'git+ssh://' to the uri.

Arguably, this is fragile, and am open to better ideas, but can't think of
anything else currently.
2015-06-26 16:32:20 -07:00
Sean Farley
96e32e85c0 import_git_commit: skip hgsubstate logic if file was deleted
Previously, there was an edge case for Git repositories that started as
Mercurial repositories and had used subrepos where a deleted .hgsubstate would
be ignored and therefore reintroduced.

This patch fixes that behavior by checking for the deleted .hgsubstate file
first.

A test has been added to verify behavior.
2015-06-13 18:03:34 -07:00
Durham Goode
594789d17b gitimport: add save frequency config
If the importer encountered an error half way through a large import, all the
commits are saved, but the mapfile is not written, so the process starts over
from the beginning when run again.

This adds the option for a config value that will save the map file every X
commits. I thought about just hard coding this to 100 or something, but doing it
this way seems a little less invasive.
2015-06-11 13:56:16 -07:00
Durham Goode
abb733905a pull: consider remotes during discovery
The default dulwich graph walker only walks from refs/heads. During the
discovery phase of fetching this causes it to redownload commits that are only
referenced by refs/remotes. In a normal hggit case, this seems to mean it
redownloads the entire git repo on every hg pull.

Added a --debug to a test to check the object count (it decreased from 21 to 10
as part of this patch).
2015-06-23 20:17:10 -07:00
Gregory Szorc
c0465bda87 git_handler: properly handle paths when files converge
filectx.renamed() returns a 2-tuple or None. memfilectx.__init__ expects
the copied argument to be either None or a string. Before, we were
passing a 2-tuple, leading to the memfilectx storing the wrong type.
This eventually resulted in doing a key lookup against a manifest
with a 2-tuple, which made manifest.c throw an error.
2015-05-14 12:51:37 -07:00
Sean Farley
057929f2ba git_handler: update for bookmark changes in mercurial 3.5 2015-05-12 17:05:13 -07:00
Sean Farley
30ae373e3c git_handler: remove unused variables 2015-04-15 18:37:37 -04:00
Sean Farley
2a2d57d708 git_handler: whitespace and formating changes
All errors found with flake8.
2015-04-15 18:31:06 -04:00
Sean Farley
283ba31ae9 git_handler: remove dead imports and put them on multiple lines 2015-04-15 16:10:15 -04:00
Siddharth Agarwal
f4e95251f9 git_mapfile.save_map: stop sorting the keys entirely
There really is no point to this -- the sorting is expensive to compute and
the structure is never actually used.

For a mapfile with 1.5 million entries, this speeds up save_map from 3.6
seconds to 0.87.

This is probably the limit of the speedups we can get with pure-Python code.
Any further speedups will have to be made by rewriting these bits in C.
2015-04-09 21:15:20 -07:00
Siddharth Agarwal
520f944b25 git_handler: move cStringIO to a global import
There are a couple of places that use StringIO for the added features it has
over cStringIO, so we can't replace all its uses wholesale.
2015-04-13 08:03:57 -07:00
Siddharth Agarwal
621b383912 git_handler.save_map: buffer the output
For a mapfile with 1.5 million entries, this speeds up save_map from 3.5
seconds to 3.1.
2015-04-09 20:50:26 -07:00
Siddharth Agarwal
ae7b2070ac git_handler.save_map: don't sort list of tuples
Sorting a list of tuples is much more expensive than sorting a list of strings.

For a mapfile with 1.5 million entries, this speeds up save_map from 6 seconds
to 3.5.
2015-04-09 20:39:53 -07:00
Siddharth Agarwal
0596ac290a git_handler.save_map: pass in the map file explicitly for easier testing 2015-04-09 20:24:10 -07:00
Siddharth Agarwal
1a15adc3e0 git_handler.load_map: avoid split and strip
For a mapfile with 1.5 million entries, this speeds up load_map from 2.3
seconds to 1.8.
2015-04-09 20:14:33 -07:00
Siddharth Agarwal
6e87e0e982 git_handler.load_map: avoid property accesses
For a mapfile with 1.5 million entries, this speeds up perfgitloadmap from 2.5
seconds to 2.3.
2015-04-09 19:51:33 -07:00
Siddharth Agarwal
01dbae187f git_handler: reintroduce compatibility with dulwich 0.9.4 (issue124)
It's the version that ships with the latest Ubuntu LTS as of this writing.
2015-03-06 10:58:33 -08:00
Siddharth Agarwal
74287cb2d6 git_handler: stop exporting commits before performing a fetch
While this has been done since the beginning of time, there's no apparent
justification for it. If an imported commit works out to the same hash as an
existing one, it simply won't be added to the revlog.

The tests all continue to pass. There's already test coverage for reimporting
commits in test-pull-after-strip.t. Also, gimport has worked this way all this
while.
2015-03-04 23:52:11 -08:00