Code Monkey home page Code Monkey logo

git-remote-hg's Introduction

git-remote-hg is the semi-official Mercurial bridge from the Git project, once installed, it allows you to clone, fetch and push to and from Mercurial repositories as if they were Git ones:

git clone "hg::http://selenic.com/repo/hello"

To enable this, simply add the git-remote-hg script anywhere in your $PATH:

curl https://raw.githubusercontent.com/felipec/git-remote-hg/master/git-remote-hg -o ~/bin/git-remote-hg
chmod +x ~/bin/git-remote-hg

That’s it :)

Obviously you will need Mercurial installed.

Configuration

If you want to see Mercurial revisions as Git commit notes:

% git config core.notesRef refs/notes/hg

If you are not interested in Mercurial permanent and global branches (aka. commit labels):

% git config --global remote-hg.track-branches false

With this configuration, the 'branches/foo' refs won’t appear.

If you want the equivalent of hg clone --insecure:

% git config --global remote-hg.insecure true

If you want git-remote-hg to be compatible with hg-git, and generate exactly the same commits:

% git config --global remote-hg.hg-git-compat true

Notes

Remember to run git gc --aggressive after cloning a repository, especially if it’s a big one. Otherwise lots of space will be wasted.

The newest supported version of Mercurial is 6.2, the oldest one is 4.0.

Pushing branches

To push a branch, you need to use the 'branches/' prefix:

% git checkout branches/next
# do stuff
% git push origin branches/next

All the pushed commits will receive the "next" Mercurial named branch.

Note: Make sure you don’t have remote-hg.track-branches disabled.

Cloning HTTPS

The simplest way is to specify the user and password in the URL:

git clone hg::https://user:[email protected]/user/repo

You can also use the schemes extension:

[auth]
bb.prefix = https://bitbucket.org/user/
bb.username = user
bb.password = password

Finally, you can also use the keyring extension.

Caveats

The only major incompatibility is that Git octopus merges (a merge with more than two parents) are not supported.

Mercurial branches and bookmarks have some limitations of Git branches: you can’t have both 'dev/feature' and 'dev' (as Git uses files and directories to store them).

Multiple anonymous heads (which are useless anyway) are not supported: you would only see the latest head.

