18 Commits
v0.2 ... test

Author SHA1 Message Date
Felipe Contreras
e71a8963af test: fix hg version check
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-06-02 18:38:59 -05:00
Felipe Contreras
f20dbc33c3 Add extra verbosity
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
2014-06-02 18:29:14 -05:00
Felipe Contreras
e4aeae6d4b 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:16:49 -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
9 changed files with 83 additions and 32 deletions

View File

@@ -12,6 +12,7 @@ before_script:
- pip show hg-git dulwich
script:
- export TEST_OPTS='-v'
- make test
matrix:

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

@@ -109,8 +109,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 +122,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'))
@@ -453,12 +457,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)
@@ -650,7 +654,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 +683,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 +745,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 +786,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)
@@ -805,8 +809,12 @@ def parse_commit(parser):
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 +917,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 +940,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 +953,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 +986,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'):
@@ -1262,7 +1273,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

@@ -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,28 @@ 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()')
echo "hg_version: $hg_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 &&
@@ -101,7 +118,7 @@ setup () {
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
@@ -470,7 +470,7 @@ rm -rf hgrepo
test_expect_success 'fetch special filenames' '
test_when_finished "rm -rf hgrepo gitrepo && LC_ALL=C" &&
LC_ALL=en_US.UTF-8
LC_ALL=C.UTF-8
export LC_ALL
(
@@ -503,7 +503,7 @@ test_expect_success 'push special filenames' '
mkdir -p tmp && cd tmp &&
LC_ALL=en_US.UTF-8
LC_ALL=C.UTF-8
export LC_ALL
(