Commit Graph

710 Commits

Author SHA1 Message Date
Siddharth Agarwal
bffd6d062c tests: test with @ instead of tip 2014-05-19 19:27:48 -07:00
Siddharth Agarwal
f553d6f950 testedwith: update list of versions hg-git is tested with
This should be kept in sync with the Makefile, but hasn't been.
2014-05-19 19:21:46 -07:00
Siddharth Agarwal
7f8c670530 readme: drop Mercurial and Dulwich compatibilty information
No one's ever going to bother keeping this in sync.
2014-05-19 20:44:53 -07:00
Siddharth Agarwal
d0ee6b199a tests: fix breakage caused by Mercurial changes
Mercurial commit 1ecf7fef14e2 added a new message to `hg resolve` with no more
unresolved files.
2014-05-19 19:52:22 -07:00
Augie Fackler
b5d06af748 Added signature for changeset ed515afe5a32 2014-05-13 17:42:19 -04:00
Augie Fackler
d5522aeda7 setup: bump version number, correct author 2014-05-13 17:42:05 -04:00
Augie Fackler
32e8a45170 Makefile: drop support for hg older than 2.8.2
Ubuntu's current LTS release (Trusty Tahr) comes with Mercurial 2.8.2,
which still works fine with current code. The older LTS comes with a
version that's broken, but I don't have to worry about that anymore.
2014-05-13 17:25:04 -04:00
Takumi IINO
7dcd72400d gignore: remove illegal components (issue92)
mercurial can't ignore .hg direcotry.
2014-04-16 22:04:26 +09:00
Siddharth Agarwal
f82134e252 listkeys: while looking for bookmarks, don't fetch a pack
hg pull calls listkeys for bookmarks. This would previously cause a pack with
all refs to be fetched. For Mercurial mirrors of Git repositories where only
some refs were mirrored, this would cause problems in a bunch of ways:

- A larger pack would be fetched than necessary.
- The final refs written out to the Git repo would only be the set of refs we
  were actually interested in. If a GC was subsequently run, unreferenced
  objects would be deleted. Those objects might be referred to on subsequent
  fetches, which could cause hg-git to crash.

We replace all that logic with a simple null fetch. The tests introduced in the
previous patch ensure no regressions.
2014-05-08 20:18:06 -07:00
Siddharth Agarwal
c39a11100a test-bookmark-workflow: introduce tests for incoming bookmarks
An upcoming patch will change bookmark discovery significantly. These tests
make sure nothing major regresses.
2014-05-08 19:49:50 -07:00
Siddharth Agarwal
8fbad9ff16 filter_refs: only return all refs when heads is None
We're going to pass in an empty list to this function in an upcoming patch,
with the intent that filter_refs returns an empty dict.
2014-05-08 19:30:38 -07:00
Siddharth Agarwal
4587ed225c revset_fromgit: use repo.changelog.node instead of contexts
hg perfrevset 'max(fromgit())' on a repo with around 60,000 commits:

before: ! wall 1.055093 comb 1.050000 user 1.050000 sys 0.000000 (best of 10)
after:  ! wall 0.148586 comb 0.140000 user 0.140000 sys 0.000000 (best of 62)

In reality, perfrevset doesn't clear the Git-to-Mercurial map, which means that
a call like `hg log -r 'max(fromgit())'` speeds up from around 1.5 seconds to
0.6.
2014-04-14 21:05:13 -07:00
Siddharth Agarwal
ccfe0b660e revset_gitnode: use repo.changelog.node instead of contexts
For a repository with around 60,000 commits, perfrevset for gitnode becomes:
before: ! wall 1.130716 comb 1.130000 user 1.130000 sys 0.000000 (best of 9)
after:  ! wall 0.178828 comb 0.180000 user 0.180000 sys 0.000000 (best of 54)

In reality, perfrevset doesn't clear the Git-to-Mercurial map, which means that
a call like `hg log -r 'gitnode(...)'` speeds up from around 1.5 seconds to
0.6.
2014-04-14 19:32:17 -07:00
Siddharth Agarwal
f8423175b8 test-git-submodules: replace hg cat with hg manifest
Mercurial commit a6d634896102 added support for hg cat across subrepositories.
That caused these tests to break. Fix this by using hg manifest instead.
2014-05-08 13:53:36 -07:00
Augie Fackler
53d4df5863 tests: add some extra filters for new output
Tests pass on both my Mac and Linux machine, so I feel moderately confident
that this is portable.
2014-03-25 15:04:11 -04:00
Siddharth Agarwal
c188adb4b9 hg2git: in _init_dirs, store keys without leading '/' (issue103)
Previously, whenever a tree that wasn't the root ('') was stored, we'd prepend
a '/' to it. Then, when we'd try retrieving the entry, we'd do so without the
leading '/'. This caused data loss because existing tree entries were dropped
on the floor. Fix that by only adding '/' if we're adding to a non-empty
initial path.

