25 Commits
v0.2 ... v0.3

Author SHA1 Message Date
Felipe Contreras
b6e9475918 readme: mention Mercurial dependency
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2016-05-16 23:37:08 -05:00
Lars Noschinski
517ceb91ac Fix import of broken committers
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2016-05-16 22:44:49 -05:00
Felipe Contreras
114804f0cb travis: add more Mercurial versions
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2016-05-16 22:29:50 -05:00
Felipe Contreras
b022367aef test: temporarily disable hg-git tests
They work, but they need too many changes in different packages.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2016-05-16 22:29:50 -05:00
Felipe Contreras
18626d346f Revert "test: use C.UTF-8 locale in tests"
This reverts commit f53a8653ab.

It turns out Debian and Fedora do provide the C.UTF-8 locale, but other
distributions don't.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2016-05-16 22:29:50 -05:00
Felipe Contreras
b81ec14c2e Improve hg-git compatibility
Recent versions of Mercurial check if a filectx is the same as the
parents, and avoid creating a new filelog. This is what we want, but
hg-git doesn't do that.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2016-05-16 22:29:50 -05:00
Felipe Contreras
1e279075dc Add compatibility for Mercurial v3.2
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2016-05-16 22:29:50 -05:00
Felipe Contreras
02a0a59a4b travis: force version of hg-git
The latest that works.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2016-05-16 17:56:25 -05:00
Felipe Contreras
185852eac4 test: cleanup hg-git test
We don't need hgext.bookmarks since a long long time (ever).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-06-03 06:00:02 -05:00
Felipe Contreras
29a0d8a0e3 test: skip tests with broken hg-git compatibility
https://bitbucket.org/durin42/hg-git/issue/115/

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-06-02 18:42:17 -05:00
Felipe Contreras
aa528c9649 Fix memfilectx API change
It will change in 3.1.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-06-02 17:49:56 -05:00
Felipe Contreras
018aa4753b Improve version parsing
Development versions have extra stuff in the form of
'version+distance-id'.

Let's assume we are already in the next major version when in
development.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-06-02 17:49:29 -05:00
Felipe Contreras
f173208406 build: don't install docs by default
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-31 15:58:33 -05:00
Felipe Contreras
e7df347fab readme: fix not about v2.0
It didn't get in.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-31 15:49:28 -05:00
Brian Gernhardt
0de8aa91f4 build: avoid non-portable install -D
BSD install doesn't understand the -D option. Use a separate install
command to create the directory (with the -d option) before installing
the file.

Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-31 15:41:28 -05:00
Paul Wise
22d9794c11 test: add compatibility with Debian hg-git package
Debian has named the hggit python module as hgext.git.

Signed-off-by: Paul Wise <pabs3@bonedaddy.net>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-30 17:37:01 -05:00
Paul Wise
f53a8653ab test: use C.UTF-8 locale in tests
The en_US.UTF-8 locale is not guaranteed to exist, and if it doesn't,
several tests fail.

Signed-off-by: Paul Wise <pabs3@bonedaddy.net>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-30 17:37:01 -05:00
Paul Wise
b4c63539f2 Ignore the generated manual page
Signed-off-by: Paul Wise <pabs3@bonedaddy.net>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-30 17:37:01 -05:00
Paul Wise
38070007aa build: general improvements
Allow customising the bin and manual page dirs.

Signed-off-by: Paul Wise <pabs3@bonedaddy.net>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-30 17:37:01 -05:00
Felipe Contreras
fadd5f698b test: improve test locations
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-22 22:09:28 -05:00
Felipe Contreras
1eb8fa4805 readme: add contributing section
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-13 14:26:45 -05:00
Felipe Contreras
19f31c1c84 doc: add help for sending patches
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-13 14:26:32 -05:00
Felipe Contreras
ff221de459 Split multiple import lines
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-10 23:54:33 -05:00
Felipe Contreras
179fefda96 More pep8 fixes
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-10 23:49:49 -05:00
Felipe Contreras
c226ba3904 remote-hg,bzr: conform more to pep8
Reported-by: William Giokas <1007380@gmail.com>

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-05-10 01:01:20 -05:00
10 changed files with 111 additions and 38 deletions

