remote-helpers: cleanup more global variables

They don't need to be specified if they are not going to be set. Suggested-by: Dusty Phillips <dusty@linux.ca> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Aug 28, 2013 at 14:23 UTC 641a2b5bee4c759c4dd36b5ad9e7f159aca54611
2 files changed +2 -57
contrib/remote-helpers/git-remote-bzr
-29
@@ -178,11 +178,9 @@ class Parser:
178 return (committer, int(date), tz)
179
180 def rev_to_mark(rev):
181 - global marks
181 return marks.from_rev(rev)
182
183 def mark_to_rev(mark):
185 - global marks
184 return marks.to_rev(mark)
185
186 def fixup_user(user):
@@ -237,8 +235,6 @@ def get_filechanges(cur, prev):
235 return modified, removed
236
237 def export_files(tree, files):
240 - global marks, filenodes
241 -
238 final = []
239 for path, fid in files.iteritems():
240 kind = tree.kind(fid)
@@ -280,8 +276,6 @@ def export_files(tree, files):
276 return final
277
278 def export_branch(repo, name):
283 - global prefix
284 -
279 ref = '%s/heads/%s' % (prefix, name)
280 tip = marks.get_tip(name)
281
@@ -382,16 +376,12 @@ def export_branch(repo, name):
376 marks.set_tip(name, revid)
377
378 def export_tag(repo, name):
385 - global tags, prefix
386 -
379 ref = '%s/tags/%s' % (prefix, name)
380 print "reset %s" % ref
381 print "from :%u" % rev_to_mark(tags[name])
382 print
383
384 def do_import(parser):
393 - global dirname
394 -
385 repo = parser.repo
386 path = os.path.join(dirname, 'marks-git')
387
@@ -417,8 +407,6 @@ def do_import(parser):
407 sys.stdout.flush()
408
409 def parse_blob(parser):
420 - global blob_marks
421 -
410 parser.next()
411 mark = parser.get_mark()
412 parser.next()
@@ -429,8 +417,6 @@ def parse_blob(parser):
417 class CustomTree():
418
419 def __init__(self, branch, revid, parents, files):
432 - global files_cache
433 -
420 self.updates = {}
421 self.branch = branch
422
@@ -587,9 +573,6 @@ def c_style_unescape(string):
573 return string
574
575 def parse_commit(parser):
590 - global marks, blob_marks, parsed_refs
591 - global mode
592 -
576 parents = []
577
578 ref = parser[1]
@@ -661,8 +644,6 @@ def parse_commit(parser):
644 marks.new_mark(revid, commit_mark)
645
646 def parse_reset(parser):
664 - global parsed_refs
665 -
647 ref = parser[1]
648 parser.next()
649
@@ -678,8 +659,6 @@ def parse_reset(parser):
659 parsed_refs[ref] = mark_to_rev(from_mark)
660
661 def do_export(parser):
681 - global parsed_refs, dirname
682 -
662 parser.next()
663
664 for line in parser.each_block('done'):
@@ -728,8 +707,6 @@ def do_export(parser):
707 print
708
709 def do_capabilities(parser):
731 - global dirname
732 -
710 print "import"
711 print "export"
712 print "refspec refs/heads/*:%s/heads/*" % prefix
@@ -747,8 +724,6 @@ def ref_is_valid(name):
724 return not True in [c in name for c in '~^: \\']
725
726 def do_list(parser):
750 - global tags
751 -
727 master_branch = None
728
729 for name in branches:
@@ -782,8 +757,6 @@ def clone(path, remote_branch):
757 return remote_branch.sprout(bdir, repository=repo)
758
759 def get_remote_branch(name):
785 - global dirname, branches
786 -
760 remote_branch = bzrlib.branch.Branch.open(branches[name])
761 if isinstance(remote_branch.user_transport, bzrlib.transport.local.LocalTransport):
762 return remote_branch
@@ -825,8 +798,6 @@ def find_branches(repo):
798 yield name, branch.base
799
800 def get_repo(url, alias):
828 - global dirname, peer, branches
829 -
801 normal_url = bzrlib.urlutils.normalize_url(url)
802 origin = bzrlib.bzrdir.BzrDir.open(url)
803 is_local = isinstance(origin.transport, bzrlib.transport.local.LocalTransport)
contrib/remote-helpers/git-remote-hg
+2 -28
@@ -227,8 +227,6 @@ class Parser:
227 return sys.stdin.read(size)
228
229 def get_author(self):
230 - global bad_mail
231 -
230 ex = None
231 m = RAW_AUTHOR_RE.match(self.line)
232 if not m:
@@ -261,8 +259,6 @@ def fix_file_path(path):
259 return os.path.relpath(path, '/')
260
261 def export_files(files):
264 - global marks, filenodes
265 -
262 final = []
263 for f in files:
264 fid = node.hex(f.filenode())
@@ -344,8 +340,6 @@ def fixup_user_hg(user):
340 return (name, mail)
341
342 def fixup_user(user):
347 - global mode, bad_mail
348 -
343 if mode == 'git':
344 name, mail = fixup_user_git(user)
345 else:
@@ -374,7 +368,7 @@ def updatebookmarks(repo, peer):
368 bookmarks.write(repo)
369
370 def get_repo(url, alias):
377 - global dirname, peer
371 + global peer
372
373 myui = ui.ui()
374 myui.setconfig('ui', 'interactive', 'off')
@@ -416,16 +410,12 @@ def get_repo(url, alias):
410 return repo
411
412 def rev_to_mark(rev):
419 - global marks
413 return marks.from_rev(rev.hex())
414
415 def mark_to_rev(mark):
423 - global marks
416 return marks.to_rev(mark)
417
418 def export_ref(repo, name, kind, head):
427 - global prefix, marks, mode
428 -
419 ename = '%s/%s' % (kind, name)
420 try:
421 tip = marks.get_tip(ename)
@@ -537,12 +527,9 @@ def export_branch(repo, branch):
527 export_ref(repo, branch, 'branches', head)
528
529 def export_head(repo):
540 - global g_head
530 export_ref(repo, g_head[0], 'bookmarks', g_head[1])
531
532 def do_capabilities(parser):
544 - global prefix, dirname
545 -
533 print "import"
534 print "export"
535 print "refspec refs/heads/branches/*:%s/branches/*" % prefix
@@ -562,8 +549,6 @@ def branch_tip(branch):
549 return branches[branch][-1]
550
551 def get_branch_tip(repo, branch):
565 - global branches
566 -
552 heads = branches.get(hgref(branch), None)
553 if not heads:
554 return None
@@ -576,7 +561,7 @@ def get_branch_tip(repo, branch):
561 return heads[0]
562
563 def list_head(repo, cur):
579 - global g_head, bmarks, fake_bmark
564 + global g_head, fake_bmark
565
566 if 'default' not in branches:
567 # empty repo
@@ -592,8 +577,6 @@ def list_head(repo, cur):
577 g_head = (head, node)
578
579 def do_list(parser):
595 - global branches, bmarks, track_branches
596 -
580 repo = parser.repo
581 for bmark, node in bookmarks.listbookmarks(repo).iteritems():
582 bmarks[bmark] = repo[node]
@@ -661,8 +644,6 @@ def do_import(parser):
644 print 'done'
645
646 def parse_blob(parser):
664 - global blob_marks
665 -
647 parser.next()
648 mark = parser.get_mark()
649 parser.next()
@@ -679,9 +660,6 @@ def get_merge_files(repo, p1, p2, files):
660 files[e] = f
661
662 def parse_commit(parser):
682 - global marks, blob_marks, parsed_refs
683 - global mode
684 -
663 from_mark = merge_mark = None
664
665 ref = parser[1]
@@ -799,8 +777,6 @@ def parse_commit(parser):
777 marks.new_mark(node, commit_mark)
778
779 def parse_reset(parser):
802 - global parsed_refs
803 -
780 ref = parser[1]
781 parser.next()
782 # ugh
@@ -993,8 +969,6 @@ def check_tip(ref, kind, name, heads):
969 return tip in heads
970
971 def do_export(parser):
996 - global parsed_refs, bmarks, peer
997 -
972 p_bmarks = []
973 p_revs = {}
974