Closed branches are not supported: they are not shown and you can’t close or reopen. Additionally in certain rare situations a synchronization issue can occur (Bug #65).

Limitations of Git’s remote-helpers framework apply.

Other projects

There are other git-remote-hg projects out there, but this is the original, which was distributed officially in the Git project.

Over the years many similar tools have died out, the only actively maintained alternative is mnauw’s fork of this project: mnauw/git-remote-hg. I’ve merged some of his patches, and he has merged some of my patches, so the projects are mostly in sync, but not quite. In particular Nauwelaerts' fork has many administrative extensions, which although useful to some people, I don’t believe they belong in the core.

For a comparison between these and other projects go here.

Contributing

Send your patches to the mailing list [email protected] (no need to subscribe).

git-remote-hg's People

Contributors

ambakshi avatar apelisse avatar artagnon avatar benabik avatar delcypher avatar felipec avatar fingolfin avatar gitster avatar jcb91 avatar mnauw avatar noschinl avatar ostueker avatar pabs3 avatar rhansen avatar rotu avatar rudis avatar tboegi avatar wking avatar zetten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-remote-hg's Issues

notes are lost when fetching from a new repo

Since a new repo does not yet have last-note info, the notes commit for fast-import does not mention a from mark, and so it starts a whole new hierarchy, thereby losing the existing notes (holding revision info from repos fetched so far).

Fix coming up that avoids using the last-note info altogether, and so prevents this from happening.

ValueError: invalid literal for int() with base 10:

I'm getting an error when pushing an existing git repo into a new mercurial repo. To reproduce:

mkdir foo && ( cd foo && hg init)
git clone https://gitlab.com/fdroid/fdroidclient.git
git remote add foo hg::../foo
git push foo master
Traceback (most recent call last):
  File "/home/kevin/bin/git-remote-hg", line 1322, in <module>
    sys.exit(main(sys.argv))
  File "/home/kevin/bin/git-remote-hg", line 1308, in main
    do_export(parser)
  File "/home/kevin/bin/git-remote-hg", line 1099, in do_export
    parse_commit(parser)
  File "/home/kevin/bin/git-remote-hg", line 788, in parse_commit
    mark = int(mark_ref[1:])
ValueError: invalid literal for int() with base 10: '4ca7dd0dbaee8a011aad6195f33e840793e7df9'
error: fast-export died of signal 13
fatal: Error while running fast-export

json import failure

When starting a clone without "json" python module (I use simplejson), I got the following error :

git clone "hg::ssh://<....>" profile.git
Cloning into 'profile.git'...
Traceback (most recent call last):
File "/usr/bin/git-remote-hg", line 23, in
import json
ImportError: No module named json

question: What is a good workflow to prevent some(git specific) files from getting added to

I want to use git to work on a project(hosted on bitbucket hg) and periodically send pull requests upstream.

I have a bitbucket fork of that project and I'm using git-remote-hg to push changes to a particular branch to my fork and create pull requests. However, I need to delete git/github specific files such as .gitignore and .travis.yml every time I merge another branch into the branch tracking the hg remote.

Are there alternative/simpler ways of achieving this?

Mercurial 3.2 breaks git-remote-hg

Upgrading to Mercurial 3.2 appears to break git-remote-hg.

I get the following upon running git fetch:

Traceback (most recent call last):
  File "/home/tomxtobin/bin/git-remote-hg", line 1322, in <module>
    sys.exit(main(sys.argv))
  File "/home/tomxtobin/bin/git-remote-hg", line 1286, in main
    repo = get_repo(url, alias)
  File "/home/tomxtobin/bin/git-remote-hg", line 433, in get_repo
    repo.pull(peer, heads=None, force=True)
  File "/usr/lib/python2.7/site-packages/mercurial/repoview.py", line 307, in __getattr__
    return getattr(self._unfilteredrepo, attr)
AttributeError: 'localrepository' object has no attribute 'pull'

Downgrading to Mercurial 3.1.2 resolves the issue.

How to map hg tags & branches to git branches?

I am a first time user of git-remote-hg. I cloned an hg repo whose web browser view shows more than 20 branches and also a large number of tags, none of which is called "master".

git branch --list

shows a single branch master.

How can I confirm that this master branch maps to default in origin? Does it? As there is no master branch in the remote hg repo I am guessing that this is what must be happening.

git remote show origin

shows

searching for changes
adding changesets
adding manifests
adding file changes
added 5 changesets with 6 changes to 6 files
* remote origin
  Fetch URL: hg::http://hg.libsdl.org/SDL
  Push  URL: hg::http://hg.libsdl.org/SDL
  HEAD branch: master
  Remote branches:
    branches/SDL-1.2 tracked
    branches/default tracked
    master           tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (create)

The items under branches are the first 2 branches listed by the web browser view of the origin depot. Is there any way to get these branches to show up as regular git branches so that git branch shows them?

I don't need them right now but is there any way to include the other branches from the remote?

Is there any way to create git branches corresponding to the hg tags?

The multiple statements implying there is something called master at the remote are very confusing.

I'm sure I can't be the only person with these questions. Is there documentation somewhere that I failed to find?

BTW, you need to have hg installed so the comment on the home page to the effect that you simply need to copy the script to somewhere in your $PATH is wrong.

ImportError: No module named mercurial: Clarify install documentation

To install git-remote-hg, I followed the simple wget-based instructions at
felipec/git-remote-hg: Transparent bidirectional bridge between Git and Mercurial for Git

But when trying to run it I encountered this error.

Cloning into 'bx-python'...
Traceback (most recent call last):
  File ".../git-remote-hg", line 15, in <module>
    from mercurial import hg, ui, bookmarks, context, encoding
ImportError: No module named mercurial

Some googling led me to a bunch of different advice and potentially complicating issues, like #38 and #27. Especially after an initial failure, I hate having to try different things, and prefer a robust solution.

I think the main page should clarify at least one clean, known-to-work scenario.

In my case (Ubuntu Trusty), I know it is generally better for long-term security to install official packages, and it seems to have worked to do apt-get install mercurial. For others it might be more appropriate to install via pip from git-remote-hg 0.1.1 : Python Package Index.

fast import crashes with: "Missing < in ident string"

Hi,

when cloning a certain mercurial repository, fast-import crashes:

fast-import crash report:
    fast-import process: 12990
    parent process     : 12989
    at Wed Jun 4 15:53:16 2014

fatal: Missing < in ident string: noschinl 1397474979 +0200

The most recent command before the crash is:

committer noschinl 1397474979 +0200

If I lookup the associated commit in Mercurial, I see this this refers to the content of the committer field in extras, which was created by an older version of git-remote-hg:

$ hg log -r 56572 --template "{join(extras, '\n')}\n"
branch=default
committer=noschinl 1397474979 -7200

So apparently, once upon a time git-remote-hg created commits that itself cannot import anymore now. This may be related to the fact that my git config contains the lines:

[user]
    name = noschinl
    email = unknown

as the project uses old unix-style author names.

I don't know whether this is the correct fix, but I made the import work for me using the following patch:

diff --git a/git-remote-hg b/git-remote-hg
index c10b37b..d0e94c2 100755
--- a/git-remote-hg
+++ b/git-remote-hg
@@ -498,7 +498,7 @@ def export_ref(repo, name, kind, head):
         if 'committer' in extra:
             try:
                 cuser, ctime, ctz = extra['committer'].rsplit(' ', 2)
-                committer = "%s %s %s" % (cuser, ctime, gittz(int(ctz)))
+                committer = "%s %s %s" % (fixup_user(cuser), ctime, gittz(int(ctz)))
             except ValueError:
                 cuser = extra['committer']
                 committer = "%s %d %s" % (fixup_user(cuser), time, gittz(tz))

The versions of relevant tools are:

$ git --version
git version 2.0.0.rc2
$ hg --version
Mercurial Distributed SCM (version 2.9.2)

git-remote-hg version is 185852e

Cannot clone a mercurial repository: "env: python2: No such file or directory"

macdada$ ls -alh /usr/local/bin/git-remote-hg

lrwxr-xr-x  1 macdada  admin    37B May  7 13:42 /usr/local/bin/git-remote-hg -> ../Cellar/git/1.9.2/bin/git-remote-hg

macdada$ git --version
git version 1.9.2

macdada$ hg --version
Mercurial Distributed SCM (version 3.0)

macdada$ git clone "hg::https://[email protected]/kwi/urllinker"
Cloning into 'urllinker'...
env: python2: No such file or directory

I also tried to just add it as a remote, same problem.

macdada$ mkdir UrlLinker && cd UrlLinker

macdada$ git init
Initialized empty Git repository in /Users/macdada/Documents/programowanie/forks/UrlLinker/.git/

macdada$ git remote add upstream "hg::https://[email protected]/kwi/urllinker"

macdada$ git fetch upstream
env: python2: No such file or directory

Syntax error: newline unexpected

Tried cloning from two different hg repos, and get the same error every time:

zamparol@iski0019:~/projects/mirnylab$ git clone "hg::http://selenic.com/repo/hello"
Cloning into 'hello'...
/home/zamparol/bin/git-remote-hg: 5: /home/zamparol/bin/git-remote-hg: Syntax error: newline unexpected

What's up with this?

git fsck on cloned repo shows "warning in tree ad82bbbe50a28ff5e712c1a18986908168afbf10: contains '.git'"

Reproduction steps are trivial (at least here with git 1.8.3.1 and hg 2.6.2):

  1. git clone hg::https://bitbucket.org/fbennett/citeproc-js
  2. cd citeproc-js
  3. git fsck

The result is:

$ git fsck
Checking object directories: 100% (256/256), done.
warning in tree ad82bbbe50a28ff5e712c1a18986908168afbf10: contains '.git'
Checking objects: 100% (46524/46524), done.
$

Unfortunately, this seems to break my ability to push the created repository to GitLab.

Cloning: 'localrepository' object has no attribute 'pull'

Cloning remote repositories fails with the following output:

[oliver@oliver:git]$ git clone "hg::http://hg.gajim.org/gajim" gajim 
Cloning into 'gajim'...
Traceback (most recent call last):
  File "/usr/local/bin/git-remote-hg", line 1322, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/git-remote-hg", line 1286, in main
    repo = get_repo(url, alias)
  File "/usr/local/bin/git-remote-hg", line 433, in get_repo
    repo.pull(peer, heads=None, force=True)
  File "/usr/lib/python2.7/site-packages/mercurial/repoview.py", line 335, in __getattr__
    return getattr(self._unfilteredrepo, attr)
AttributeError: 'localrepository' object has no attribute 'pull'

hg revisions created from git commits lack file rename and copy metadata

The 2 systems, git and Mercurial, are obviously different here.
Git does not really track any move and copy meta-data, it just finds out about that (with more or less effort) when traversing history. Mercurial, on the other hand, does track such metadata and relies on it when following a file's history.

As no such move and copy metadata is added to the generated hg changesets, performing a file move in a git commit which is then pushed to Mercurial will break that file's history, as opposed to what would happen in a native hg revision.

Linus Torvalds says git gc --aggressive is bad

Your Readme says to do git gc --aggressive after cloning. Is that really safe to do?
Does the part about "Some import tools in particular could generate really horribly bad deltas" apply?
Or would it be better to switch to git repack?


Date: Wed, 5 Dec 2007 22:09:12 -0800 (PST)
From: Linus Torvalds
Subject: Re: Git and GCC

On Thu, 6 Dec 2007, Daniel Berlin wrote:

Actually, it turns out that git-gc --aggressive does this dumb thing
to pack files sometimes regardless of whether you converted from an
SVN repo or not.

Absolutely. git --aggressive is mostly dumb. It's really only useful for
the case of "I know I have a really bad pack, and I want to throw away
all the bad packing decisions I have done".

To explain this, it's worth explaining (you are probably aware of it, but
let me go through the basics anyway) how git delta-chains work, and how
they are so different from most other systems.

In other SCM's, a delta-chain is generally fixed. It might be "forwards"
or "backwards", and it might evolve a bit as you work with the repository,
but generally it's a chain of changes to a single file represented as some
kind of single SCM entity. In CVS, it's obviously the *,v file, and a lot
of other systems do rather similar things.

Git also does delta-chains, but it does them a lot more "loosely". There
is no fixed entity. Delta's are generated against any random other version
that git deems to be a good delta candidate (with various fairly
successful heursitics), and there are absolutely no hard grouping rules.