View File

@@ -5,7 +5,7 @@ install:
then pip install -q Mercurial${HG_VERSION+==$HG_VERSION};
else pip install -q http://selenic.com/repo/hg/archive/tip.tar.gz;
fi
- pip install -q dulwich hg-git || true
- pip install -q dulwich hg-git==0.6.1 || true
before_script:
- hg --version || true
@@ -20,6 +20,9 @@ matrix:
- env: HG_VERSION=2.8.2
- env: HG_VERSION=2.7.2
- env: HG_VERSION=3.0
- env: HG_VERSION=3.5.2
- env: HG_VERSION=3.6.3
- env: HG_VERSION=3.7
- env: HG_VERSION=dev
- python: 2.7
- python: 2.6

View File

@@ -1,6 +1,9 @@
prefix := $(HOME)
all:
bindir := $(prefix)/bin
mandir := $(prefix)/share/man/man1
all: doc
doc: doc/git-remote-hg.1
@@ -10,14 +13,17 @@ test:
doc/git-remote-hg.1: doc/git-remote-hg.txt
a2x -d manpage -f manpage $<
clean:
$(RM) doc/git-remote-hg.1
D = $(DESTDIR)
install:
install -D -m 755 git-remote-hg \
$(D)$(prefix)/bin/git-remote-hg
install -d -m 755 $(D)$(bindir)/
install -m 755 git-remote-hg $(D)$(bindir)/git-remote-hg
install-doc: doc
install -D -m 644 doc/git-remote-hg.1 \
$(D)$(prefix)/share/man/man1/git-remote-hg.1
install -d -m 755 $(D)$(mandir)/
install -m 644 doc/git-remote-hg.1 $(D)$(mandir)/git-remote-hg.1
.PHONY: all test
.PHONY: all test install install-doc clean

View File

@@ -15,6 +15,8 @@ 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:
@@ -109,8 +111,8 @@ Limitations of the remote-helpers' framework apply. In particular, these
commands don't work:
* `git push origin :branch-to-delete`
* `git push origin old:new` (it will push 'old') (Git v2.0)
* `git push --dry-run origin branch` (it will push) (Git v2.0)
* `git push origin old:new` (it will push 'old') (patches available)
* `git push --dry-run origin branch` (it will push) (patches available)
== Other projects ==
@@ -122,3 +124,8 @@ this is the one distributed officially by the Git project:
For a comparison between these and other projects go
https://github.com/felipec/git/wiki/Comparison-of-git-remote-hg-alternatives[here].
== Contributing ==
Send your patches to the mailing list git-fc@googlegroups.com (no need to
subscribe).

1
doc/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
git-remote-hg.1

5
doc/SubmittingPatches Normal file
View File

@@ -0,0 +1,5 @@
Please send your patches using `git format-patch` to the mailing list:
git-fc@googlegroups.com.
Make sure all the tests pass by running `make test`, and if possible add a new
test to exercise the code you are submitting.

View File