This wasn't detected in tests because most of them deal only with files in the
root and not ones in subdirectories.
2014-03-25 11:11:04 -07:00
Siddharth Agarwal
f84c69b6c1 hg2git: start incremental conversion from a known commit
Previously, we'd spin up the Mercurial incremental exporter from the null
commit and build up state from there. This meant that for the first exported
commit, we'd have to read all the files in that commit and compute Git blobs
and trees based on that.

The current Mercurial to Git conversion scheme makes most sense with
Mercurial's current default storage format, where manifests are diffed against
the numerically previous revision. At some point in the future, the default
will switch to generaldelta, where manifests would be diffed against one of
their parents. In that world it might make more sense to have a stateless
exporter that diffed each commit against its generaldelta parent and calculated
dirty trees based on that instead. However, more experiments need to be done to
see what export scheme is best.

For a repo with around 50,000 files, this brings down an incremental 'hg
gexport' of one commit from 18 seconds with a hot file cache (and tens of
minutes with a cold one) to around 2 seconds with a hot file cache.
2014-03-14 20:45:09 -07:00
Siddharth Agarwal
fe5bb48ac2 git_handler: return early when no commits need to be exported
This will make our life easier in an upcoming patch.
2014-03-14 19:18:19 -07:00
Siddharth Agarwal
e5bd941852 hg2git: implement a method to initialize _dirs from a Git commit
Upcoming patches will start incrementally exporting from a particular commit
instead of from null. This function will be used for that..
2014-03-14 19:17:09 -07:00
Siddharth Agarwal
3e13ddc73e safebranchrevs: handle changelog having no commits
The usage of getattr was unsafe. Use hgutil.safehasattr instead.
util.safehasattr has been around since Mercurial 2.0.

This also fixes the formerly disabled test in test-pull.t.
2014-03-04 23:20:50 -08:00
Siddharth Agarwal
8117eb614e test-pull.t: add test for no-op pull 2014-03-04 16:30:12 -08:00
Siddharth Agarwal
bf45b40ca3 git_handler.fetch: only import commits reachable from requested heads
Previously we'd attempt to import every single reachable commit in the Git
object store.

The test adds another branch to the Git repo and doesn't import it until much
later. Previously we'd import it when we ran `hg -R hgrepo pull -r beta`. Now
we won't.
2014-03-04 16:23:11 -08:00
Siddharth Agarwal
759062fbfd git_handler.fetch: actually return number of heads added or removed
The return value as implemented in git_handler.fetch was pretty bogus. It used
to return the number of values that changed in the 'refs/heads/' namespace,
regardless of whether multiple values in there point to the same Mercurial
commit, or whether particular heads were even imported. Fix all of that by
using the actual heads in the changelog, just like vanilla Mercurial.

The test output changes demonstrate examples where the code was buggy.
2014-03-04 16:05:19 -08:00
Siddharth Agarwal
0428a10ad5 import_git_objects: return number of commits imported
This will be used in an upcoming patch.
2014-03-04 16:51:43 -08:00
Siddharth Agarwal
e41aded84e git_handler: base 'no changes found' message on commits, not on heads
Since Mercurial is commit-oriented, the 'no changes found' message really
should rely on what new commits are in the repo, not on new heads. This also
makes an upcoming patch much simpler.

Since everything around this code is completely broken anyway, writing a test
for this that doesn't trigger other bugs is close to impossible. An upcoming
patch will include tests.

The test output change is for an empty clone -- the output is precisely how
vanilla Mercurial treats an empty clone.
2014-03-04 15:43:54 -08:00
Siddharth Agarwal
636c9670c6 update_hg_bookmarks: don't update bookmarks that don't have an hg commit
Still more bugs to fix.
2014-03-04 14:50:44 -08:00
Siddharth Agarwal
c090d035ea update_remote_branches: don't store refs that don't have an hg equivalent
Same reasoning as previous patch, and same reason why this patch doesn't
include a test.
2014-03-04 14:39:50 -08:00
Siddharth Agarwal
82ef213bf9 import_tags: don't import tags that don't have an hg commit equivalent
The theme of this and upcoming patches is that relying on self.git.object_store
to figure out which commits/tags/bookmarks to import is not great. This breaks
if the git repo is manually put in place (as might be done in a server-based
replication scenario), or if a partial fetch pulled too many commits in for
whatever reason. Indeed we were just about always pulling an entire pack in,
because listkeys for bookmarks currently calls fetch_pack without any
filtering. (This is probably a bug and should be fixed, but this series doesn't
do that.)

Instead, rely on whether we actually imported the commit into Mercurial to
determine whether to import the tag. This is clean, straightforward, and
clearly correct.

