commit e2627129b1f6ebc6ad4bdd695f708195d85bcb6a Author: TomasKorbar Date: Sat Apr 28 19:23:07 2018 +0200 ignore some mercurial remote revision names diff --git a/git-remote-hg b/git-remote-hg index 8e1c321..e9dac14 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -95,8 +95,8 @@ def check_version(*check): return True return hg_version >= check -def get_config(config): - cmd = ['git', 'config', '--get', config] +def get_config(config, getall=False): + cmd = ['git', 'config', '--get' if not getall else '--get-all', config] process = subprocess.Popen(cmd, stdout=subprocess.PIPE) output, _ = process.communicate() return output @@ -696,20 +696,41 @@ def do_list(parser): list_head(repo, cur) + ignore_ref = get_config('remote-hg.ignore-name', True) + ignore_re = [] + for exp in ignore_ref.splitlines(): + if exp: + try: + #warn("checking %s" % ( + ignore_re.append(re.compile(exp.strip())) + except: + warn("Invalid regular expression '%s'" % (exp)) + def ignore(kind, name): + for r in ignore_re: + if r.search(name): + warn("Ignoring matched %s %s" % (kind, name)) + return True + return False + + for_push = (parser.line.find('for-push') >= 0) + sha1 = 'f' * 40 if (capability_push and for_push) else '?' + if track_branches: for branch in branches: - print "? refs/heads/branches/%s" % gitref(branch) + if not ignore('branch', branch): + print "%s refs/heads/branches/%s" % (sha1, gitref(branch)) for bmark in bmarks: if bmarks[bmark].hex() == '0' * 40: warn("Ignoring invalid bookmark '%s'", bmark) - else: - print "? refs/heads/%s" % gitref(bmark) + elif not ignore('bookmark', bmark): + print "%s refs/heads/%s" % (sha1, gitref(bmark)) for tag, node in repo.tagslist(): if tag == 'tip': continue - print "? refs/tags/%s" % gitref(tag) + if not ignore('tag', tag): + print "%s refs/tags/%s" % (sha1, gitref(tag)) print @@ -1270,6 +1291,7 @@ def main(args): global fake_bmark, hg_version global dry_run global notes, alias + global capability_push marks = None is_tmp = False @@ -1287,6 +1309,8 @@ def main(args): hg_git_compat = get_config_bool('remote-hg.hg-git-compat') track_branches = get_config_bool('remote-hg.track-branches', True) + capability_push = get_config_bool('remote-hg.capability-push', True) + force_push = False if hg_git_compat: