Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 751e2b3

Browse files
committed
Merge branch 'fc/contrib-bzr-hg-fixes'
* fc/contrib-bzr-hg-fixes: contrib/remote-helpers: quote variable references in redirection targets contrib/remote-helpers: style updates for test scripts remote-hg: use notes to keep track of Hg revisions remote-helpers: cleanup more global variables remote-helpers: trivial style fixes remote-hg: improve basic test remote-hg: add missing &&s in the test remote-hg: fix test remote-bzr: make bzr branches configurable per-repo remote-bzr: fix export of utf-8 authors
2 parents ac4d295 + 5d21adc commit 751e2b3

File tree

6 files changed

+327
-292
lines changed

6 files changed

+327
-292
lines changed

contrib/remote-helpers/git-remote-bzr

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
# or
1414
# % git clone bzr::lp:myrepo
1515
#
16-
# If you want to specify which branches you want track (per repo):
17-
# git config remote-bzr.branches 'trunk, devel, test'
16+
# If you want to specify which branches you want to track (per repo):
17+
# % git config remote.origin.bzr-branches 'trunk, devel, test'
18+
#
19+
# Where 'origin' is the name of the repository you want to specify the
20+
# branches.
1821
#
1922

2023
import sys
@@ -168,17 +171,16 @@ class Parser:
168171
if not m:
169172
return None
170173
_, name, email, date, tz = m.groups()
174+
name = name.decode('utf-8')
171175
committer = '%s <%s>' % (name, email)
172176
tz = int(tz)
173177
tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
174178
return (committer, int(date), tz)
175179

176180
def rev_to_mark(rev):
177-
global marks
178181
return marks.from_rev(rev)
179182

180183
def mark_to_rev(mark):
181-
global marks
182184
return marks.to_rev(mark)
183185

184186
def fixup_user(user):
@@ -233,8 +235,6 @@ def get_filechanges(cur, prev):
233235
return modified, removed
234236

235237
def export_files(tree, files):
236-
global marks, filenodes
237-
238238
final = []
239239
for path, fid in files.iteritems():
240240
kind = tree.kind(fid)
@@ -276,8 +276,6 @@ def export_files(tree, files):
276276
return final
277277

278278
def export_branch(repo, name):
279-
global prefix
280-
281279
ref = '%s/heads/%s' % (prefix, name)
282280
tip = marks.get_tip(name)
283281

@@ -378,16 +376,12 @@ def export_branch(repo, name):
378376
marks.set_tip(name, revid)
379377

380378
def export_tag(repo, name):
381-
global tags, prefix
382-
383379
ref = '%s/tags/%s' % (prefix, name)
384380
print "reset %s" % ref
385381
print "from :%u" % rev_to_mark(tags[name])
386382
print
387383

388384
def do_import(parser):
389-
global dirname
390-
391385
repo = parser.repo
392386
path = os.path.join(dirname, 'marks-git')
393387

@@ -413,8 +407,6 @@ def do_import(parser):
413407
sys.stdout.flush()
414408

415409
def parse_blob(parser):
416-
global blob_marks
417-
418410
parser.next()
419411
mark = parser.get_mark()
420412
parser.next()
@@ -425,8 +417,6 @@ def parse_blob(parser):
425417
class CustomTree():
426418

427419
def __init__(self, branch, revid, parents, files):
428-
global files_cache
429-
430420
self.updates = {}
431421
self.branch = branch
432422

@@ -484,7 +474,7 @@ class CustomTree():
484474
add_entry(fid, dirname, 'directory')
485475
return fid
486476

487-
def add_entry(fid, path, kind, mode = None):
477+
def add_entry(fid, path, kind, mode=None):
488478
dirname, basename = os.path.split(path)
489479
parent_fid = get_parent(dirname, basename)
490480

@@ -505,7 +495,7 @@ class CustomTree():
505495
self.files[path] = [change[0], None]
506496
changes.append(change)
507497

508-
def update_entry(fid, path, kind, mode = None):
498+
def update_entry(fid, path, kind, mode=None):
509499
dirname, basename = os.path.split(path)
510500
parent_fid = get_parent(dirname, basename)
511501

@@ -583,9 +573,6 @@ def c_style_unescape(string):
583573
return string
584574

585575
def parse_commit(parser):
586-
global marks, blob_marks, parsed_refs
587-
global mode
588-
589576
parents = []
590577

591578
ref = parser[1]
@@ -657,8 +644,6 @@ def parse_commit(parser):
657644
marks.new_mark(revid, commit_mark)
658645

659646
def parse_reset(parser):
660-
global parsed_refs
661-
662647
ref = parser[1]
663648
parser.next()
664649

@@ -674,8 +659,6 @@ def parse_reset(parser):
674659
parsed_refs[ref] = mark_to_rev(from_mark)
675660

676661
def do_export(parser):
677-
global parsed_refs, dirname, transports
678-
679662
parser.next()
680663

681664
for line in parser.each_block('done'):
@@ -725,8 +708,6 @@ def do_export(parser):
725708
print
726709

727710
def do_capabilities(parser):
728-
global dirname
729-
730711
print "import"
731712
print "export"
732713
print "refspec refs/heads/*:%s/heads/*" % prefix
@@ -744,8 +725,6 @@ def ref_is_valid(name):
744725
return not True in [c in name for c in '~^: \\']
745726

746727
def do_list(parser):
747-
global tags
748-
749728
master_branch = None
750729

751730
for name in branches:
@@ -770,7 +749,6 @@ def do_list(parser):
770749
print
771750

772751
def clone(path, remote_branch):
773-
global transports
774752
try:
775753
bdir = bzrlib.bzrdir.BzrDir.create(path, possible_transports=transports)
776754
except bzrlib.errors.AlreadyControlDirError:
@@ -780,8 +758,6 @@ def clone(path, remote_branch):
780758
return remote_branch.sprout(bdir, repository=repo)
781759

782760
def get_remote_branch(name):
783-
global dirname, branches, transports
784-
785761
remote_branch = bzrlib.branch.Branch.open(branches[name],
786762
possible_transports=transports)
787763
if isinstance(remote_branch.user_transport, bzrlib.transport.local.LocalTransport):
@@ -825,8 +801,6 @@ def find_branches(repo):
825801
yield name, branch.base
826802

827803
def get_repo(url, alias):
828-
global dirname, peer, branches, transports
829-
830804
normal_url = bzrlib.urlutils.normalize_url(url)
831805
origin = bzrlib.bzrdir.BzrDir.open(url, possible_transports=transports)
832806
is_local = isinstance(origin.transport, bzrlib.transport.local.LocalTransport)
@@ -858,9 +832,13 @@ def get_repo(url, alias):
858832
except bzrlib.errors.NoRepositoryPresent:
859833
pass
860834

861-
wanted = get_config('remote-bzr.branches').rstrip().split(', ')
835+
wanted = get_config('remote.%s.bzr-branches' % alias).rstrip().split(', ')
862836
# stupid python
863837
wanted = [e for e in wanted if e]
838+
if not wanted:
839+
wanted = get_config('remote-bzr.branches').rstrip().split(', ')
840+
# stupid python
841+
wanted = [e for e in wanted if e]
864842

865843
if not wanted:
866844
try:

0 commit comments

Comments
 (0)