This is generally a very good thing. It's good for various conceptual
reasons (ie git internally never really even needs to care about the whole
revision chain - it doesn't really think in terms of deltas at all), but
it's also great because getting rid of the inflexible delta rules means
that git doesn't have any problems at all with merging two files together,
for example - there simply are no arbitrary *,v "revision files" that have
some hidden meaning.

It also means that the choice of deltas is a much more open-ended
question. If you limit the delta chain to just one file, you really don't
have a lot of choices on what to do about deltas, but in git, it really
can be a totally different issue.

And this is where the really badly named "--aggressive" comes in. While
git generally tries to re-use delta information (because it's a good idea,
and it doesn't waste CPU time re-finding all the good deltas we found
earlier), sometimes you want to say "let's start all over, with a blank
slate, and ignore all the previous delta information, and try to generate
a new set of deltas".

So "--aggressive" is not really about being aggressive, but about wasting
CPU time re-doing a decision we already did earlier!

Sometimes that is a good thing. Some import tools in particular could
generate really horribly bad deltas. Anything that uses "git fast-import",
for example, likely doesn't have much of a great delta layout, so it might
be worth saying "I want to start from a clean slate".

But almost always, in other cases, it's actually a really bad thing to do.
It's going to waste CPU time, and especially if you had actually done a
good job at deltaing earlier, the end result isn't going to re-use all
those good deltas you already found, so you'll actually end up with a
much worse end result too!

I'll send a patch to Junio to just remove the "git gc --aggressive"
documentation. It can be useful, but it generally is useful only when you
really understand at a very deep level what it's doing, and that
documentation doesn't help you do that.

Generally, doing incremental "git gc" is the right approach, and better
than doing "git gc --aggressive". It's going to re-use old deltas, and
when those old deltas can't be found (the reason for doing incremental GC
in the first place!) it's going to create new ones.

