diff options
| author | Mickaël Salaün <mic@digikod.net> | 2012-09-30 00:37:55 +0200 |
|---|---|---|
| committer | Mickaël Salaün <mic@digikod.net> | 2012-10-10 08:30:15 +0200 |
| commit | 2f6ab7f5b8f21b2dbfe9ae102674bd1694e94f03 (patch) | |
| tree | 040f9045751d83902ea8c479304fdfa2a0061a54 | |
| parent | 3a6cd4200e42fbb5a21b3fb8d3c9738c0320cc63 (diff) | |
| download | git-repo-2f6ab7f5b8f21b2dbfe9ae102674bd1694e94f03.tar.gz | |
Rename "dir" variables
The variable name "dir" conflicts with the name of a Python built-in
function: http://docs.python.org/library/functions.html#dir
Change-Id: I850f3ec8df7563dc85e21f2876fe5e6550ca2d8f
| -rw-r--r-- | git_command.py | 8 | ||||
| -rwxr-xr-x | main.py | 4 | ||||
| -rw-r--r-- | project.py | 6 | ||||
| -rwxr-xr-x | repo | 30 | ||||
| -rw-r--r-- | subcmds/sync.py | 8 |
5 files changed, 28 insertions, 28 deletions
diff --git a/git_command.py b/git_command.py index 5988cc28..82709b91 100644 --- a/git_command.py +++ b/git_command.py | |||
| @@ -37,11 +37,11 @@ def ssh_sock(create=True): | |||
| 37 | if _ssh_sock_path is None: | 37 | if _ssh_sock_path is None: |
| 38 | if not create: | 38 | if not create: |
| 39 | return None | 39 | return None |
| 40 | dir = '/tmp' | 40 | tmp_dir = '/tmp' |
| 41 | if not os.path.exists(dir): | 41 | if not os.path.exists(tmp_dir): |
| 42 | dir = tempfile.gettempdir() | 42 | tmp_dir = tempfile.gettempdir() |
| 43 | _ssh_sock_path = os.path.join( | 43 | _ssh_sock_path = os.path.join( |
| 44 | tempfile.mkdtemp('', 'ssh-', dir), | 44 | tempfile.mkdtemp('', 'ssh-', tmp_dir), |
| 45 | 'master-%r@%h:%p') | 45 | 'master-%r@%h:%p') |
| 46 | return _ssh_sock_path | 46 | return _ssh_sock_path |
| 47 | 47 | ||
| @@ -209,8 +209,8 @@ def _CheckWrapperVersion(ver, repo_path): | |||
| 209 | cp %s %s | 209 | cp %s %s |
| 210 | """ % (exp_str, _MyWrapperPath(), repo_path) | 210 | """ % (exp_str, _MyWrapperPath(), repo_path) |
| 211 | 211 | ||
| 212 | def _CheckRepoDir(dir): | 212 | def _CheckRepoDir(repo_dir): |
| 213 | if not dir: | 213 | if not repo_dir: |
| 214 | print >>sys.stderr, 'no --repo-dir argument' | 214 | print >>sys.stderr, 'no --repo-dir argument' |
| 215 | sys.exit(1) | 215 | sys.exit(1) |
| 216 | 216 | ||
| @@ -209,9 +209,9 @@ class _CopyFile: | |||
| 209 | if os.path.exists(dest): | 209 | if os.path.exists(dest): |
| 210 | os.remove(dest) | 210 | os.remove(dest) |
| 211 | else: | 211 | else: |
| 212 | dir = os.path.dirname(dest) | 212 | dest_dir = os.path.dirname(dest) |
| 213 | if not os.path.isdir(dir): | 213 | if not os.path.isdir(dest_dir): |
| 214 | os.makedirs(dir) | 214 | os.makedirs(dest_dir) |
| 215 | shutil.copy(src, dest) | 215 | shutil.copy(src, dest) |
| 216 | # make the file read-only | 216 | # make the file read-only |
| 217 | mode = os.stat(dest)[stat.ST_MODE] | 217 | mode = os.stat(dest)[stat.ST_MODE] |
| @@ -538,19 +538,19 @@ def _Checkout(cwd, branch, rev, quiet): | |||
| 538 | def _FindRepo(): | 538 | def _FindRepo(): |
| 539 | """Look for a repo installation, starting at the current directory. | 539 | """Look for a repo installation, starting at the current directory. |
| 540 | """ | 540 | """ |
| 541 | dir = os.getcwd() | 541 | curdir = os.getcwd() |
| 542 | repo = None | 542 | repo = None |
| 543 | 543 | ||
| 544 | olddir = None | 544 | olddir = None |
| 545 | while dir != '/' \ | 545 | while curdir != '/' \ |
| 546 | and dir != olddir \ | 546 | and curdir != olddir \ |
| 547 | and not repo: | 547 | and not repo: |
| 548 | repo = os.path.join(dir, repodir, REPO_MAIN) | 548 | repo = os.path.join(curdir, repodir, REPO_MAIN) |
| 549 | if not os.path.isfile(repo): | 549 | if not os.path.isfile(repo): |
| 550 | repo = None | 550 | repo = None |
| 551 | olddir = dir | 551 | olddir = curdir |
| 552 | dir = os.path.dirname(dir) | 552 | curdir = os.path.dirname(curdir) |
| 553 | return (repo, os.path.join(dir, repodir)) | 553 | return (repo, os.path.join(curdir, repodir)) |
| 554 | 554 | ||
| 555 | 555 | ||
| 556 | class _Options: | 556 | class _Options: |
| @@ -656,13 +656,13 @@ def _SetDefaultsTo(gitdir): | |||
| 656 | 656 | ||
| 657 | 657 | ||
| 658 | def main(orig_args): | 658 | def main(orig_args): |
| 659 | main, dir = _FindRepo() | 659 | repo_main, rel_repo_dir = _FindRepo() |
| 660 | cmd, opt, args = _ParseArguments(orig_args) | 660 | cmd, opt, args = _ParseArguments(orig_args) |
| 661 | 661 | ||
| 662 | wrapper_path = os.path.abspath(__file__) | 662 | wrapper_path = os.path.abspath(__file__) |
| 663 | my_main, my_git = _RunSelf(wrapper_path) | 663 | my_main, my_git = _RunSelf(wrapper_path) |
| 664 | 664 | ||
| 665 | if not main: | 665 | if not repo_main: |
| 666 | if opt.help: | 666 | if opt.help: |
| 667 | _Usage() | 667 | _Usage() |
| 668 | if cmd == 'help': | 668 | if cmd == 'help': |
| @@ -682,25 +682,25 @@ def main(orig_args): | |||
| 682 | os.rmdir(os.path.join(root, name)) | 682 | os.rmdir(os.path.join(root, name)) |
| 683 | os.rmdir(repodir) | 683 | os.rmdir(repodir) |
| 684 | sys.exit(1) | 684 | sys.exit(1) |
| 685 | main, dir = _FindRepo() | 685 | repo_main, rel_repo_dir = _FindRepo() |
| 686 | else: | 686 | else: |
| 687 | _NoCommands(cmd) | 687 | _NoCommands(cmd) |
| 688 | 688 | ||
| 689 | if my_main: | 689 | if my_main: |
| 690 | main = my_main | 690 | repo_main = my_main |
| 691 | 691 | ||
| 692 | ver_str = '.'.join(map(lambda x: str(x), VERSION)) | 692 | ver_str = '.'.join(map(lambda x: str(x), VERSION)) |
| 693 | me = [main, | 693 | me = [repo_main, |
| 694 | '--repo-dir=%s' % dir, | 694 | '--repo-dir=%s' % rel_repo_dir, |
| 695 | '--wrapper-version=%s' % ver_str, | 695 | '--wrapper-version=%s' % ver_str, |
| 696 | '--wrapper-path=%s' % wrapper_path, | 696 | '--wrapper-path=%s' % wrapper_path, |
| 697 | '--'] | 697 | '--'] |
| 698 | me.extend(orig_args) | 698 | me.extend(orig_args) |
| 699 | me.extend(extra_args) | 699 | me.extend(extra_args) |
| 700 | try: | 700 | try: |
| 701 | os.execv(main, me) | 701 | os.execv(repo_main, me) |
| 702 | except OSError, e: | 702 | except OSError, e: |
| 703 | print >>sys.stderr, "fatal: unable to start %s" % main | 703 | print >>sys.stderr, "fatal: unable to start %s" % repo_main |
| 704 | print >>sys.stderr, "fatal: %s" % e | 704 | print >>sys.stderr, "fatal: %s" % e |
| 705 | sys.exit(148) | 705 | sys.exit(148) |
| 706 | 706 | ||
diff --git a/subcmds/sync.py b/subcmds/sync.py index 1b716351..e68a025e 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -339,13 +339,13 @@ uncommitted changes are present' % project.relpath | |||
| 339 | print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree | 339 | print >>sys.stderr, 'Deleting obsolete path %s' % project.worktree |
| 340 | shutil.rmtree(project.worktree) | 340 | shutil.rmtree(project.worktree) |
| 341 | # Try deleting parent subdirs if they are empty | 341 | # Try deleting parent subdirs if they are empty |
| 342 | dir = os.path.dirname(project.worktree) | 342 | project_dir = os.path.dirname(project.worktree) |
| 343 | while dir != self.manifest.topdir: | 343 | while project_dir != self.manifest.topdir: |
| 344 | try: | 344 | try: |
| 345 | os.rmdir(dir) | 345 | os.rmdir(project_dir) |
| 346 | except OSError: | 346 | except OSError: |
| 347 | break | 347 | break |
| 348 | dir = os.path.dirname(dir) | 348 | project_dir = os.path.dirname(project_dir) |
| 349 | 349 | ||
| 350 | new_project_paths.sort() | 350 | new_project_paths.sort() |
| 351 | fd = open(file_path, 'w') | 351 | fd = open(file_path, 'w') |
