Commit Graph

265 Commits

Author SHA1 Message Date
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
Siddharth Agarwal
afdc4cc403 git_handler: don't store rename source if branch info is stored
Consider a Mercurial commit with hash 'h1'. Originally, if the only Mercurial
field stored is the branch info (which is stored in the commit message rather
than as an extra field), we'd store the rename source explicitly as a Git extra
field -- let's call the original exported hash 'g1'.

In Git, some operations throw all extra fields away. (One such example is a
rebase.) If such an operation happens, we'll be left with a frankencommit with
the branch info but without the rename source. Let's call this hash 'g2'. For a
setup where Git is the source of truth, let's say that this 'g2' frankencommit
is what gets pushed to the server.

When 'g2' is subsequently imported into Mercurial, we'd look at the fact that
it contains a Mercurial field in the commit message and believe that it was a
legacy commit from the olden days when all info was stored in the commit
message. In that case, in an attempt to preserve the hash, we wouldn't store
any extra rename source info, resulting in 'h1'. Then, when the commit is
re-exported to Git, we'd add the rename source again and produce 'g1' -- and
thus break bidirectionality.

Prevent this situation by not storing the rename source if we're adding branch
info to the commit message. Then for 'h1' we export as 'g2' directly and never
produce 'g1'.

What happens if we not only need to store branch info but also other extra
info, like renames? For 'h1' we'd produce 'g1', then it'd be rewritten on the
Git side to 'g2' throwing away all that extra information. 'g2' being
subsequently imported into Mercurial would produce a new hash, say 'h2'. That's
fine because the commit did get rewritten in Git. We unfortunately wouldn't
perform rename detection thinking that the commit is from Mercurial and had no
renames recorded there, but when the commit is re-exported to Git we'd export
it to 'g2' again. This at least preserves bidirectionality.
2015-02-26 22:14:44 -08:00
Siddharth Agarwal
6232b82c9f git_handler: handle case where file is renamed and replaced by a symlink
This edge case that rename detection introduces wasn't handled previously --
the file would be renamed but the symlink wouldn't be added.
2015-02-26 17:37:20 -08:00
Augie Fackler
de2efcf3f2 git_handler: slight style cleanup for previous patch 2015-02-23 09:58:01 -05:00
Jelmer Vernooij
fb74586b8b Allow for dulwich to not return the magic "capabilities^{}" ref. 2015-02-23 09:56:21 -05:00
Paul Chen
e0b24be7bc git_handler: Fix extra bookmark created after pushed to empty remote repo. 2015-02-21 14:49:43 +08:00
Siddharth Agarwal
8db62b55cf git_handler: handle symlink <-> regular file transitions properly
See comment inline for explanation. Also add tests for this (the bug was masked
with rename detection disabled -- it only appeared with rename detection
enabled).
2014-12-30 13:25:55 -08:00
Siddharth Agarwal
e7b4906871 git_handler: mark source for rename info as Git or Mercurial
See inline comments for why the additional metadata needs to be stored.

This literally breaks all the hashes because of the additional metadata. The
changing of hashes is unfortunate but necessary to preserve bidirectionality.

While this could be broken up into multiple commits, there was no way to do
that while preserving bidirectionality. Following the principle that every
intermediate commit must result in a correct state, I decided to combine the
commits.
2014-12-02 14:17:09 -08:00
Siddharth Agarwal
9df74aef3e git_handler.get_files_changed: detect renames when asked to do so
We use Dulwich's rename detector to detect any renames over the specified
similarity threshold.

This isn't fully bidirectional yet -- when the commit is exported to Git
the hashes will no longer be the same. That's why that isn't tested here. In
upcoming patches we'll make sure it's bidirectional and will add the
corresponding tests.
2014-12-02 15:57:21 -08:00
Siddharth Agarwal
cb2138b97c git_handler.get_files_changed: return detected renames
We currently return an empty dictionary -- we'll fill it in upcoming patches.
2014-12-02 15:04:50 -08:00
Siddharth Agarwal
4ddee10f62 git_handler: add a way to get a rename detector
This will be used to detect renames in upcoming patches.
2014-12-02 14:53:11 -08:00
Siddharth Agarwal
3ff3a9e433 git_handler.get_files_changed: switch to diff_tree's tree_changes
object_store.tree_changes doesn't allow us to specify a rename detector, but
diff_tree's tree_changes does.
2014-12-01 23:25:25 -08:00
Siddharth Agarwal
eee3a8a81e git_handler.import_git_commit: figure out when to detect renames
get_files_changed doesn't do anything with this yet, but it will in upcoming
patches.
2014-12-01 21:18:34 -08:00
Siddharth Agarwal
ac7bb7b951 git_handler.import_git_commit: rename 'hg_renames' to 'renames'
In upcoming patches we'll add other sources of renames.
2014-12-01 21:12:45 -08:00
Siddharth Agarwal
d1797f25d6 git2hg: while extracting metadata, detect which VCS commits were made in
This is currently a heuristic -- it'll be made more reliable in upcoming
patches.
2014-12-01 20:16:24 -08:00
Siddharth Agarwal
94b7e645fa git_handler.export_git_objects: avoid unnecessary list creation
These are used just once, so generators are fine for them.
2014-11-30 00:46:58 -08:00
Siddharth Agarwal
0f6841f47b git_handler.export_git_objects: filter out octopus explosions earlier
hg-git translates octopus merges into a series of merges, called an octopus
explosion. The intermediate octopus explosion commits are not recorded in
the mapfile -- only the final commit is. This means that they show up in the
export list and have to then be detected and filtered out.

Don't initialize the incremental exporter with octopus explosion commits.
Previously, if there were octopus merges early in the history, we'd initialize
the incremental exporter with the first one's parent, then calculate the diff
of that against the first commit we actually cared about exporting. That's slow
and wasteful.

For a particular real-world repo with one octopus merge 1/3 of the way in
history, this is a 10x improvement for 'hg gexport' with one commit to export
-- 60 seconds to 6.
2014-11-30 00:42:30 -08:00
Siddharth Agarwal
8ab3734764 git_handler: iterate over contexts, not nodes
This prepares for an upcoming patch.

In theory, we could pass the context into export_hg_commit, but there's some
encoding shenanigans going on there that I don't want to delve into.
2014-11-30 00:26:24 -08:00
Siddharth Agarwal
abfba0b8e3 git_handler.filter_min_date: support tag times for annotated tags
Previously we'd crash on annotated tags because they don't have a 'tag_time'
property.
2014-11-04 13:56:00 -08:00