Commit Graph

137 Commits

Author SHA1 Message Date
Siddharth Agarwal
36052aca77 git_handler: note that new commits are returned in topo order
This wasn't obvious to me at first.
2014-02-18 20:13:15 -08:00
Siddharth Agarwal
5e72b26e7b git_handler: fix progress reset call 2014-02-16 01:13:10 -08:00
Siddharth Agarwal
298fec2a4b git_handler: use repo.changelog.node instead of repo.lookup
For a repo with over 50,000 commits, this brings down the computation of
'export' from 1.25 seconds to 0.25 seconds.

To scale this to hundreds of thousands of commits, one solution might be to
maintain the mapping in a DAG data structure mirroring the changelog, over
which findcommonmissing can be used.
2014-02-16 01:11:47 -08:00
Siddharth Agarwal
94957f9a66 git_handler: remove collect_gitlinks now that it is unused 2014-02-15 16:21:49 -08:00
Siddharth Agarwal
8d0c4fe9f2 git_handler: fix hgsubstate generation
Before this patch, in the git to hg conversion, .hgsubstate once created is
never deleted, even if no submodules are any longer present. This is broken
state, as shown by the test for which the SHA changes. Fix that by looking at
the diff instead of just what submodules are present.

Since 'gitlinks' now contains *changed* gitlinks, not *all* gitlinks, it no
longer makes sense to gate gitmodules checks on that.

This patch simply demonstrates that the test was broken; an upcoming patch will
introduce more tests.

Bonus: this also makes the import process faster because we no longer need to
walk the entire tree to collect gitlinks.

This will cause the SHAs of repos that have submodules added and then removed
to change.
2014-02-14 15:44:50 -08:00
Siddharth Agarwal
94f67b719d git_handler: move check for gparents in repo to start of import_git_commit
Also drop Mercurial < 1.5 support.
2014-02-14 16:16:25 -08:00
Siddharth Agarwal
82b4618e1f git_handler: move gparents initialization up to start of import_git_commit
gparents will be used to compute .hgsubstate in an upcoming patch.
2014-02-14 13:15:45 -08:00
Siddharth Agarwal
35411ae613 git_handler: return gitlinks in get_files_changed
Currently, to figure out which gitlinks are in a repository we walk through the
entire tree. This patch lets us use get_files_changed to detect which gitlinks
have changed.
2014-02-14 11:31:54 -08:00
Dov Feldstern
97838c2daf fallback to unauthenticated http(s) access when using older dulwich 2014-02-13 02:00:18 +02:00
Dov Feldstern
7e0c3b141b support for http(s) basic authentication
This is an adaptation of the original patch submitted in [1], without the
monkey-patching: a patch has been committed in dulwich [2] which allows clients
to supply a custom urllib2 "opener" for opening the url; here, we provide such
an opener, which provides authentication information obtained from the hg
config.

[1] https://groups.google.com/forum/#!topic/hg-git/9clPr1wdtiw
[2] https://bugs.launchpad.net/dulwich/+bug/909037
2014-02-13 01:37:22 +02:00
Siddharth Agarwal
a06bbdeeac git_handler: don't bail on multiple octopus merges in succession
Consider two octopus merges, one of which is a child of the other. Without this
patch, get_git_parents() called on the second octopus merge checks that each p1
is neither in the middle of an octopus merge nor the end of it. Since the end
of the first octopus merge is a p1 of the second one, this asserts.

