From: Felipe Contreras <hidden> Date: 2016-06-15 22:56:47
Hi,
This is a reroll of the previous series due to a few minor issues. As the
previous version, forced pushes remain a configuration option. Also, I picked
up a fix for test regarding hg_log() that was sent to the mailing list.
Antoine Pelisse (1):
remote-hg: activate graphlog extension for hg_log()
Dusty Phillips (2):
remote-hg: add missing config variable in doc
remote-hg: push to the appropriate branch
Felipe Contreras (15):
remote-hg: trivial cleanups
remote-hg: properly report errors on bookmark pushes
remote-hg: make sure fake bookmarks are updated
remote-hg: trivial test cleanups
remote-hg: redirect buggy mercurial output
remote-hg: split bookmark handling
remote-hg: refactor export
remote-hg: update remote bookmarks
remote-hg: update tags globally
remote-hg: force remote push
remote-hg: show more proper errors
remote-hg: add basic author tests
remote-hg: add simple mail test
remote-hg: fix bad state issue
remote-hg: fix bad file paths
Peter van Zetten (1):
remote-hg: fix for files with spaces
Simon Ruderich (2):
remote-hg: add 'insecure' option
remote-hg: document location of stored hg repository
contrib/remote-helpers/git-remote-hg | 122 +++++++++++++++++++++++++------
contrib/remote-helpers/test-hg-bidi.sh | 11 ++-
contrib/remote-helpers/test-hg-hg-git.sh | 8 +-
contrib/remote-helpers/test-hg.sh | 36 +++++++++
4 files changed, 148 insertions(+), 29 deletions(-)
--
1.8.2.1
@@ -531,7 +531,6 @@ def parse_blob(parser): data = parser.get_data() blob_marks[mark] = data parser.next()- return def get_merge_files(repo, p1, p2, files): for e in repo[p1].files():
@@ -542,7 +541,7 @@ def get_merge_files(repo, p1, p2, files): files[e] = f def parse_commit(parser):- global marks, blob_marks, bmarks, parsed_refs+ global marks, blob_marks, parsed_refs global mode from_mark = merge_mark = None
@@ -23,6 +23,10 @@ import urllib # If you want to switch to hg-git compatibility mode: # git config --global remote-hg.hg-git-compat true #+# If you are not in hg-git-compat mode and want to disable the tracking of+# named branches:+# git config --global remote-hg.track-branches false+# # git: # Sensible defaults for git. # hg bookmarks are exported as git branches, hg branches are prefixed
From: Felipe Contreras <hidden> Date: 2016-06-15 22:56:47
From: Peter van Zetten <redacted>
Set the maximum number of splits to make when dividing the diff stat
lines based on space characters.
Signed-off-by: Felipe Contreras <redacted>
---
contrib/remote-helpers/git-remote-hg | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -625,7 +625,7 @@ def parse_commit(parser): i = data.find('\n--HG--\n') if i >= 0: tmp = data[i + len('\n--HG--\n'):].strip()- for k, v in [e.split(' : ') for e in tmp.split('\n')]:+ for k, v in [e.split(' : ', 1) for e in tmp.split('\n')]: if k == 'rename': old, new = v.split(' => ', 1) files[new]['rename'] = old
@@ -685,6 +685,8 @@ def parse_tag(parser): def do_export(parser): global parsed_refs, bmarks, peer+ p_bmarks = []+ parser.next() for line in parser.each_block('done'):
@@ -706,20 +708,9 @@ def do_export(parser): pass elif ref.startswith('refs/heads/'): bmark = ref[len('refs/heads/'):]- if bmark in bmarks:- old = bmarks[bmark].hex()- else:- old = ''-- if bmark == 'master' and 'master' not in parser.repo._bookmarks:- # fake bookmark- print "ok %s" % ref- continue-- if not bookmarks.pushbookmark(parser.repo, bmark, old, node):- print "error %s" % ref- continue-+ p_bmarks.append((bmark, node))+ # handle below+ continue elif ref.startswith('refs/tags/'): tag = ref[len('refs/tags/'):] parser.repo.tag([tag], node, None, True, None, {})
@@ -731,6 +722,26 @@ def do_export(parser): if peer: parser.repo.push(peer, force=False)+ # handle bookmarks+ for bmark, node in p_bmarks:+ ref = 'refs/heads/' + bmark++ if bmark in bmarks:+ old = bmarks[bmark].hex()+ else:+ old = ''++ if bmark == 'master' and 'master' not in parser.repo._bookmarks:+ # fake bookmark+ print "ok %s" % ref+ continue++ if not bookmarks.pushbookmark(parser.repo, bmark, old, node):+ print "error %s" % ref+ continue++ print "ok %s" % ref+ print def fix_path(alias, repo, orig_url):
@@ -725,6 +727,7 @@ def do_export(parser): # handle bookmarks for bmark, node in p_bmarks: ref = 'refs/heads/' + bmark+ new = hghex(node) if bmark in bmarks: old = bmarks[bmark].hex()
@@ -733,10 +736,11 @@ def do_export(parser): if bmark == 'master' and 'master' not in parser.repo._bookmarks: # fake bookmark- print "ok %s" % ref- continue-- if not bookmarks.pushbookmark(parser.repo, bmark, old, node):+ pass+ elif bookmarks.pushbookmark(parser.repo, bmark, old, new):+ # updated locally+ pass+ else: print "error %s" % ref continue
@@ -625,6 +625,10 @@ def parse_commit(parser): if merge_mark: get_merge_files(repo, p1, p2, files)+ # Check if the ref is supposed to be a named branch+ if ref.startswith('refs/heads/branches/'):+ extra['branch'] = ref[len('refs/heads/branches/'):]+ if mode == 'hg': i = data.find('\n--HG--\n') if i >= 0:
From: Felipe Contreras <hidden> Date: 2016-06-15 22:56:47
Ideally we shouldn't do this, as it's not recommended in mercurial
documentation, but there's no other way to push multiple bookmarks (on
the same branch), which would be the behavior most similar to git.
At the same time, add a configuration option for the people that don't
want to risk creating new remote heads.
Signed-off-by: Felipe Contreras <redacted>
---
contrib/remote-helpers/git-remote-hg | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
From: Felipe Contreras <hidden> Date: 2016-06-15 22:56:47
When cloning or pushing fails, we don't want to show a stack-trace.
Signed-off-by: Felipe Contreras <redacted>
---
contrib/remote-helpers/git-remote-hg | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
From: Felipe Contreras <hidden> Date: 2016-06-15 22:56:47
From: Simon Ruderich <redacted>
If set to true acts as hg's clone/pull --insecure option.
Signed-off-by: Felipe Contreras <redacted>
---
contrib/remote-helpers/git-remote-hg | 9 +++++++++
1 file changed, 9 insertions(+)
@@ -30,6 +30,9 @@ import urllib # If you don't want to force pushes (and thus risk creating new remote heads): # git config --global remote-hg.force-push false #+# If you want the equivalent of hg's clone/pull--insecure option:+# git config remote-hg.insecure true+# # git: # Sensible defaults for git. # hg bookmarks are exported as git branches, hg branches are prefixed
From: Felipe Contreras <hidden> Date: 2016-06-15 22:56:47
The problem reportedly happened after doing a push that fails, the abort
causes the state of remote-hg to go bad, this happens because
remote-hg's marks are not stored, but 'git fast-export' marks are.
Ensure that the marks are _always_ stored.
Signed-off-by: Felipe Contreras <redacted>
---
contrib/remote-helpers/git-remote-hg | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
@@ -8,6 +8,9 @@ # Just copy to your ~/bin, or anywhere in your $PATH. # Then you can clone with: # git clone hg::/path/to/mercurial/repo/+#+# For remote repositories a local clone is stored in+# "$GIT_DIR/hg/origin/clone/.hg/". from mercurial import hg, ui, bookmarks, context, util, encoding, node, error
From: Felipe Contreras <hidden> Date: 2016-06-15 22:56:47
From: Antoine Pelisse <redacted>
The hg_log() test helper uses the "--graph" parameter that is
implemented by the GraphLog extension. If the extension is not activated
by the user, the parameter is not available. Activate the extension in
setup().
Also changes the way we grep the output in hg_log(). The pipe operator
can hide the return code of hg command. As a matter of fact, if log
fails because it doesn't know about "--graph", it doesn't report any
failure and let's you think everything worked.
Signed-off-by: Antoine Pelisse <redacted>
Signed-off-by: Felipe Contreras <redacted>
---
contrib/remote-helpers/test-hg-bidi.sh | 5 ++++-
contrib/remote-helpers/test-hg-hg-git.sh | 4 +++-
2 files changed, 7 insertions(+), 2 deletions(-)
From: Felipe Contreras <hidden> Date: 2016-06-15 22:56:47
Mercurial emits messages like "searching for changes", "no changes
found", etc. meant for the use of its own UI layer, which break the pipe
between transport helper and remote helper.
Since there's no way to silence Mercurial, let's redirect to standard
error.
Signed-off-by: Felipe Contreras <redacted>
---
contrib/remote-helpers/git-remote-hg | 1 +
1 file changed, 1 insertion(+)
Can you explain why "update" went from False to True ? That can be a
problem if the repository is BIG (two working directories instead of
one can raise space issues).
The commit message is not so helpful here ;)
Can you explain why "update" went from False to True ? That can be a
problem if the repository is BIG (two working directories instead of
one can raise space issues).
The commit message is not so helpful here ;)
Good catch. It was probably a mistake. However, I already sent a patch
that overrides this so update=False again.
--
Felipe Contreras