Commit Graph

406 Commits

Author SHA1 Message Date
Siddharth Agarwal
178e6c9bdb overlaychangectx: use overlayrevlog logic to determine parents
The old logic was broken -- it didn't work at the boundary between hg and git
commits. The logic in overlayrevlog.parents handles that correctly.

This is the last fix required for Mercurial 3.4.
2015-05-08 15:50:48 -07:00
Siddharth Agarwal
fa1f56923a overlay: adapt diff to work with lazymanifests 2015-05-08 16:00:45 -07:00
Augie Fackler
c1d5202a78 pull: acquire wlock before lock to fix lock-checker warnings 2015-04-29 18:03:03 -04:00
Sean Farley
7f080a40f6 overlay: flake8 cleanup 2015-04-22 16:41:38 -07:00
Sean Farley
76f530f942 overlay: remove method that apparenetly was never called
This method had a syntax error that would have caused a crash.
2015-04-22 16:40:45 -07:00
Sean Farley
3b19ebc41e hg2git: flake8 cleanup 2015-04-22 16:42:48 -07:00
Sean Farley
89740bc8a4 gitdirstate: flake8 cleanup 2015-04-22 16:34:25 -07:00
Sean Farley
53945fe29d verify: flake8 cleanup 2015-04-22 16:31:11 -07:00
Sean Farley
1f2ea783f8 util: flake8 cleanup 2015-04-22 16:27:13 -07:00
Sean Farley
a8328e4738 gitrepo: flake8 cleanups 2015-04-22 16:25:04 -07:00
Sean Farley
5209dc41df ssh: move imports to top of file 2015-04-22 16:23:09 -07:00
Sean Farley
42a644d529 hgrepo: remove unused import 2015-04-22 16:21:51 -07:00
Sean Farley
0afb430516 init: whitespace and formating cleanup
Also cleans up some unused imports.
2015-04-17 12:52:27 -04:00
Sean Farley
c26b1ba406 hgrepo: whitespace and formatting cleanup 2015-04-16 10:34:57 -04: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
830312cb5f overlaychangectx: return nullrev if commit has no parents
In Mercurial, every commit has at least one parent -- root commits have the
null revision as their parent. In Git, root commits don't have any parents.
This difference needs to be papered over in hg-git for 'hg incoming' to work in
Mercurial 3.4+.

Note that this doesn't fix all the broken tests in default -- I haven't had
time to investigate the others.
2015-04-03 11:18:30 -07:00
Siddharth Agarwal
db378d8134 gitdirstate: use normalized path from _walkexplicit
Since cce24e8019c8 in Mercurial, _walkexplicit returns a tuple, so ensure
we are up to date and take the normalized path which is the first part of the
tuple.

Based on a patch by David Soria Parra <davidsp@fb.com>.
2015-04-03 10:27:04 -07:00
Siddharth Agarwal
acd93ed88f gitdirstate: fix whitespace 2015-04-03 10:25:18 -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
d752117df9 gitrepo.listkeys: stop exporting commits before computing bookmarks
This seems to be a holdover from the days when we used to fetch the entire pack
from the Git server in listkeys. We don't do that any more, so this is also
unnecessary.
2015-03-05 13:08:35 -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
Mathias De Maré
62e84b3950 gitdirstate: avoid an abort when a .gitignore is missing
Deleting a .gitignore using 'rm' results in 'hg add' or 'hg status' aborting.
For example if the top-level .gitignore is removed:
  > abort: No such file or directory: .gitignore
This change avoids that by checking the presence of the .gitignore files.
2015-02-16 18:35:35 +01:00
Augie Fackler
b061e25670 Bump testedwith and hg-git version for release. 2015-01-30 11:08:10 -05:00
Siddharth Agarwal
a5d4fa20cb overlaymanifest: implement more methods for Mercurial 3.3 compatibility
Looks like we use many more dict APIs in overlaymanifest.
2015-01-26 17:47:54 -08:00
Siddharth Agarwal
61d715d7f4 overlaychangelog: return tuples for read()
I have no idea why this used to return a changectx -- changelog.read() in core
has always returned a tuple.
2015-01-26 17:46:55 -08:00
Siddharth Agarwal
f36dda4433 overlay: add namespace support to overlayrepo to support Mercurial >= 3.3
This allows test-incoming.t to progress further.
2015-01-26 16:21:23 -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
Augie Fackler
6efcd59b56 hg2git: audit path components during export (CVE-2014-9390)
A user recently got confused and managed to track and export a .git
directory, which confuses git and causes it to emit very odd
errors. For example, cloning one such repository (which has a symlink
for .git) produces this output from git:

  Cloning into 'git'...
  done.
  error: Updating '.git' would lose untracked files in it

and another (which has a .git directory checked in) produces this:

  Cloning into 'git'...
  done.
  error: Invalid path '.git/hooks/post-update'

If it ended there, that'd be fine, but this led to a line of
investigation that ended with CVE-2014-9390, so now git will block
checking these revisions out, so we should try to prevent
foot-shooting on our end. Since some servers (notably github) are
blocking trees that contain these entries, default to refusing to
export any path component that looks like it folds to .git. Since some
histories probably contain this already, we offer an escape hatch via
the config option git.blockdotgit that allows users to resume
foot-shooting behavior.
2014-11-23 19:06:21 -05:00
Siddharth Agarwal
9ec82c345a init: assert compatibility with Mercurial 3.2.2 2014-12-10 11:01:12 -08:00
Siddharth Agarwal
11762ee4bc init: add a try/except to retain compatibility with Mercurial 3.2
Without the try/except, hg-git crashes with Mercurial 3.2. Oops.
2014-12-10 10:59:39 -08:00
Siddharth Agarwal
283e5974d6 git2hg: update comment now that presence of hg fields is no longer a heuristic
In a previous commit we started storing metadata in Git whenever commits
originated in Mercurial, so this is no longer a heuristic.
2014-12-05 01:07:41 -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
paul.wheeler@appature.com
e311b5750b util: add missing mercurial.util import 2014-12-05 16:40:21 -08:00
Siddharth Agarwal
6b74612330 exchangepull: fixup for introduction of transaction manager upstream
Mercurial rev 1660b80d8083 introduced a transaction manager upstream. This
means that the closetransaction and releasetransaction methods on the pull
operation have gone away.
2014-12-05 16:40:34 -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