Change the sanity check to only make sure that p1 is not in the middle of an
octopus merge.
2014-02-11 22:13:34 -08:00
anatoly techtonik
a09eed97b0 git_handler.py: less cryptic error message when push fails 2013-12-15 15:19:22 -05:00
Augie Fackler
6d7d1ac665 git_handler: iterate over new refs in sorted order to stabilize test output
An earlier patch already fixes the test expectations (oops), so this
just makes sure the tests always pass.
2013-12-13 13:02:08 -05:00
Jordi Gutiérrez Hermoso
adf3575aa8 git-handler: turn refs from None to {} so that empty git repos can convert 2013-12-03 16:55:17 -05:00
Augie Fackler
6f0e54cb16 Merge a work-around for a bug in dulwich.
I've been waiting for dulwich upstream to fix this *and* for a test
from domruf that's acceptable. Having gotten neither over a period of
/months/, and having hit the bug myself, I'm moving on and accepting a
patch without tests. This will likely break again, but hopefully
before we'd break it dulwich will be fixed.
2013-09-17 09:59:36 -04:00
Augie Fackler
df2fed070b git_handler: fix bugs introduced by 93aaff49e601 which could never have passed tests 2013-09-17 09:58:36 -04:00
Augie Fackler
3460706765 git_handler: clean up trailing whitespace 2013-09-17 09:58:12 -04:00
Augie Fackler
ff1e9014cf merge 2013-08-28 13:49:01 -04:00
nsuke
291493c743 git_handler: skip exporting hg tags whose names are not valid as git tag name 2013-08-12 23:20:41 +09:00
Risto Kankkunen
e3f5583d09 Make the path part of URL contain a leading slash only if it's not followed by tilde. (issue #71) 2013-07-11 00:22:07 +03:00
André Felipe Dias
071243136a Fixes #54 | option branch_bookmark_suffix doesn't move bookmarks along
Test case based on the one proposed by David Carr at
https://bitbucket.org/durin42/hg-git/issue/54/with-option-branch_bookmark_suffix-set
2013-07-01 16:04:53 -03:00
Gregory Szorc
baa19027ef Export Git objects from incremental Mercurial changes
This replaces the brute force Mercurial to Git export with one that is
incremental. It results in a decent performance win and paves the road
for parallel export via using multiple incremental exporters.
2013-03-19 22:44:01 -07:00
Hal Wine
e83de5b7dc scrub bad timezone values before dulwich sees them
If dulwich is presented with a "sub minute" timezone offset, it throws
an exception (see tests/test-timezone.t). This patch rounds the timezone
down to the next minute before passing the value to dulwich.
2013-02-05 08:25:37 -08:00
David M. Carr
114a8500cb push: provide better output about changed references (issue #64)
As pointed out by l33t, Hg-Git's output for push doesn't currently do a very
good job of telling the user what happened.  My previous changes in this area
had moved some of the output from status to note, making it only show if
--verbose was specified.  However, I hadn't realized at the time that the
reference information (though overly verbose) was providing a valueable purpose
that otherwise wasn't met; telling the user that a remote reference had changed.

This changeset makes it so that:
*   default output will include simple messages like "adding reference
    refs/heads/feature" and "updating reference refs/heads/master" (omitting any
    mention of unchanged references)
*   verbose output will include more detailed messages like "adding reference
    default::refs/heads/feature => GIT:aba43c" and "updating reference
    default::refs/heads/master => GIT:aba43c" (omitting any mention of unchanged
    references)
*   debug output will include the detailed output like in verbose, but
    addtionally will include messages like "unchanged reference
    default::refs/heads/other => GIT:aba43c"