On the other hand, it's definitely true that an "initial import of a long
and involved history" is a point where it can be worth spending a lot of
time finding the _really_good* deltas. Then, every user ever after (as
long as they don't use "git gc --aggressive" to undo it!) will get the
advantage of that one-time event. So especially for big projects with a
long history, it's probably worth doing some extra work, telling the delta
finding code to go wild.

So the equivalent of "git gc --aggressive" - but done properly - is to
do (overnight) something like

git repack -a -d --depth=250 --window=250

where that depth thing is just about how deep the delta chains can be
(make them longer for old history - it's worth the space overhead), and
the window thing is about how big an object window we want each delta
candidate to scan.

And here, you might well want to add the "-f" flag (which is the "drop all
old deltas", since you now are actually trying to make sure that this one
actually finds good candidates.

And then it's going to take forever and a day (ie a "do it overnight"
thing). But the end result is that everybody downstream from that
repository will get much better packs, without having to spend any effort
on it themselves.

How can I find the hg revision number of a commit?

Sometimes, I need to add a reference to a previous commit in the current commit message. Is there a way to find the hg revision number(not sha hash) without having to create a new working directory for the hg clone?

Incompatibility with hg-git tip version due to rename detection

hg-git recently added file rename detection. In particular, they add a mercurial "extra" field where they record the "source" of renames, and this new field ("hg-git-rename-source=git") break things.

Note that Mercurial 3.3 is incompatible with hg-git 0.7.0, and so once hg 3.3 is out, one will have to use it with hg-git newer than 0.7.0, which in turn means git-remote-hg users may run into this issue.

Relevant hg-git commit:
https://bitbucket.org/durin42/hg-git/commits/fffe8883960b7c45e0dfe597f3b79bd1f4824cbe

Typical diff (from first hg-git test, "executable bit")

--- output-hg   2015-01-13 15:46:17.000000000 +0000
+++ output-git  2015-01-13 15:46:18.000000000 +0000
@@ -1,8 +1,8 @@
-@  changeset:   2:04585efb2d7e9262381ab791282b68ceb33398d0
+@  changeset:   2:1efb93106a36bf71352ab04e769a3422522cf946
 |  bookmark:    master
 |  tag:         tip
 |  phase:       draft
-|  parent:      1:9d3aaf34d914c50354fbcca3a0c309351f159546
+|  parent:      1:d7cae8b1fdab97568ba5eca44ca2bf5a44d7c394
 |  parent:      -1:0000000000000000000000000000000000000000
 |  manifest:    2:51e6255d794f794a8c4e0f03edf264444e3c5ce7
 |  user:        A U Thor <[email protected]>
@@ -10,14 +10,13 @@
 |  files:       alpha
 |  extra:       branch=default
 |  extra:       committer=C O Mitter <[email protected]> 1167600600 -9000
-|  extra:       hg-git-rename-source=git
 |  description:
 |  clear executable bit
 |
 |
-o  changeset:   1:9d3aaf34d914c50354fbcca3a0c309351f159546
+o  changeset:   1:d7cae8b1fdab97568ba5eca44ca2bf5a44d7c394
 |  phase:       draft
-|  parent:      0:97e0f86af84c927e56ac1e6159b5b2386ac3e110
+|  parent:      0:362b656574c3c9e89fa7f2d7a943091dc93bce4d
 |  parent:      -1:0000000000000000000000000000000000000000
 |  manifest:    1:e4bf4ef5e9aea7a6a57573e533a5519bd062f144
 |  user:        A U Thor <[email protected]>
@@ -25,12 +24,11 @@
 |  files:       alpha
 |  extra:       branch=default
 |  extra:       committer=C O Mitter <[email protected]> 1167600600 -9000
-|  extra:       hg-git-rename-source=git
 |  description:
 |  set executable bit
 |
 |
-o  changeset:   0:97e0f86af84c927e56ac1e6159b5b2386ac3e110
+o  changeset:   0:362b656574c3c9e89fa7f2d7a943091dc93bce4d
    phase:       draft
    parent:      -1:0000000000000000000000000000000000000000
    parent:      -1:0000000000000000000000000000000000000000
@@ -40,7 +38,6 @@
    files+:      alpha
    extra:       branch=default
    extra:       committer=C O Mitter <[email protected]> 1167600600 -9000
-   extra:       hg-git-rename-source=git
    description:
    add alpha

In case it helps (probably not): The following naive and brainless patch (i.e. made without actually thinking about the issue) is, not surprisingly, not helping much. It causes some tests to pass, but causes issues in others.

diff --git a/git-remote-hg b/git-remote-hg
index 0d903e3..6900499 100755
--- a/git-remote-hg
+++ b/git-remote-hg
@@ -538,7 +538,8 @@ def export_ref(repo, name, kind, head):
                 extra_msg += "rename : %s => %s\n" % e

             for key, value in extra.iteritems():
-                if key in ('author', 'committer', 'encoding', 'message', 'branch', 'hg-git'):
+                if key in ('author', 'committer', 'encoding', 'message', 'branch',
+                           'hg-git', 'hg-git-rename-source'):
                     continue
                 else:
                     extra_msg += "extra : %s : %s\n" % (key, urllib.quote(value))
@@ -870,6 +871,9 @@ def parse_commit(parser):
                     extra[ek] = urllib.unquote(ev)
             data = data[:i]

+    if 'hg-git-rename-source' not in extra:
+        extra['hg-git-rename-source'] = 'git'   # HACK
+
     ctx = context.memctx(repo, (p1, p2), data,
             files.keys(), getfilectx,
             user, (date, tz), extra)

pushes are rejected with a non-fast-forward error.

So, I've been trying to push a single commit to an HG repository.. And I've re-cloned it 3 times so far from scratch and it's refusing to work. Here are the steps.

  1. git clone hg::https://user:pass@reposite/repo repo
  2. cd repo
  3. git co branches/default
  4. git am < ../0001-my-patch
  5. git push origin branches/default

What I see is a bunch of errors about object already having a mark (see #16 ).. though if I do a push as step 3a.. I can get those out of the way before hand.
then I see this.

searching for changes
no changes found
searching for changes
To hg::https://user:pass@reposite/repo
 ! [rejected]        branches/default -> branches/default (non-fast-forward)
error: failed to push some refs to 'hg::https://user:pass@reposite/repo'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

However things are not behind at all!.. And here's the "fun bit" when I try to push again.. this is what happens.

searching for changes
no changes found
Everything up-to-date

As the commit that is supposed to be pushed to the remote is ON the hg repo in .git/hg/origin but not up on the remote server.

HG version 2.4.1 and git version 1.8.1.4
Note that I have been able to commit and push before from this system. So I have no idea why it is breaking now.

Now.. looking at the raw .hg data the branchheads has 3 "default" entries in it? could this be the cause of this?

Error mirroring bitbucket

Here the configuration in use

[remote "github"]
        url = [email protected]:lu-zero/moin-2.0.git
        fetch = +refs/heads/*:refs/remotes/github/*
[remote "origin"]
        url = hg::https://bitbucket.org/thomaswaldmann/moin-2.0
        fetch = +refs/heads/*:refs/remotes/origin/*
        pushurl = [email protected]:lu-zero/moin-2.0.git
[branch "master"]
        remote = origin
        merge = refs/heads/branches/default

Here the message

~/mirror/moin-2.0(master) $ git pull; git push                                                                                               
searching for changes
adding changesets
adding manifests
adding file changes
added 629 changesets with 1690 changes to 419 files
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/git-remote-hg", line 1322, in <module>
    sys.exit(main(sys.argv))
  File "/usr/lib/python-exec/python2.7/git-remote-hg", line 1293, in main
    marks = Marks(marks_path, repo)
  File "/usr/lib/python-exec/python2.7/git-remote-hg", line 119, in __init__
    self.load()
  File "/usr/lib/python-exec/python2.7/git-remote-hg", line 142, in load
    tmp = json.load(open(self.path))
  File "/usr/lib64/python2.7/json/__init__.py", line 290, in load
    **kw)
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Branching does not work as expected?

Trying git-remote-hg for the first time, I was not able to create a branch that was not totally disjoint from its ancestor.

Here is what I tried:

git checkout -b branches/newbranch hgremote/branches/default
# do some changes
git commit
git push hgremote branches/newbranch

This did create a new branch, but it had nothing in common with branches/default (probably because all the commits were rewritten as if they had always been on that branch?).
Was I doing something wrong? I was trying to create pull requests, see vcpromptignore and tailing-null from this repository. The other branches were created using hg itself.

I am using git-remote-hg 185852e from this repository and git 1.9.1/hg 2.8.2 from Ubuntu trusty, none of the .gitconfig options are set.

Force push to update a remote branch results in multiple heads

When I modify a commit and force push the result to a remote branch, Bitbucket seems to be confused by the multiple heads that result from this. An associated PR is not updated with the content of the new head.

I was wondering if it would be sensible to strip the previous head when doing something like that. Or maybe, git-remote-hg is already able to do that?

Steps to reproduce:

  1. git clone hg:...
  2. git checkout -b branches/my-new-feature
  3. git commit -m "New feature"
  4. git push origin branches/my-new-feature
  5. git commit --amend
  6. git push -f origin branches/my-new-feature

ImportError: No module named mercurial

I get an error trying to clone a repo with git-remote-hg on Raspbian:

pi@raspberrypi ~/sources $ git clone hg::https://code.google.com/p/markdownsharpCloning into 'markdownsharp'...
Traceback (most recent call last):
  File "/home/pi/bin/git-remote-hg", line 15, in <module>
    from mercurial import hg, ui, bookmarks, context, encoding
ImportError: No module named mercurial

From what I understand, I need to install the mercurial Python module. I tried to install it with easy_install, but I got some errors:

pi@raspberrypi ~/sources $ sudo easy_install-pypy -U mercurial                  Searching for mercurial
Reading https://pypi.python.org/simple/mercurial/
Best match: mercurial 3.3.2
Downloading https://pypi.python.org/packages/source/M/Mercurial/mercurial-3.3.2.tar.gz#md5=731f33b7c8c76e99efe74ab2c9ceebc8
Processing mercurial-3.3.2.tar.gz
Writing /tmp/easy_install-gPVxcO/mercurial-3.3.2/setup.cfg
Running mercurial-3.3.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-gPVxcO/mercurial-3.3.2/egg-dist-tmp-QwLz8d
mercurial/mpatch.c: In function 'fold':
mercurial/mpatch.c:294:3: warning: passing argument 2 of 'PyObject_AsCharBuffer' from incompatible pointer type [enabled by default]
/usr/lib/pypy-upstream/include/pypy_decl.h:280:17: note: expected 'char **' but argument is of type 'const char **'
mercurial/mpatch.c: In function 'patches':
mercurial/mpatch.c:324:2: warning: passing argument 2 of 'PyObject_AsCharBuffer' from incompatible pointer type [enabled by default]
/usr/lib/pypy-upstream/include/pypy_decl.h:280:17: note: expected 'char **' but argument is of type 'const char **'
mercurial/dirs.c: In function '_addpath':
mercurial/dirs.c:58:27: error: 'PyStringObject' has no member named 'ob_shash'
mercurial/dirs.c:66:26: error: lvalue required as left operand of assignment
mercurial/dirs.c:71:23: error: lvalue required as left operand of assignment
mercurial/dirs.c:81:22: error: lvalue required as left operand of assignment
mercurial/dirs.c: In function '_delpath':
mercurial/dirs.c:117:7: error: lvalue required as decrement operand
error: Setup script exited with error: command 'cc' failed with exit status 1

Sorry if it's a basic question, I don't know much about Python and Linux...

"Object [hash] already has a mark" on pushing

This looks similar to felipec/git#48, but I'm getting this on the latest version of standard Git (2.1) and the latest git-remote-hg:

searching for changes
no changes found
error: Object [hash] already has a mark
...(repeated several times with different [hash])...
searching for changes
...(and the push continues normally)...

Cloning error

I'm encountering an error while cloning pywin32 on cygwin. The hg repository clones fine. Versions: git 2.1.1, mercurial 3.0.1 (these are the latest on cygwin).

$ git clone hg::http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/
Cloning into 'pywin32'...
real URL is http://pywin32.hg.sourceforge.net:8000/hgroot/pywin32/pywin32/
requesting all changes
adding changesets
adding manifests
adding file changes
added 4354 changesets with 10537 changes to 1961 files
progress revision 99 'master' (100/4106)
progress revision 199 'master' (200/4106)
progress revision 299 'master' (300/4106)
progress revision 399 'master' (400/4106)
progress revision 499 'master' (500/4106)
progress revision 599 'master' (600/4106)
progress revision 699 'master' (700/4106)
progress revision 799 'master' (800/4106)
progress revision 899 'master' (900/4106)
progress revision 999 'master' (1000/4106)
progress revision 1099 'master' (1100/4106)
progress revision 1199 'master' (1200/4106)
progress revision 1299 'master' (1300/4106)
progress revision 1399 'master' (1400/4106)
progress revision 1499 'master' (1500/4106)
progress revision 1599 'master' (1600/4106)
progress revision 1699 'master' (1700/4106)
error: git-fast-import died of signal 11
fatal: Error while running fast-import
$ Traceback (most recent call last):                                                                                                                                                                                                   128 ↵
  File "/usr/bin/git-remote-hg", line 1322, in <module>
    sys.exit(main(sys.argv))
  File "/usr/bin/git-remote-hg", line 1306, in main
    do_import(parser)
  File "/usr/bin/git-remote-hg", line 718, in do_import
    export_head(repo)
  File "/usr/bin/git-remote-hg", line 616, in export_head
    export_ref(repo, g_head[0], 'bookmarks', g_head[1])
  File "/usr/bin/git-remote-hg", line 547, in export_ref
    modified_final = export_files(c.filectx(f) for f in modified)
  File "/usr/bin/git-remote-hg", line 276, in export_files
    fid = node.hex(f.filenode())
  File "/usr/lib/python2.7/site-packages/mercurial/context.py", line 528, in filenode
    return self._filenode
  File "/usr/lib/python2.7/site-packages/mercurial/util.py", line 287, in __get__
    result = self.func(obj)
  File "/usr/lib/python2.7/site-packages/mercurial/context.py", line 483, in _filenode
    return self._filelog.lookup(self._fileid)
  File "/usr/lib/python2.7/site-packages/mercurial/revlog.py", line 840, in lookup
    raise LookupError(id, self.indexfile, _('no match found'))
mercurial.error.LookupError: data/com/win32com/util.py.i@0c5f158ba9cd: no match found
close failed in file object destructor:
sys.excepthook is missing

Support mercurial subrepositories

Any plans to support mercurial subrepositories via .hgsub? I just checked out a repository with them and noticed they weren't pulled.

Concurrency is not supported

As @felipec stated on issue #16, "Concurrency is not supported".

This should then at least be documented as a known issue, as it can corrupt the internal state of git-remote-hg.

Of course a better solution would be if git-remote-hg used e.g. some kind of locking to prevent multiple processes of accessing the marks files simultaneously. So concurrency would still not be supported, but it would lead to an error, instead of silent (and possibly quite fatal) failure.

ERROR: Repository error

I try the command and this happens:

~/pychess$ git remote add -f i175 "hg::https://[email protected]/r/gniusck-175/"
Updating i175
ERROR: Repository error
error: Could not fetch i175

Other relevant info

Git 2.1.0 on Ubuntu with the latest version of git-remote-hg. I will leave the repo open for you to see if it is general or not.

Crash with "broken pipe"

While trying to pull changes into a clone of the CPython repo with git fetch origin, I got the following crash:

searching for changes
no changes found
fatal: mark :289218 not declared
fast-import: dumping crash report to .git/fast_import_crash_17220
fatal: Error while running fast-import
Traceback (most recent call last):
  File "/home/larsb/bin/git-remote-hg", line 1322, in <module>
    sys.exit(main(sys.argv))
  File "/home/larsb/bin/git-remote-hg", line 1306, in main
    do_import(parser)
  File "/home/larsb/bin/git-remote-hg", line 721, in do_import
    export_branch(repo, branch)
  File "/home/larsb/bin/git-remote-hg", line 613, in export_branch
    export_ref(repo, branch, 'branches', head)
  File "/home/larsb/bin/git-remote-hg", line 547, in export_ref
    modified_final = export_files(c.filectx(f) for f in modified)
  File "/home/larsb/bin/git-remote-hg", line 288, in export_files
    print d
IOError: [Errno 32] Broken pipe

Crash report fast_import_crash_17220 reads:

fast-import crash report:
    fast-import process: 17220
    parent process     : 17219
    at Mon Aug 4 20:23:06 2014

fatal: mark :289218 not declared

Most Recent Commands Before Crash
---------------------------------
  feature done
  feature import-marks=.git/hg/origin/marks-git
  feature export-marks=.git/hg/origin/marks-git
  feature force
  blob
  mark :289220
  data 196121
  commit refs/hg/origin/branches/default
  mark :289221
  author Tal Einat <[email protected]> 1405518740 +0300
  committer Tal Einat <[email protected]> 1405518740 +0300
  data 66
* from :289218

Active Branch LRU
-----------------
    active_branches = 0 cur, 5 max

  pos  clock name
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Inactive Branches
-----------------
refs/hg/origin/branches/default:
  status      : dirty
  tip commit  : 0000000000000000000000000000000000000000
  old tree    : 0000000000000000000000000000000000000000
  cur tree    : 0000000000000000000000000000000000000000
  commit clock: 0
  last pack   : 


Marks
-----
  exported to .git/hg/origin/marks-git

-------------------
END OF CRASH REPORT

git-remote-hg version is 185852e.

cloning bitbucket repos fail

Hi,

cloning bitbucket repos all seems to fail like this

git clone hg::https://bitbucket.org/pytest-dev/pytest aa.git

Cloning into 'aa.git'...
Traceback (most recent call last):
File "/sbin/git-remote-hg", line 1307, in
sys.exit(main(sys.argv))
File "/sbin/git-remote-hg", line 1271, in main
repo = get_repo(url, alias)
File "/sbin/git-remote-hg", line 429, in get_repo
repo.pull(peer, heads=None, force=True)
File "/usr/lib/python2.7/site-packages/mercurial/repoview.py", line 311, in getattr
return getattr(self._unfilteredrepo, attr)
AttributeError: 'localrepository' object has no attribute 'pull'

Archlinux
git version 2.3.7
git-remote-hg version 0.2-2
mercirual (3.3.x and 3.4)

Error with local cloning

Hi
I am trying to clone from local file repo but failing all the way

I tried
"hg::localhg:cloned"
"hg::file://localhg:cloned"

all fails with the error

cloning into 'fromhg'...
Traceback (most recent call last):
File "/usr/bin/git-remote-hg", line 1322, in
sys.exit(main(sys.argv))
File "/usr/bin/git-remote-hg", line 1286, in main
repo = get_repo(url, alias)
File "/usr/bin/git-remote-hg", line 394, in get_repo
repo = hg.repository(myui, url)
File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 119, in repository
peer = _peerorrepo(ui, path, create)
File "/usr/lib/python2.7/dist-packages/mercurial/hg.py", line 106, in _peerorrepo
obj = peerlookup(path).instance(ui, path, create)
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 1777, in instance
return localrepository(ui, util.urllocalpath(path), create)
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 249, in init
raise error.RepoError(
("repository %s not found") % path)
mercurial.error.RepoError: repository ./del:fromhg not found

'module' object has no attribute 'write'

I don't really know enough to troubleshoot this. I have this repo as a submodule in my personal dotfiles repo. Here's the bug reproduced in a standard clone. All the other hg submodules worked fine.

$ git clone hg::https://bitbucket.org/marmoute/mutable-history
Cloning into 'mutable-history'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 1720 changesets with 3018 changes to 168 files (+2 heads)
adding remote bookmark @
ERROR: 'module' object has no attribute 'write'

Make writing of marks files atomic

Right now, git-remote-hg can die while in the middle of writing the marks files, fatally corrupting the state of git-remote-hg, and potentially forcing the user to make a fresh clone.

Things would be better if the marks files were writing atomically, or if at least the time during which a dieing process would cause issues was minimized. E.g. write the the marks first to new files; then swap old and new files atomically (on systems that support that; on systems that don't, first move the old files away, then move the new files into place, then delete the old files; this way, it is quite easy to recover manually).

incorrect conversion for half-hour time zones in western hemisphere

git-remote-hg miscalculates the time-zone offsets for time zones that don't have a full-hour offset and are located west of UTC (e.g. St. John's, Newfoundland).

Basically it's caused because int(3.5) == 3 but int(-3.5) != 3.

The attached script demonstrates the issue:

$ python convert_timezone.py 

Implementation in git-remote-hg (fails for St. John's)
------------------------------------------------------
Name         | ISO TZ  int tz  | gittz(tz)  pytz(TZ)   | iso->int->iso 
Tehran       |  +0330  -12600  |   +0330     -12600    |   +0330   
Berlin       |  +0100   -3600  |   +0100      -3600    |   +0100   
UTC          |  +0000     0    |   +0000        0      |   +0000   
St. John's   |  -0330   12600  |   -0430  *   10200  * |   -0310  *
Halifax      |  -0400   14400  |   -0400      14400    |   -0400   
Toronto      |  -0500   18000  |   -0500      18000    |   -0500   
Calgary      |  -0700   25200  |   -0700      25200    |   -0700   
Vancouver    |  -0800   28800  |   -0800      28800    |   -0800   

Correct implementation
----------------------
Name         | ISO TZ  int tz  | gittz(tz)  pytz(TZ)   | iso->int->iso 
Tehran       |  +0330  -12600  |   +0330     -12600    |   +0330   
Berlin       |  +0100   -3600  |   +0100      -3600    |   +0100   
UTC          |  +0000     0    |   +0000        0      |   +0000   
St. John's   |  -0330   12600  |   -0330      12600    |   -0330   
Halifax      |  -0400   14400  |   -0400      14400    |   -0400   
Toronto      |  -0500   18000  |   -0500      18000    |   -0500   
Calgary      |  -0700   25200  |   -0700      25200    |   -0700   
Vancouver    |  -0800   28800  |   -0800      28800    |   -0800   

$ python convert_timezone.py test
**********************************************************************
File "convert_timezone.py", line 12, in __main__.gittz
Failed example:
    gittz(int(3.5*3600))    # St. John's (fails!)
Expected:
    '-0330'
Got:
    '-0430'
**********************************************************************
File "convert_timezone.py", line 47, in __main__.pytz
Failed example:
    pytz('-0330')   # St. John's (fails!)
Expected:
    12600
Got:
    10200
**********************************************************************
2 items had failures:
   1 of   4 in __main__.gittz
   1 of   4 in __main__.pytz
***Test Failed*** 2 failures.

Pull-request with fix is coming up.
convert_timezone.txt

httplib.IncompleteRead: IncompleteRead(31 bytes read)

The following error happened while cloning one repo:

Cloning into 'repos/2013-2-1172-aa-tree'...
Traceback (most recent call last):
  File "/home/kenorb/bin/git-remote-hg", line 1322, in <module>
    sys.exit(main(sys.argv))
  File "/home/kenorb/bin/git-remote-hg", line 1286, in main
    repo = get_repo(url, alias)
  File "/home/kenorb/bin/git-remote-hg", line 433, in get_repo
    repo.pull(peer, heads=None, force=True)
  File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 1545, in pull
    force=force)
  File "/usr/lib/python2.7/dist-packages/mercurial/discovery.py", line 45, in findcommonincoming
    abortwhenunrelated=not force)
  File "/usr/lib/python2.7/dist-packages/mercurial/setdiscovery.py", line 109, in findcommonheads
    batch.submit()
  File "/usr/lib/python2.7/dist-packages/mercurial/wireproto.py", line 76, in submit
    self._submitreq(req, rsp)
  File "/usr/lib/python2.7/dist-packages/mercurial/wireproto.py", line 78, in _submitreq
    encresults = self.remote._submitbatch(req)
  File "/usr/lib/python2.7/dist-packages/mercurial/wireproto.py", line 160, in _submitbatch
    rsp = self._call("batch", cmds=';'.join(cmds))
  File "/usr/lib/python2.7/dist-packages/mercurial/httprepo.py", line 171, in _call
    return fp.read()
  File "/usr/lib/python2.7/dist-packages/mercurial/keepalive.py", line 425, in read
    s = self._rbuf + self._raw_read(amt)
  File "/usr/lib/python2.7/httplib.py", line 541, in read
    return self._read_chunked(amt)
  File "/usr/lib/python2.7/dist-packages/mercurial/keepalive.py", line 448, in _read_chunked
    raise httplib.IncompleteRead(value)
httplib.IncompleteRead: IncompleteRead(31 bytes read)

This happened for this one:

git clone "hg::https://code.google.com/p/2013-2-1172-aa-tree/"

but I can't reproduce it after second try, so not sure if there is anything to fix.

last-note sometimes points to a non existing mark

This is a continuation from issue #4.

Here's a script that reproduces the issue:

#!/bin/sh

rm -rf test_hg test_git

(
hg init test_hg
cd test_hg
echo A >> content
hg add content
hg commit -m A
)

(
git clone hg::test_hg test_git
cd test_git

echo B >> content
git commit -a -m B
git push
git fetch
)

(
cd test_hg
hg strip tip
hg log
)

(
cd test_git
git log
git fetch
git commit --amend --message="B"
git reflog expire --expire=now --all
git gc --prune=now
git fetch
git fetch
)

Each fetch adds a commit on refs/notes/hg, even if nothing changed

Every time I run git fetch, I get a new commit on refs/notes/hg, even if nothing changed.

$ git show notes/hg
commit 187ab7fdc53e6e4d8360a13a781c721386fda2c4
Author: remote-hg <>
Date:   Sun Sep 14 20:12:15 2014 -0500

    Notes for default
$ git fetch
searching for changes
no changes found
$ git show notes/hg
commit d4e9aa183875ac5bda2b177a311c4f8247bc2e77
Author: remote-hg <>
Date:   Sun Sep 14 21:00:09 2014 -0500

    Notes for default

Clone on windows fails due to invalid names

Hi, trying to clone a Mercurial repo on Windows using git-remote-hg, but it bombs out due to an attempt to create a file who's fileName contains illegal characters for a fileName on Windows (in my case the fileName contains double quotes, but single quotes, slashes, astrixes or questionMarks would have the same issue).

Now, I was wondering if this something that could be made to work properly inside git-remote-hg somehow, for example by escaping those invalid characters and perform the needed mapping, so as a user you don't have to worry about it.

Or should I just bite the bullet and try to fix my repo somehow?

Online resources tell me to configure my git repo to do a sparse checkout, excluding the files causing issues. Can look into this, but it requires to alter the git config file in your repo and since I'm still gloning, I don't have such a repo nor config file yet

TypeError: expected string or Unicode object, NoneType found

I have an empty mercurial repository that I want to add as a remote to a current git repo and push to, but when I run git push origin master I get the following error:

searching for changes
no changes found
searching for changes
Traceback (most recent call last):
File "/home/mostafa/bin/git-remote-hg", line 1330, in <module>
    sys.exit(main(sys.argv))
File "/home/mostafa/bin/git-remote-hg", line 1316, in main
    do_export(parser)
File "/home/mostafa/bin/git-remote-hg", line 1193, in do_export
    if not push(parser.repo, peer, parsed_refs, p_revs):
File "/home/mostafa/bin/git-remote-hg", line 1079, in push
    ret = push_unsafe(repo, remote, parsed_refs, p_revs)
File "/home/mostafa/bin/git-remote-hg", line 1048, in push_unsafe
    cg = repo.getbundle('push', heads=list(p_revs), common=common)
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 2021, in getbundle
    discovery.outgoing(cl, common, heads))
File "/usr/lib/python2.7/dist-packages/mercurial/localrepo.py", line 1996, in getlocalbundle
    if not outgoing.missing:
File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 277, in __get__
    result = self.func(obj)
File "/usr/lib/python2.7/dist-packages/mercurial/discovery.py", line 87, in missing
    self._computecommonmissing()
File "/usr/lib/python2.7/dist-packages/mercurial/discovery.py", line 75, in _computecommonmissing
    self.missingheads)
File "/usr/lib/python2.7/dist-packages/mercurial/revlog.py", line 401, in findcommonmissing
    heads = [self.rev(n) for n in heads]
File "/usr/lib/python2.7/dist-packages/mercurial/changelog.py", line 184, in rev
    r = super(changelog, self).rev(node)
File "/usr/lib/python2.7/dist-packages/mercurial/revlog.py", line 298, in rev
    return self._nodecache[node]
TypeError: expected string or Unicode object, NoneType found

(The line numbers in the traceback may not be very accurate because I had added some print statements to the code).

I did a bit of poking around and found out that the heads argument passed on frame 5 of the above traceback is None because p_revs has a value of {None: 'refs/heads/master'}.

Broken pipe due to fast-import crash

Sporadically, I get a broken pipe error when fast-import crashes, which prevents syncing the hg repo.

Here's the relevant output:

git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree fetch origin 
fatal: mark :26940 not declared
fast-import: dumping crash report to .git/fast_import_crash_15105
fatal: Error while running fast-import
Traceback (most recent call last):
  File "/usr/local/bin/git-remote-hg", line 1311, in <module>
    sys.exit(main(sys.argv))
  File "/usr/local/bin/git-remote-hg", line 1295, in main
    do_import(parser)
  File "/usr/local/bin/git-remote-hg", line 721, in do_import
    export_branch(repo, branch)
  File "/usr/local/bin/git-remote-hg", line 613, in export_branch
    export_ref(repo, branch, 'branches', head)
  File "/usr/local/bin/git-remote-hg", line 547, in export_ref
    modified_final = export_files(c.filectx(f) for f in modified)
  File "/usr/local/bin/git-remote-hg", line 288, in export_files
    print d
IOError: [Errno 32] Broken pipe
Completed with errors, see above

The last time this happened, I resolved it by re-cloning the hg repo, which is an extreme solution. I'd rather fix this differently because I keep multiple clones of the git repo that all need to be re-cloned if I alter the original.

Here's the related fast_import_crash_15105:

fast-import crash report:
    fast-import process: 15105
    parent process     : 15104
    at Mon Jun 2 16:56:07 2014

fatal: mark :26940 not declared

Most Recent Commands Before Crash
---------------------------------
  feature done
  feature import-marks=.git/hg/origin/marks-git
  feature export-marks=.git/hg/origin/marks-git
  feature force
  blob
  mark :26952
  data 5144
  blob
  mark :26953
  data 719
  blob
  mark :26954
  data 545
  blob
  mark :26955
  data 363
  blob
  mark :26956
  data 1315
  blob
  mark :26957
  data 181
  blob
  mark :26958
  data 4553
  blob
  mark :26959
  data 1260
  blob
  mark :26960
  data 1346
  blob
  mark :26961
  data 461
  commit refs/hg/origin/branches/default
  mark :26962
  author fgb <unknown> 1401491792 -0700
  committer fgb <unknown> 1401491792 -0700
  data 35
* from :26940

Active Branch LRU
-----------------
    active_branches = 0 cur, 5 max

  pos  clock name
 '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

Inactive Branches
-----------------
refs/hg/origin/branches/default:
  status      : dirty
  tip commit  : 0000000000000000000000000000000000000000
  old tree    : 0000000000000000000000000000000000000000
  cur tree    : 0000000000000000000000000000000000000000
  commit clock: 0
  last pack   : 


Marks
-----
  exported to .git/hg/origin/marks-git

-------------------
END OF CRASH REPORT

Any help would be welcome. Thanks for the great plugin.

Pushing to branches fails..

hg repo is at https://hg.mozilla.org/build/puppet if you want to have a look

As advertised in the README:

(sandbox)dustin@euclid ~/code/puppetagain/t/puppetagain [moco] $ git push moco branches/default
searching for changes
no changes found
error: src refspec branches/default does not match any.
error: failed to push some refs to 'hg::ssh://hg.mozilla.org/build/puppet'

and since that says "src refspec", maybe it's trying to parse that as a local refspec?

(sandbox)dustin@euclid ~/code/puppetagain/t/puppetagain [moco] $ git push moco moco:branches/default
searching for changes
no changes found
fatal: remote-helpers do not support old:new syntax
ERROR: unhandled export command: 

Here's my config:

(sandbox)dustin@euclid ~/code/puppetagain/t/puppetagain [moco] $ cat .git/config 
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        notesRef = refs/notes/hg

[remote "moco"]
        url = hg::ssh://hg.mozilla.org/build/puppet
        fetch = +refs/heads/*:refs/remotes/moco/*

[branch "moco"]
        remote = moco
        merge = refs/heads/branches/default

and local branches:

(sandbox)dustin@euclid ~/code/puppetagain/t/puppetagain [moco] $ git branch -av | grep moco
* moco                             40270ad [ahead 1] Add README.md; a=NPTOB
  remotes/moco/branches/default    099d4b3 Bug 986599: disable filebucket for Concat; r=rail
  remotes/moco/branches/production 82d2c32 Merge default -> production
  remotes/moco/master              099d4b3 Bug 986599: disable filebucket for Concat; r=rail
  remotes/moco/moco                40270ad Add README.md; a=NPTOB

Finally, if I just run 'git push moco', it works, although it rejects the remote and I need to do a pull --rebase to fix it:

(sandbox)dustin@euclid ~/code/puppetagain/t/puppetagain [moco] $ git push moco
searching for changes
no changes found
searching for changes
To hg::ssh://hg.mozilla.org/build/puppet
 ! [remote rejected] moco -> moco
error: failed to push some refs to 'hg::ssh://hg.mozilla.org/build/puppet'
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
remote: Trying to insert into pushlog.
remote: Please do not interrupt...
remote: Inserted into the pushlog db successfully.
remote: You can view your change at the following URL:
remote:   https://hg.mozilla.org/build/puppet/rev/c1298edd65ec

This also has the side-effect of creating a 'moco' bookmark on the hg repo. At least, sometimes it does -- on this attempt it did not.

"AttributeError: 'localrepository' object has no attribute 'pull'" with hg 3.2.4 on Mac OS 10.10

When I try to clone my hg repo (which works with hg), I get:

Cloning into 'my-repo'...
Traceback (most recent call last):
  File "/Users/dmoles/bin/git-remote-hg", line 1322, in <module>
    sys.exit(main(sys.argv))
  File "/Users/dmoles/bin/git-remote-hg", line 1286, in main
    repo = get_repo(url, alias)
  File "/Users/dmoles/bin/git-remote-hg", line 433, in get_repo
    repo.pull(peer, heads=None, force=True)
  File "/Library/Python/2.7/site-packages/mercurial/repoview.py", line 307, in __getattr__
    return getattr(self._unfilteredrepo, attr)
AttributeError: 'localrepository' object has no attribute 'pull'

My hg version is 3.2.4+20150107, and my git version is 1.9.3 (Apple Git-50). I'm using revision 3cb0da9 of git-remote-hg.

Push to bitbucket not working with latest git-remote-hg

I have Git version 1.8.5, Mercurial 3.1.1 and latest git-remote-hg git revision, and when trying to push, I get this:

Traceback (most recent call last):
File "/usr/bin/git-remote-hg", line 1322, in
sys.exit(main(sys.argv))
File "/usr/bin/git-remote-hg", line 1308, in main
do_export(parser)
File "/usr/bin/git-remote-hg", line 1185, in do_export
if not push(parser.repo, peer, parsed_refs, p_revs):
File "/usr/bin/git-remote-hg", line 1073, in push
ret = push_unsafe(repo, remote, parsed_refs, p_revs)
File "/usr/bin/git-remote-hg", line 1048, in push_unsafe
ret = remote.unbundle(cg, remoteheads, 'push')
File "/Library/Python/2.7/site-packages/mercurial-3.1.1-py2.7-macosx-10.9-intel.egg/mercurial/wireproto.py", line 395, in unbundle
stream = self._calltwowaystream('unbundle', cg, heads=heads)
File "/Library/Python/2.7/site-packages/mercurial-3.1.1-py2.7-macosx-10.9-intel.egg/mercurial/httppeer.py", line 222, in _calltwowaystream
d = fp.read(4096)
AttributeError: 'NoneType' object has no attribute 'read'

fatal: Unable to find remote helper for 'hg'

I'm trying to get up and running with this for the first time. I downloaded the git-remote-hg script into ~/bin which is on my PATH. However I cannot get the example in the README to work:

$ git clone "hg::http://selenic.com/repo/hello"
Cloning into 'hello'...
fatal: Unable to find remote helper for 'hg'

When I open a new terminal window, I get this:

$ which git-remote-hg
(nothing)

$ type git-remote-hg
git-remote-hg is /Users/andy/bin/git-remote-hg

I'm using this repo @ 185852e and git v1.8.2.3, Mercurial v3.2.1, bash on OS X.

Presumably I'm making some kind of silly mistake somewhere. I'd be grateful if you could point it out :)

Error when cloning a repo: Cannot lock ref...

Recently git-remote-hg started giving an error when I was pulling from our corporate Mercurial repo. I did not update git-remote-hg nor Mercurial, it seems to be a git-remote-hg's issue with our repo. When I tried clone the repo to start with a clean one, I got the same error:

Cloning into 'android_framework'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 1674 changesets with 7397 changes to 2720 files (+2 heads)
progress revision 99 'master' (100/1613)
progress revision 199 'master' (200/1613)
progress revision 299 'master' (300/1613)
progress revision 399 'master' (400/1613)
progress revision 499 'master' (500/1613)
progress revision 599 'master' (600/1613)
progress revision 699 'master' (700/1613)
progress revision 799 'master' (800/1613)
progress revision 899 'master' (900/1613)
progress revision 999 'master' (1000/1613)
progress revision 1099 'master' (1100/1613)
progress revision 1199 'master' (1200/1613)
progress revision 1299 'master' (1300/1613)
progress revision 1399 'master' (1400/1613)
progress revision 1599 'freestyle' (1600/1649)
error: Cannot lock ref 'refs/hg/origin/tags/Bitrix24/Release/3.1': 'refs/hg/origin/tags/Bitrix24/Release/3.1/270' exists; cannot create 'refs/hg/origin/tags/Bitrix24/Release/3.1'
fatal: Error while running fast-import
Traceback (most recent call last):
File "/usr/bin/git-remote-hg", line 1322, in
sys.exit(main(sys.argv))
File "/usr/bin/git-remote-hg", line 1315, in main
marks.store()
File "/usr/bin/git-remote-hg", line 167, in store
json.dump(self.dict(), open(self.path, 'w'))
IOError: [Errno 2] No such file or directory: '/home/burjui/tmp/android_framework/.git/hg/origin/marks-hg'

I'm not sure if I can provide access to our corporate repo, but I can help debug stuff.

"whole repo is rebased"

I used git-remote-hg to author a patch for pylint, and everything worked flawlessly until the time came that upstream tried to merge: https://bitbucket.org/hpk42/pytest/pull-request/249/fix-handling-of-objects-with-non-ascii/activity

"""
Ronny Pfannschmidt DECLINED pull request #249:
uppon trying to pull local changes it seems like the repo was rebased please recreate the changes on a fresh repo
"""

Is this a bug, or simply an unsupported workflow? Or, do I need to configure / use git-remote-hg differently git this to work?

KeyError: '0000000000000000000000000000000000000000'

I get the following error when trying to clone ssh://[email protected]/lyro/evil. Do you have an idea why that might be happening? Thanks for your help!

Cloning into 'evil'...
requesting all changes
adding changesets
adding manifests
adding file changes
added 1697 changesets with 3546 changes to 51 files (+1 heads)
progress revision 0 'master' (0/1697)
progress revision 100 'master' (100/1697)
...
progress revision 1600 'master' (1600/1697)
Traceback (most recent call last):
  File "/home/jonas/bin/git-remote-hg", line 1246, in <module>
    sys.exit(main(sys.argv))
  File "/home/jonas/bin/git-remote-hg", line 1228, in main
    do_import(parser)
  File "/home/jonas/bin/git-remote-hg", line 679, in do_import
    export_bookmark(repo, bmark)
  File "/home/jonas/bin/git-remote-hg", line 566, in export_bookmark
    export_ref(repo, bmark, 'bookmarks', head)
  File "/home/jonas/bin/git-remote-hg", line 531, in export_ref
    print "from :%u" % rev_to_mark(head)
  File "/home/jonas/bin/git-remote-hg", line 432, in rev_to_mark
    return marks.from_rev(rev.hex())
  File "/home/jonas/bin/git-remote-hg", line 168, in from_rev
    return self.marks[rev]
KeyError: '0000000000000000000000000000000000000000'
fatal: stream ends early
fast-import: dumping crash report to /tmp/evil/.git/fast_import_crash_14506
fatal: Error while running fast-import

bad operand type when pushing.

I cloned a Mecurial repository via the latest version of this script.. and upon pushing came up with this stack trace.

Traceback (most recent call last):
  File "/Users/urkle/bin/git-remote-hg", line 1322, in <module>
    sys.exit(main(sys.argv))
  File "/Users/urkle/bin/git-remote-hg", line 1308, in main
    do_export(parser)
  File "/Users/urkle/bin/git-remote-hg", line 1185, in do_export
    if not push(parser.repo, peer, parsed_refs, p_revs):
  File "/Users/urkle/bin/git-remote-hg", line 1073, in push
    ret = push_unsafe(repo, remote, parsed_refs, p_revs)
  File "/Users/urkle/bin/git-remote-hg", line 1036, in push_unsafe
    if not checkheads(repo, remote, p_revs):
  File "/Users/urkle/bin/git-remote-hg", line 1005, in checkheads
    ancestors = repo.changelog.ancestors([rev], stoprev=min(old))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/revlog.py", line 369, in ancestors
    inclusive=inclusive)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/ancestor.py", line 242, in __init__
    self._containsvisit = [-rev for rev in revs]
TypeError: bad operand type for unary -: 'NoneType'

I'm using Mecurial 3.1 on python 2.7.8 (mac ports)

"git fetch" is extremely slow on large repos

After cloning a large Mercurial repository (16K+ commits, 820 heads) using git-remote-hg, running git fetch is extremely slow. This is the case even when the source repository is local (i.e., on the same machine).

The following two lines are output almost immediately:

searching for changes
no changes found

It then takes between 3-4 minutes before the command finishes.

Cloning the repository takes about 7 minutes. A push to the same repository completes very quickly (under 1 second).

If tip commit of local hg repo is stripped, git-remote-hg does not automatically recover

Suppose you have a local hg repository, and a git clone of that, both are fully in sync. Now the tip commit of the remote hg repository is stripped. If one does git pull, then origin/master is correctly updated.

I expected to be able to push the old commit (stripped from hg, but still present on the git side) out again, but not so, instead I get into this "infinite cycle" and no commit appears in the hg repo:

$ git push
To hg::/path/to/test.hg
   18b66f9..4b5fcb1  master -> master
$ git pull
From hg::/path/to/test.hg
 + 4b5fcb1...18b66f9 master     -> origin/master  (forced update)
Already up-to-date.
$ git pull
Already up-to-date.
$ git push
To hg::/path/to/test.hg
   18b66f9..4b5fcb1  master -> master
$ git pull
From hg::/path/to/test.hg
 + 4b5fcb1...18b66f9 master     -> origin/master  (forced update)
Already up-to-date.
$ git pull
Already up-to-date.

I guess this is because the marks file still references the commit, but the commit is gone in the repository. And since for local hg repositories no clone is made, it cannot recover from it.

Note that everything works fine if I set the GIT_REMOTE_HG_TEST_REMOTE env to force the creation of a clone even for local repositories.

So one possible fix would be to simply remove the special case for local repositories.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.