Mercurial > hg-git
comparison hggit/git_handler.py @ 820:0d6d2fcc62b6
git_handler: support wildcards for Git branch name matching
This is quite similar to syntax Git supports. In the future maybe core
Mercurial could be extended to support this, but I think this independently
makes sense in hg-git.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 31 Oct 2014 11:14:35 -0700 |
parents | 826296785e8b |
children | 53e7e8f34dcd |
comparison
equal
deleted
inserted
replaced
819:826296785e8b | 820:0d6d2fcc62b6 |
---|---|
1053 # if ref is just '<foo>', then we get ('foo', 'foo') | 1053 # if ref is just '<foo>', then we get ('foo', 'foo') |
1054 stripped_refs = [ | 1054 stripped_refs = [ |
1055 (r, r[r.find('/', r.find('/')+1)+1:]) | 1055 (r, r[r.find('/', r.find('/')+1)+1:]) |
1056 for r in refs] | 1056 for r in refs] |
1057 for h in heads: | 1057 for h in heads: |
1058 r = [pair[0] for pair in stripped_refs if pair[1] == h] | 1058 if h.endswith('/*'): |
1059 if not r: | 1059 prefix = h[:-1] # include the / but not the * |
1060 raise hgutil.Abort("ref %s not found on remote server" % h) | 1060 r = [pair[0] for pair in stripped_refs |
1061 elif len(r) == 1: | 1061 if pair[1].startswith(prefix)] |
1062 filteredrefs.append(r[0]) | 1062 r.sort() |
1063 filteredrefs.extend(r) | |
1063 else: | 1064 else: |
1064 raise hgutil.Abort("ambiguous reference %s: %r" % (h, r)) | 1065 r = [pair[0] for pair in stripped_refs if pair[1] == h] |
1066 if not r: | |
1067 raise hgutil.Abort("ref %s not found on remote server" % h) | |
1068 elif len(r) == 1: | |
1069 filteredrefs.append(r[0]) | |
1070 else: | |
1071 raise hgutil.Abort("ambiguous reference %s: %r" % (h, r)) | |
1065 else: | 1072 else: |
1066 for ref, sha in refs.iteritems(): | 1073 for ref, sha in refs.iteritems(): |
1067 if (not ref.endswith('^{}') | 1074 if (not ref.endswith('^{}') |
1068 and (ref.startswith('refs/heads/') | 1075 and (ref.startswith('refs/heads/') |
1069 or ref.startswith('refs/tags/'))): | 1076 or ref.startswith('refs/tags/'))): |