mirror of
				https://github.com/mnauw/git-remote-hg.git
				synced 2025-10-31 08:35: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}; | ||||
|     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 | ||||
|   | ||||
							
								
								
									
										18
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								Makefile
									
									
									
									
									
								
							| @@ -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 | ||||
|   | ||||
| @@ -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
									
								
							
							
						
						
									
										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 | ||||
| # "$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 | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| RM ?= rm -f | ||||
|  | ||||
| T = $(wildcard *.t) | ||||
| T = main.t bidi.t | ||||
| TEST_DIRECTORY := $(CURDIR) | ||||
|  | ||||
| export TEST_DIRECTORY | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user