Commit Graph

834 Commits

Author SHA1 Message Date
Siddharth Agarwal
7a8892e3fa tests: add further tests for gitlink <-> symlink and rename detection
There weren't any bugs here, but this is good to test.
2014-12-30 14:07:39 -08:00
Siddharth Agarwal
900d6b7203 tests: add tests for transitions to and from symlinks to files
This adds some test coverage for cases that are not buggy. There is a bug
lurking here, and an upcoming patch will extend these tests to cover those
cases too.
2014-12-30 12:26:10 -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
10f98f06fa test-extra.t: fix for Mercurial 3.3+ 2014-12-29 11:18:03 -08: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
f2f3a06e80 readme: add docs for rename detection options 2014-12-05 01:18:43 -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
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
a6b1e5863c test-encoding: remove support for Git 1.7.x
Git 1.8.0 was released in late 2012. Given that we only support versions of
Mercurial released in 2014, it doesn't make sense to support versions of Git
this old.
2014-12-04 18:31:42 -08:00
Augie Fackler
b4e1b8890c CONTRIBUTING: fix a typo I just noticed 2014-11-30 22:34:52 -05: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
Durham Goode
6a97baea46 manifest: add matches() to overlay
fd926a0f2592 in upstream Mercurial added a matches function to the manifest.
This broke 'hg incoming -p' with hg-git. This patch adds a simple implementation
that fixes the problem.

This was caught by the tests, and now the tests pass.
2014-11-25 10:53:11 -08:00
Augie Fackler
c7b81c40cb setup: bump version for release 2014-11-05 12:30:00 -05: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
Siddharth Agarwal
d1d7def3b9 tests: fix file modes 2014-10-29 19:34:36 -07:00
Siddharth Agarwal
deb06920ba readme: add docs for git.mindate 2014-10-31 11:36:39 -07:00
Siddharth Agarwal
c107b78504 gimport: support git.mindate 2014-10-29 19:37:23 -07:00
Siddharth Agarwal
b8dd01725f pull: support git.mindate 2014-10-29 19:37:10 -07:00
Siddharth Agarwal
b1306a0d26 git_handler: introduce a function and config to filter by minimum date
This is useful if there's no desire to import old Git branches, but new ones
should be.
2014-10-29 19:36:33 -07:00
Siddharth Agarwal
079686eb01 git_handler: support wildcards for Git branch name matching
This is quite similar to syntax Git supports. In the future maybe core
Mercurial could be extended to support this, but I think this independently
makes sense in hg-git.
2014-10-31 11:14:35 -07:00
Siddharth Agarwal
52c656bd2b git_handler.filter_refs: sort returned refs if none are provided
Again, no direct impact in stock hg-git, but super useful for extensions.
2014-10-31 10:46:56 -07:00
Siddharth Agarwal
79e05f3138 git_handler: return filtered refs as an OrderedDict
This actually has no direct impact here, but it allows extensions to customize
the list of filtered refs and be sure of the order in which they'll be
processed.
2014-10-31 10:40:58 -07:00
Siddharth Agarwal
3dc9407916 git_handler.fetch: remove dead remoteref function 2014-10-29 16:27:55 -07:00
Siddharth Agarwal
5953bb2058 git_handler: remove now-unused local_heads method 2014-10-29 12:44:29 -07:00
Siddharth Agarwal
d3891945ec git_handler.get_changed_refs: remove now-unused all_heads variable 2014-10-29 13:12:43 -07:00
Siddharth Agarwal
f842185378 git_handler.get_chanaged_refs: use exportable for no-ref check
The comment was actually incorrect -- we only used to care about bookmarks. Now
we also care about tags.
2014-10-29 13:12:15 -07:00
Siddharth Agarwal
c45d7ddd88 git_handler.get_changed_refs: switch to using get_exportable
This also means we get to clean up a lot of the code around here. It isn't
really feasible to break this up into several commits because the assumptions
in the old calling code are too closely tied to the old local_heads() way of
doing things.
2014-10-29 12:30:23 -07:00
Siddharth Agarwal
9ba36983dc git_handler.update_references: switch to using get_exportable 2014-10-29 10:35:36 -07:00
Siddharth Agarwal
ac94e84bc4 git_handler: add a way to get all heads that can be exported to Git
This is a replacement for local_heads and code duplication around it.
Centralizing all this logic also makes it much easier for extensions to define
other sorts of refs.
2014-10-29 11:56:31 -07:00
Siddharth Agarwal
3c2e5f8eb5 git_handler.get_changed_refs: drop support for ancient Mercurial versions 2014-10-29 13:30:18 -07:00
Siddharth Agarwal
e23ddbd959 test-hg-tags-invalid: add a test for tag with space in it
There was previously an attempt to handle this but no test coverage.
2014-10-29 13:28:39 -07:00
Siddharth Agarwal
82feaa76ca git_handler: write inequality more idiomatically 2014-10-27 21:47:24 -07:00
Siddharth Agarwal
cbe0340be6 git_handler.update_references: use iteritems 2014-10-28 19:03:54 -07:00
Siddharth Agarwal
1cb0a757d0 git_handler.update_references: use git ref returned from local_heads 2014-10-28 19:02:00 -07:00
Siddharth Agarwal
764c17d49f git_handler.local_heads: return git ref with sha
This allows extensions to add other sources of git refs.

The returned git ref is currently unused -- the following patch will use it.
2014-10-28 18:53:52 -07:00
Siddharth Agarwal
c2dd416ed0 git_handler.update_references: fix variable name 2014-10-28 18:57:33 -07:00
Siddharth Agarwal
da516f8757 git_handler.get_changed_refs: drop unnecessary computation of local heads
It doesn't change between iterations of the generator expression, and it's
non-trivial to calculate.
2014-10-28 18:45:02 -07:00
Siddharth Agarwal
ed9cbd422d git_handler.local_heads: use a generator comprehension
The list comprehension is unnecessary.
2014-10-28 18:25:57 -07:00