mirror of
https://github.com/mnauw/git-remote-hg.git
synced 2025-11-01 09:05:48 +01:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6e9475918 | ||
|
|
517ceb91ac | ||
|
|
114804f0cb | ||
|
|
b022367aef | ||
|
|
18626d346f | ||
|
|
b81ec14c2e | ||
|
|
1e279075dc | ||
|
|
02a0a59a4b | ||
|
|
185852eac4 | ||
|
|
29a0d8a0e3 | ||
|
|
aa528c9649 | ||
|
|
018aa4753b | ||
|
|
f173208406 | ||
|
|
e7df347fab | ||
|
|
0de8aa91f4 | ||
|
|
22d9794c11 | ||
|
|
f53a8653ab | ||
|
|
b4c63539f2 | ||
|
|
38070007aa | ||
|
|
fadd5f698b | ||
|
|
1eb8fa4805 | ||
|
|
19f31c1c84 | ||
|
|
ff221de459 | ||
|
|
179fefda96 | ||
|
|
c226ba3904 |
@@ -5,7 +5,7 @@ install:
|
|||||||
then pip install -q Mercurial${HG_VERSION+==$HG_VERSION};
|
then pip install -q Mercurial${HG_VERSION+==$HG_VERSION};
|
||||||
else pip install -q http://selenic.com/repo/hg/archive/tip.tar.gz;
|
else pip install -q http://selenic.com/repo/hg/archive/tip.tar.gz;
|
||||||
fi
|
fi
|
||||||
- pip install -q dulwich hg-git || true
|
- pip install -q dulwich hg-git==0.6.1 || true
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- hg --version || true
|
- hg --version || true
|
||||||
@@ -20,6 +20,9 @@ matrix:
|
|||||||
- env: HG_VERSION=2.8.2
|
- env: HG_VERSION=2.8.2
|
||||||
- env: HG_VERSION=2.7.2
|
- env: HG_VERSION=2.7.2
|
||||||
- env: HG_VERSION=3.0
|
- 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
|
- env: HG_VERSION=dev
|
||||||
- python: 2.7
|
- python: 2.7
|
||||||
- python: 2.6
|
- python: 2.6
|
||||||
|
|||||||
18
Makefile
18
Makefile
@@ -1,6 +1,9 @@
|
|||||||
prefix := $(HOME)
|
prefix := $(HOME)
|
||||||
|
|
||||||
all:
|
bindir := $(prefix)/bin
|
||||||
|
mandir := $(prefix)/share/man/man1
|
||||||
|
|
||||||
|
all: doc
|
||||||
|
|
||||||
doc: doc/git-remote-hg.1
|
doc: doc/git-remote-hg.1
|
||||||
|
|
||||||
@@ -10,14 +13,17 @@ test:
|
|||||||
doc/git-remote-hg.1: doc/git-remote-hg.txt
|
doc/git-remote-hg.1: doc/git-remote-hg.txt
|
||||||
a2x -d manpage -f manpage $<
|
a2x -d manpage -f manpage $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) doc/git-remote-hg.1
|
||||||
|
|
||||||
D = $(DESTDIR)
|
D = $(DESTDIR)
|
||||||
|
|
||||||
install:
|
install:
|
||||||
install -D -m 755 git-remote-hg \
|
install -d -m 755 $(D)$(bindir)/
|
||||||
$(D)$(prefix)/bin/git-remote-hg
|
install -m 755 git-remote-hg $(D)$(bindir)/git-remote-hg
|
||||||
|
|
||||||
install-doc: doc
|
install-doc: doc
|
||||||
install -D -m 644 doc/git-remote-hg.1 \
|
install -d -m 755 $(D)$(mandir)/
|
||||||
$(D)$(prefix)/share/man/man1/git-remote-hg.1
|
install -m 644 doc/git-remote-hg.1 $(D)$(mandir)/git-remote-hg.1
|
||||||
|
|
||||||
.PHONY: all test
|
.PHONY: all test install install-doc clean
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ chmod +x ~/bin/git-remote-hg
|
|||||||
|
|
||||||
That's it :)
|
That's it :)
|
||||||
|
|
||||||
|
Obviously you will need Mercurial installed.
|
||||||
|
|
||||||
== Configuration ==
|
== Configuration ==
|
||||||
|
|
||||||
If you want to see Mercurial revisions as Git commit notes:
|
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:
|
commands don't work:
|
||||||
|
|
||||||
* `git push origin :branch-to-delete`
|
* `git push origin :branch-to-delete`
|
||||||
* `git push origin old:new` (it will push 'old') (Git v2.0)
|
* `git push origin old:new` (it will push 'old') (patches available)
|
||||||
* `git push --dry-run origin branch` (it will push) (Git v2.0)
|
* `git push --dry-run origin branch` (it will push) (patches available)
|
||||||
|
|
||||||
== Other projects ==
|
== 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
|
For a comparison between these and other projects go
|
||||||
https://github.com/felipec/git/wiki/Comparison-of-git-remote-hg-alternatives[here].
|
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
1
doc/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
git-remote-hg.1
|
||||||
5
doc/SubmittingPatches
Normal file
5
doc/SubmittingPatches
Normal 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.
|
||||||
@@ -12,7 +12,8 @@
|
|||||||
# For remote repositories a local clone is stored in
|
# For remote repositories a local clone is stored in
|
||||||
# "$GIT_DIR/hg/origin/clone/.hg/".
|
# "$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
|
from mercurial import changegroup
|
||||||
|
|
||||||
import re
|
import re
|
||||||
@@ -23,7 +24,8 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import urllib
|
import urllib
|
||||||
import atexit
|
import atexit
|
||||||
import urlparse, hashlib
|
import urlparse
|
||||||
|
import hashlib
|
||||||
import time as ptime
|
import time as ptime
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -157,7 +159,9 @@ class Marks:
|
|||||||
self.version = 2
|
self.version = 2
|
||||||
|
|
||||||
def dict(self):
|
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):
|
def store(self):
|
||||||
json.dump(self.dict(), open(self.path, 'w'))
|
json.dump(self.dict(), open(self.path, 'w'))
|
||||||
@@ -426,6 +430,11 @@ def get_repo(url, alias):
|
|||||||
peer = hg.peer(repo.ui, {}, url)
|
peer = hg.peer(repo.ui, {}, url)
|
||||||
except:
|
except:
|
||||||
die('Repository error')
|
die('Repository error')
|
||||||
|
|
||||||
|
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)
|
repo.pull(peer, heads=None, force=True)
|
||||||
|
|
||||||
updatebookmarks(repo, peer)
|
updatebookmarks(repo, peer)
|
||||||
@@ -453,12 +462,12 @@ def gitrange(repo, a, b):
|
|||||||
positive.append(cur)
|
positive.append(cur)
|
||||||
pending.remove(cur)
|
pending.remove(cur)
|
||||||
for p in parents:
|
for p in parents:
|
||||||
if not p in negative:
|
if p not in negative:
|
||||||
pending.add(p)
|
pending.add(p)
|
||||||
elif cur in negative:
|
elif cur in negative:
|
||||||
negative.remove(cur)
|
negative.remove(cur)
|
||||||
for p in parents:
|
for p in parents:
|
||||||
if not p in pending:
|
if p not in pending:
|
||||||
negative.add(p)
|
negative.add(p)
|
||||||
else:
|
else:
|
||||||
pending.discard(p)
|
pending.discard(p)
|
||||||
@@ -494,7 +503,7 @@ def export_ref(repo, name, kind, head):
|
|||||||
if 'committer' in extra:
|
if 'committer' in extra:
|
||||||
try:
|
try:
|
||||||
cuser, ctime, ctz = extra['committer'].rsplit(' ', 2)
|
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:
|
except ValueError:
|
||||||
cuser = extra['committer']
|
cuser = extra['committer']
|
||||||
committer = "%s %d %s" % (fixup_user(cuser), time, gittz(tz))
|
committer = "%s %d %s" % (fixup_user(cuser), time, gittz(tz))
|
||||||
@@ -650,7 +659,7 @@ def list_head(repo, cur):
|
|||||||
return
|
return
|
||||||
|
|
||||||
node = repo[branch_tip('default')]
|
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
|
fake_bmark = head
|
||||||
bmarks[head] = node
|
bmarks[head] = node
|
||||||
|
|
||||||
@@ -741,7 +750,7 @@ def get_merge_files(repo, p1, p2, files):
|
|||||||
if e not in files:
|
if e not in files:
|
||||||
if e not in repo[p1].manifest():
|
if e not in repo[p1].manifest():
|
||||||
continue
|
continue
|
||||||
f = { 'ctx' : repo[p1][e] }
|
f = { 'ctx': repo[p1][e] }
|
||||||
files[e] = f
|
files[e] = f
|
||||||
|
|
||||||
def c_style_unescape(string):
|
def c_style_unescape(string):
|
||||||
@@ -782,10 +791,10 @@ def parse_commit(parser):
|
|||||||
if parser.check('M'):
|
if parser.check('M'):
|
||||||
t, m, mark_ref, path = line.split(' ', 3)
|
t, m, mark_ref, path = line.split(' ', 3)
|
||||||
mark = int(mark_ref[1:])
|
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'):
|
elif parser.check('D'):
|
||||||
t, path = line.split(' ', 1)
|
t, path = line.split(' ', 1)
|
||||||
f = { 'deleted' : True }
|
f = { 'deleted': True }
|
||||||
else:
|
else:
|
||||||
die('Unknown file command: %s' % line)
|
die('Unknown file command: %s' % line)
|
||||||
path = c_style_unescape(path)
|
path = c_style_unescape(path)
|
||||||
@@ -799,12 +808,30 @@ def parse_commit(parser):
|
|||||||
def getfilectx(repo, memctx, f):
|
def getfilectx(repo, memctx, f):
|
||||||
of = files[f]
|
of = files[f]
|
||||||
if 'deleted' in of:
|
if 'deleted' in of:
|
||||||
|
if check_version(3, 2):
|
||||||
|
return None
|
||||||
|
else:
|
||||||
raise IOError
|
raise IOError
|
||||||
if 'ctx' in of:
|
if 'ctx' in of:
|
||||||
|
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']
|
return of['ctx']
|
||||||
is_exec = of['mode'] == 'x'
|
is_exec = of['mode'] == 'x'
|
||||||
is_link = of['mode'] == 'l'
|
is_link = of['mode'] == 'l'
|
||||||
rename = of.get('rename', None)
|
rename = of.get('rename', None)
|
||||||
|
if check_version(3, 1):
|
||||||
|
return context.memfilectx(repo, f, of['data'],
|
||||||
|
is_link, is_exec, rename)
|
||||||
|
else:
|
||||||
return context.memfilectx(f, of['data'],
|
return context.memfilectx(f, of['data'],
|
||||||
is_link, is_exec, rename)
|
is_link, is_exec, rename)
|
||||||
|
|
||||||
@@ -909,6 +936,9 @@ def write_tag(repo, tag, node, msg, author):
|
|||||||
except error.ManifestLookupError:
|
except error.ManifestLookupError:
|
||||||
data = ""
|
data = ""
|
||||||
content = data + "%s %s\n" % (node, tag)
|
content = data + "%s %s\n" % (node, tag)
|
||||||
|
if check_version(3, 1):
|
||||||
|
return context.memfilectx(repo, f, content, False, False, None)
|
||||||
|
else:
|
||||||
return context.memfilectx(f, content, False, False, None)
|
return context.memfilectx(f, content, False, False, None)
|
||||||
|
|
||||||
p1 = tip.hex()
|
p1 = tip.hex()
|
||||||
@@ -929,7 +959,7 @@ def write_tag(repo, tag, node, msg, author):
|
|||||||
|
|
||||||
ctx = context.memctx(repo, (p1, p2), msg,
|
ctx = context.memctx(repo, (p1, p2), msg,
|
||||||
['.hgtags'], getfilectx,
|
['.hgtags'], getfilectx,
|
||||||
user, date_tz, {'branch' : branch})
|
user, date_tz, {'branch': branch})
|
||||||
|
|
||||||
tmp = encoding.encoding
|
tmp = encoding.encoding
|
||||||
encoding.encoding = 'utf-8'
|
encoding.encoding = 'utf-8'
|
||||||
@@ -942,7 +972,7 @@ def write_tag(repo, tag, node, msg, author):
|
|||||||
|
|
||||||
def checkheads_bmark(repo, ref, ctx):
|
def checkheads_bmark(repo, ref, ctx):
|
||||||
bmark = ref[len('refs/heads/'):]
|
bmark = ref[len('refs/heads/'):]
|
||||||
if not bmark in bmarks:
|
if bmark not in bmarks:
|
||||||
# new bmark
|
# new bmark
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -975,7 +1005,7 @@ def checkheads(repo, remote, p_revs):
|
|||||||
for node, ref in p_revs.iteritems():
|
for node, ref in p_revs.iteritems():
|
||||||
ctx = repo[node]
|
ctx = repo[node]
|
||||||
branch = ctx.branch()
|
branch = ctx.branch()
|
||||||
if not branch in remotemap:
|
if branch not in remotemap:
|
||||||
# new branch
|
# new branch
|
||||||
continue
|
continue
|
||||||
if not ref.startswith('refs/heads/branches'):
|
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):
|
if not checkheads(repo, remote, p_revs):
|
||||||
return None
|
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)
|
cg = changegroup.getbundle(repo, 'push', heads=list(p_revs), common=common)
|
||||||
else:
|
else:
|
||||||
cg = repo.getbundle('push', heads=list(p_revs), common=common)
|
cg = repo.getbundle('push', heads=list(p_revs), common=common)
|
||||||
@@ -1262,7 +1294,11 @@ def main(args):
|
|||||||
filenodes = {}
|
filenodes = {}
|
||||||
fake_bmark = None
|
fake_bmark = None
|
||||||
try:
|
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:
|
except:
|
||||||
hg_version = None
|
hg_version = None
|
||||||
dry_run = False
|
dry_run = False
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
RM ?= rm -f
|
RM ?= rm -f
|
||||||
|
|
||||||
T = $(wildcard *.t)
|
T = main.t bidi.t
|
||||||
TEST_DIRECTORY := $(CURDIR)
|
TEST_DIRECTORY := $(CURDIR)
|
||||||
|
|
||||||
export TEST_DIRECTORY
|
export TEST_DIRECTORY
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
test_description='Test bidirectionality of remote-hg'
|
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
|
if ! test_have_prereq PYTHON
|
||||||
then
|
then
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
test_description='Test remote-hg output compared to hg-git'
|
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
|
if ! test_have_prereq PYTHON
|
||||||
then
|
then
|
||||||
@@ -22,12 +23,26 @@ then
|
|||||||
test_done
|
test_done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! python2 -c 'import hggit' > /dev/null 2>&1
|
if python2 -c 'import hggit' > /dev/null 2>&1
|
||||||
then
|
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'
|
skip_all='skipping remote-hg tests; hg-git not available'
|
||||||
test_done
|
test_done
|
||||||
fi
|
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
|
# clone to a git repo with git
|
||||||
git_clone_git () {
|
git_clone_git () {
|
||||||
git clone -q "hg::$1" $2 &&
|
git clone -q "hg::$1" $2 &&
|
||||||
@@ -100,8 +115,7 @@ setup () {
|
|||||||
debugrawcommit = -d "0 0"
|
debugrawcommit = -d "0 0"
|
||||||
tag = -d "0 0"
|
tag = -d "0 0"
|
||||||
[extensions]
|
[extensions]
|
||||||
hgext.bookmarks =
|
$hggit =
|
||||||
hggit =
|
|
||||||
graphlog =
|
graphlog =
|
||||||
EOF
|
EOF
|
||||||
git config --global receive.denycurrentbranch warn
|
git config --global receive.denycurrentbranch warn
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
test_description='Test remote-hg'
|
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
|
. "$TEST_DIRECTORY"/test-lib.sh
|
||||||
|
|
||||||
if ! test_have_prereq PYTHON
|
if ! test_have_prereq PYTHON
|
||||||
|
|||||||
Reference in New Issue
Block a user