@@ -12,7 +12,8 @@
# For remote repositories a local clone is stored in
# "$GIT_DIR/hg/origin/clone/.hg/".
from mercurial import hg, ui, bookmarks, context, encoding, node, error, extensions, discovery, util
from mercurial import hg, ui, bookmarks, context, encoding
from mercurial import node, error, extensions, discovery, util
from mercurial import changegroup
import re
@@ -23,7 +24,8 @@ import shutil
import subprocess
import urllib
import atexit
import urlparse, hashlib
import urlparse
import hashlib
import time as ptime
#
@@ -157,7 +159,9 @@ class Marks:
self.version = 2
def dict(self):
return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version, 'last-note' : self.last_note }
return { 'tips': self.tips, 'marks': self.marks,
'last-mark': self.last_mark, 'version': self.version,
'last-note': self.last_note }
def store(self):
json.dump(self.dict(), open(self.path, 'w'))
@@ -426,7 +430,12 @@ def get_repo(url, alias):
peer = hg.peer(repo.ui, {}, url)
except:
die('Repository error')
repo.pull(peer, heads=None, force=True)
if check_version(3, 0):
from mercurial import exchange
exchange.pull(repo, peer, heads=None, force=True)
else:
repo.pull(peer, heads=None, force=True)
updatebookmarks(repo, peer)
@@ -453,12 +462,12 @@ def gitrange(repo, a, b):
positive.append(cur)
pending.remove(cur)
for p in parents:
if not p in negative:
if p not in negative:
pending.add(p)
elif cur in negative:
negative.remove(cur)
for p in parents:
if not p in pending:
if p not in pending:
negative.add(p)
else:
pending.discard(p)
@@ -494,7 +503,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))
@@ -650,7 +659,7 @@ def list_head(repo, cur):
return
node = repo[branch_tip('default')]
head = 'master' if not 'master' in bmarks else 'default'
head = 'master' if 'master' not in bmarks else 'default'
fake_bmark = head
bmarks[head] = node
@@ -679,7 +688,7 @@ def do_list(parser):
print "? refs/heads/branches/%s" % gitref(branch)
for bmark in bmarks:
if bmarks[bmark].hex() == '0' * 40:
if bmarks[bmark].hex() == '0' * 40:
warn("Ignoring invalid bookmark '%s'", bmark)
else:
print "? refs/heads/%s" % gitref(bmark)
@@ -741,7 +750,7 @@ def get_merge_files(repo, p1, p2, files):
if e not in files:
if e not in repo[p1].manifest():
continue
f = { 'ctx' : repo[p1][e] }
f = { 'ctx': repo[p1][e] }
files[e] = f
def c_style_unescape(string):
@@ -782,10 +791,10 @@ def parse_commit(parser):
if parser.check('M'):
t, m, mark_ref, path = line.split(' ', 3)
mark = int(mark_ref[1:])
f = { 'mode' : hgmode(m), 'data' : blob_marks[mark] }
f = { 'mode': hgmode(m), 'data': blob_marks[mark] }
elif parser.check('D'):
t, path = line.split(' ', 1)
f = { 'deleted' : True }
f = { 'deleted': True }
else:
die('Unknown file command: %s' % line)
path = c_style_unescape(path)
@@ -799,14 +808,32 @@ def parse_commit(parser):
def getfilectx(repo, memctx, f):
of = files[f]
if 'deleted' in of:
raise IOError
if check_version(3, 2):
return None
else:
raise IOError
if 'ctx' in of:
return of['ctx']
if mode == 'hg':
ctx = of['ctx']
is_exec = ctx.isexec()
is_link = ctx.islink()
if check_version(3, 1):
return context.memfilectx(repo, f, ctx.data(),
is_link, is_exec)
else:
return context.memfilectx(f, ctx.data(),
is_link, is_exec)
else:
return of['ctx']
is_exec = of['mode'] == 'x'
is_link = of['mode'] == 'l'
rename = of.get('rename', None)
return context.memfilectx(f, of['data'],
is_link, is_exec, rename)
if check_version(3, 1):
return context.memfilectx(repo, f, of['data'],
is_link, is_exec, rename)
else:
return context.memfilectx(f, of['data'],
is_link, is_exec, rename)
repo = parser.repo
@@ -909,7 +936,10 @@ def write_tag(repo, tag, node, msg, author):
except error.ManifestLookupError:
data = ""
content = data + "%s %s\n" % (node, tag)
return context.memfilectx(f, content, False, False, None)
if check_version(3, 1):
return context.memfilectx(repo, f, content, False, False, None)
else:
return context.memfilectx(f, content, False, False, None)
p1 = tip.hex()
p2 = '0' * 40
@@ -929,7 +959,7 @@ def write_tag(repo, tag, node, msg, author):
ctx = context.memctx(repo, (p1, p2), msg,
['.hgtags'], getfilectx,
user, date_tz, {'branch' : branch})
user, date_tz, {'branch': branch})
tmp = encoding.encoding
encoding.encoding = 'utf-8'
@@ -942,7 +972,7 @@ def write_tag(repo, tag, node, msg, author):
def checkheads_bmark(repo, ref, ctx):
bmark = ref[len('refs/heads/'):]
if not bmark in bmarks:
if bmark not in bmarks:
# new bmark
return True
@@ -975,7 +1005,7 @@ def checkheads(repo, remote, p_revs):
for node, ref in p_revs.iteritems():
ctx = repo[node]
branch = ctx.branch()
if not branch in remotemap:
if branch not in remotemap:
# new branch
continue
if not ref.startswith('refs/heads/branches'):
@@ -1025,7 +1055,9 @@ def push_unsafe(repo, remote, parsed_refs, p_revs):
if not checkheads(repo, remote, p_revs):
return None
if check_version(3, 0):
if check_version(3, 2):
cg = changegroup.getchangegroup(repo, 'push', heads=list(p_revs), common=common)
elif check_version(3, 0):
cg = changegroup.getbundle(repo, 'push', heads=list(p_revs), common=common)
else:
cg = repo.getbundle('push', heads=list(p_revs), common=common)
@@ -1262,7 +1294,11 @@ def main(args):
filenodes = {}
fake_bmark = None
try:
hg_version = tuple(int(e) for e in util.version().split('.'))
version, _, extra = util.version().partition('+')
version = list(int(e) for e in version.split('.'))
if extra:
version[1] += 1
hg_version = tuple(version)
except:
hg_version = None
dry_run = False