https://bitbucket.org/durin42/hg-git/issue/64/push-confirmation
2013-01-06 02:31:37 -05:00
David M. Carr
a6e63bd878 push: add more output about what was added (issue #64)
l33t pointed out that currently, Hg-Git doesn't provide any confirmation that a
push was successful other than the exit code.  Normal Mercurial provides a
couple other messages followed by "added X changesets with Y changes to
Z files".  After this change, Hg-Git will provide much more similar output.
It's not identical, as the underlying model is substantially different, but the
concept is the same.  The main message is "added X commits with Y trees and
Z blobs".

This change doesn't affect the output of what references/branches were touched.
That will be addressed in a subsequent commit.

Dulwich doesn't provide an easy hook to get the information needed for this
output.  Instead of passing generate_pack_contents as the pack generator
function to send_pack, I pass a custom function that determines the "missing"
objects, stores the counts, and then calls generate_pack_contents (which then
will determine the "missing" objects again.

The new expected output:
searching for changes # unless quiet true
<N> commits found     # if verbose true
list of commits:      # if debugflag true and at least one commit found
<each hash>           # if debugflag true and at least one commit found
adding objects        # if at least one commit found unless quiet true
added <N> commits with <N> trees and <N> blobs # if at least one object unless
                                               # quiet true

https://bitbucket.org/durin42/hg-git/issue/64/push-confirmation
2013-01-06 01:46:57 -05:00
domruf
5d467e12d1 fix/work around https://bugs.launchpad.net/dulwich/+bug/1025886 2012-12-11 15:44:23 +01:00
Augie Fackler
5c9bcd81f4 Merge with master. 2012-11-23 20:20:48 -06:00
David M. Carr
4ad1b4bfde git_handler: add bookmark compatibility with new bmstore (issue #60)
Prior to this fix, tests against the latest hg codebase would fail with:
creating bookmarks failed, do you have bookmarks enabled?
2012-11-22 18:44:09 -05:00
Augie Fackler
3f40fa1ef5 Merge 2012-11-11 17:12:55 -06:00
Augie Fackler
2e95d380da git_handler: defend against unexported revisions in tag exporting 2012-11-11 15:46:19 -06:00
Augie Fackler
586391e789 Merge 2012-10-25 23:22:36 -05:00
David M. Carr
deba26ad93 push: suppress "exporting hg objects to git" message
When communicating with the user on push/outgoing, Mercurial doesn't show a
"exporting hg objects to git" message, so we shouldn't.  The message has been
changed to be shown if --verbose is specified.
2012-10-25 21:47:44 -04:00
David M. Carr
fb74ae0f84 push: suppress ref output by default
When communicating with the user on push, Mercurial doesn't show much on
success.  Currently, Hg-Git shows every changed ref.  After this change,
the default output will more closely match Mercurial's regular behavior (no
per-ref output), while changed refs will be shown if --verbose is specified,
and all refs will be shown if --debug is specified.
2012-10-25 21:47:36 -04:00
David M. Carr
7168922e8f gitrepo: initial support for listkeys
This changeset adds test coverage for comparing "hg outgoing -B" in normal
Mercurial usage with Hg-Git usage.  This didn't match, since previously, gitrepo
didn't provide a meaningful listkeys implementation.  Now, it does.

gitrepo now has access to a GitHandler when a localrepo is available.  This
handler is used to access the information needed to implement listkeys for
namespaces (currently, only bookmarks) and bookmarks.

A couple of other tests were testing "divergent bookmark" scenarios.  These
tests have been updated to filter out the divergent bookmark output, as it isn't
consistent across the supported Mercurial versions.
2012-10-25 20:49:08 -04:00
David M. Carr
92f7dd666e push: fix traceback when pushing empty hg repo to empty git repo (issue #58)
In the logic that was attempting to handle the case where the local repo doesn't
have any bookmarks, the assumption was being made that tip resolved to a
non-null revision.  In the case of a totally empty local repo, however, that
isn't a valid assumption, and resulted in attempting to set the master ref
to None, which broke dulwich.

The "fix", which avoids the traceback and allows the push to complete (though
still do nothing, since in this case there aren't any changes to push), is to
not tweak the refs at all if tip is nullid.  Leaving the special capabilities
ref and not adding a master ref appears to be fine in this case.
2012-10-25 00:40:35 -04:00
Jordi Gutiérrez Hermoso
8ab8c36d60 git_handler: replace with-statement with try-finally
Python 2.4 does not have a with-statement
2012-10-18 12:25:04 -04:00
Augie Fackler
9f2907f1f1 Merge 2012-10-17 10:59:42 -05:00
Augie Fackler
f8e6ed57b8 git_handler: lazy-load mapping
Loading the mapping was costing about half a second for a user on IRC
on the pidgin repo. There's no reason to load this data aggressively.
2012-10-17 10:50:55 -05:00
David M. Carr
33ac80b524 push: change "no changes" default output to match normal mercurial
The output for "hg push" when there were no changes didn't quite match between
Mercurial with and without Hg-Git, so I changed the behavior to bring it into
synch.  The existing "creating and sending data" message was changed to be
included if --verbose is specified.
2012-10-07 20:11:27 -04:00
David M. Carr
727eff8e96 outgoing: don't delete remote refs
There was a bug introduced in fa5f235be2cd such that calling hg outgoing on
a Git repository would result in all refs being deleted from the remote
repository (with the possible exception of the currently checked out branch).
It wasn't noticed before because the existing test for outgoing didn't actually
verify the refs on the remote.  This changeset fixes the bug, as well as adding
test coverage to allow verifying that the fix works.
2012-09-27 22:32:01 -04:00
Gregory Szorc
2d6677065b Verify tree and parent objects are in Git repo
When exporting Git commits, verify that the tree and parents objects
exist in the repository before allowing the commit to be exported. If a
tree or parent commit is missing, then the repository is not valid and
the export should not be allowed.
2012-09-21 20:26:26 -07:00
Gregory Szorc
2e7c57f121 Precompile author file regular expression 2012-09-21 19:43:50 -07:00
Gregory Szorc
a8e43072e2 Precompile Git progress regular expressions 2012-09-21 19:42:24 -07:00
Gregory Szorc
19caaa42b9 Precompile Git author extra data regular expression 2012-09-21 19:39:53 -07:00
Gregory Szorc
71b136cd70 Precompile Git username sanitizing regular expression 2012-09-21 19:36:57 -07:00
Gregory Szorc
029f0a2090 Precompile Git URI regular expression 2012-09-21 19:32:16 -07:00
Gregory Szorc
7ac8f5932a Optimize get_git_author
Pre-compile regular expression. Prevent extra key lookup in author_map.
2012-09-21 19:28:46 -07:00
David M. Carr
523efe6ee9 outgoing: re-introduce support for outgoing 2012-09-13 18:47:11 -04:00
Augie Fackler
fbc67fee2e Merge master into next. 2012-09-09 16:13:02 -05:00
David M. Carr
1b832796d9 push: state when no changes are found 2012-09-05 23:27:31 -04:00