There is a whole series of bugs in this code that any test case for this would
hit -- an upcoming patch will include a test for all these bugs at once.
2014-03-04 14:26:30 -08:00
Siddharth Agarwal
6a6f93d8e3 determine_wants: factor ref filtering code out into a separate function
This will be used in another context in an upcoming patch.
2014-03-04 12:57:37 -08:00
Siddharth Agarwal
4877843f03 git_handler: don't write out objects if already in object store
object_store.add_object doesn't check to see if the object is already in a
pack, so it is still written out in that case. Do the check ourselves before
calling add_object.
2014-03-03 22:44:09 -08:00
Siddharth Agarwal
05dde62bce extsetup: use new-style extsetup with ui parameter
The "new-style" extsetup has been supported since at least 2009.
2014-02-27 17:20:31 -08:00
Augie Fackler
e1793c2341 verify: drop broken and unused import statement 2014-03-01 09:37:26 -05:00
Siddharth Agarwal
89c409af60 verify: add new command to verify the contents of a Mercurial rev
Since the Git to Mercurial conversion process is incremental, it's at risk of
missing files, or recording files the wrong way, or recording the wrong commit
metadata. Add a command called 'gverify' that can verify the contents of a
particular Mercurial rev against the corresponding Git commit.

Currently, this is limited to checking file names, flags and contents, but this
can be made as robust as desired. Further additions will probably require
refactoring git_handler.py a bit though.

This function is pretty fast: on a Linux machine with a warm cache, verifying a
repository with around 50,000 files takes just 20 seconds. There is scope for
further improvement through parallelization, but conducting tree walks in
parallel is non-trivial with the current worker infrastructure in Mercurial.
2014-02-26 14:19:24 -08:00
Siddharth Agarwal
56cbe49bb0 git_handler: remove init_if_missing
This function is a no-op and can be removed.
2014-02-25 20:01:42 -08:00
Siddharth Agarwal
6d1bd2e02e git_handler: make self.git a lazily evaluated property
This allows other functions to be able to use the `git` property without
needing to care about initializing it.

An upcoming patch will remove the `init_if_missing` function.
2014-02-25 19:51:02 -08:00
Siddharth Agarwal
bbfc3bf8b0 overlayrevlog: handle root commits correctly
Previously, we'd try to access commit.parents[0] and fail. Now, check for
commit.parents being empty and return what Mercurial thinks is a repository
root in that case.
2014-02-25 00:23:12 -08:00
Siddharth Agarwal
a5e956514d overlayrevlog: handle rev = 0 correctly
Previously we'd just test if gitrev was falsy, which it is if the rev returned
is 0, even though it shouldn't be. With this patch, test against None
explicitly.

This unmasks another bug: see next patch for a fix and a test.
2014-02-25 00:20:22 -08:00
Siddharth Agarwal
fea85d57c6 git_handler: fix call to self.ui.progress in flush
Since we now directly use progress on self.ui, we shouldn't pass in self.ui as
the first argument. Oops.
2014-02-24 15:29:31 -08:00
Siddharth Agarwal
2cc81f4c1f git_handler: don't compute tags for each tag imported
Previously we'd recompute the repo tags each time we'd consider importing a Git
tag. This is O(n^2) in the number of tags and produced noticeable slowdowns in
repos with large numbers of tags.

To fix this, compute the tags just once. This is correct because the only case
where we'd have issues is if multiple new Git tags with the same name were
introduced, which can't happen because Git tags cannot share names.

For a repository with over 200 tags, this causes a no-op hg pull to be sped up
by around 0.5 seconds.
2014-02-24 11:38:00 -08:00
Siddharth Agarwal
27784bf3bc util: drop support for Mercurial < 1.4 2014-02-19 18:49:42 -08:00
Siddharth Agarwal
01fb9068a0 git_handler: replace util.progress with ui.progress
util.progress was a shim for Mercurial < 1.4.
2014-02-19 18:49:28 -08:00
Siddharth Agarwal
01896282f6 overlay: drop support for Mercurial < 1.9 2014-02-19 18:46:56 -08:00
Siddharth Agarwal
a49ac12684 git_handler: remove old and bogus code for deleting entries from tags cache
This code never worked for Mercurial >= 2.0, since it neither had repo._tags
nor repo.tagscache.
2014-02-19 18:45:36 -08:00
Siddharth Agarwal
d7bad71d02 git_handler.save_tags: drop support for Mercurial < 1.9 2014-02-19 16:12:27 -08:00
Siddharth Agarwal
5ef555a629 git_handler.save_map: drop support for Mercurial < 1.9 2014-02-19 16:10:35 -08:00
Siddharth Agarwal
8f2d697a54 hgrepo.tags: drop support for Mercurial < 2.0
A new property called _tagscache was introduced in Mercurial 2.0, so the cache
wasn't actually working.

The contract for tags() also changed at some point -- it stopped returning
nodes that weren't in the repo. This will need to be accounted for if we
start using the tags cache again. However, it isn't very clear whether the
Mercurial tags cache is actually worth doing, since we already have a
separate in-memory cache for Git tags in the handler.
2014-02-19 16:09:23 -08:00
Siddharth Agarwal
41357ce554 hgrepo.push: drop support for Mercurial < 1.6 2014-02-19 15:55:45 -08:00
Siddharth Agarwal
732da34592 gitrepo: drop support for Mercurial < 1.7 2014-02-19 15:54:37 -08:00
Siddharth Agarwal
7e329463b5 getremotechanges: drop support for Mercurial < 1.7 2014-02-19 15:54:04 -08:00
Siddharth Agarwal
a1a2eb9b35 nodetags: drop support for Mercurial < 1.6 2014-02-19 15:53:14 -08:00