View File

@@ -1,6 +1,6 @@
RM ?= rm -f
T = $(wildcard *.t)
T = main.t bidi.t
TEST_DIRECTORY := $(CURDIR)
export TEST_DIRECTORY

View File

@@ -8,7 +8,8 @@
test_description='Test bidirectionality of remote-hg'
. ./test-lib.sh
test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=$(dirname $0)/
. "$TEST_DIRECTORY"/test-lib.sh
if ! test_have_prereq PYTHON
then

View File

@@ -8,7 +8,8 @@
test_description='Test remote-hg output compared to hg-git'
. ./test-lib.sh
test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=$(dirname $0)/
. "$TEST_DIRECTORY"/test-lib.sh
if ! test_have_prereq PYTHON
then
@@ -22,12 +23,26 @@ then
test_done
fi
if ! python2 -c 'import hggit' > /dev/null 2>&1
if python2 -c 'import hggit' > /dev/null 2>&1
then
hggit=hggit
elif python2 -c 'import hgext.git' > /dev/null 2>&1
then
hggit=hgext.git
else
skip_all='skipping remote-hg tests; hg-git not available'
test_done
fi
hg_version=$(python2 -c 'from mercurial import util; print util.version()')
case $hg_version in
3.0*+*)
skip_all='skipping remote-hg tests; unsuported version of hg by hg-git'
test_done
;;
esac
# clone to a git repo with git
git_clone_git () {
git clone -q "hg::$1" $2 &&
@@ -100,8 +115,7 @@ setup () {
debugrawcommit = -d "0 0"
tag = -d "0 0"
[extensions]
hgext.bookmarks =
hggit =
$hggit =
graphlog =
EOF
git config --global receive.denycurrentbranch warn

View File

@@ -8,7 +8,7 @@
test_description='Test remote-hg'
test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=${0%/*}/../../t
test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=$(dirname $0)/
. "$TEST_DIRECTORY"/test-lib.sh
if ! test_have_prereq PYTHON