From df14a70c4529821d7450303ec553a9f608af1656 Mon Sep 17 00:00:00 2001 From: Anthony Newnam Date: Sun, 9 Jan 2011 17:31:57 -0800 Subject: [PATCH 1/8] Make path references OS independent Change-Id: I5573995adfd52fd54bddc62d1d1ea78fb1328130 (cherry picked from commit b0f9a02394779c1c9422a9649412c9ac5fb0f12f) Conflicts: command.py --- command.py | 6 ++++-- manifest_xml.py | 2 +- project.py | 4 ++-- repo | 6 +++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/command.py b/command.py index a941b95a..8e93787e 100644 --- a/command.py +++ b/command.py @@ -74,7 +74,7 @@ class Command(object): project = all.get(arg) if not project: - path = os.path.abspath(arg) + path = os.path.abspath(arg).replace('\\', '/') if not by_path: by_path = dict() @@ -82,13 +82,15 @@ class Command(object): by_path[p.worktree] = p if os.path.exists(path): + oldpath = None while path \ - and path != '/' \ + and path != oldpath \ and path != self.manifest.topdir: try: project = by_path[path] break except KeyError: + oldpath = path path = os.path.dirname(path) else: try: diff --git a/manifest_xml.py b/manifest_xml.py index 9d68f09f..0103cf55 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -435,7 +435,7 @@ class XmlManifest(object): worktree = None gitdir = os.path.join(self.topdir, '%s.git' % name) else: - worktree = os.path.join(self.topdir, path) + worktree = os.path.join(self.topdir, path).replace('\\', '/') gitdir = os.path.join(self.repodir, 'projects/%s.git' % path) project = Project(manifest = self, diff --git a/project.py b/project.py index 01dc8678..25347daf 100644 --- a/project.py +++ b/project.py @@ -236,8 +236,8 @@ class Project(object): self.manifest = manifest self.name = name self.remote = remote - self.gitdir = gitdir - self.worktree = worktree + self.gitdir = gitdir.replace('\\', '/') + self.worktree = worktree.replace('\\', '/') self.relpath = relpath self.revisionExpr = revisionExpr diff --git a/repo b/repo index 02858ec2..96daa9b7 100755 --- a/repo +++ b/repo @@ -430,10 +430,14 @@ def _FindRepo(): dir = os.getcwd() repo = None - while dir != '/' and not repo: + olddir = None + while dir != '/' \ + and dir != olddir \ + and not repo: repo = os.path.join(dir, repodir, REPO_MAIN) if not os.path.isfile(repo): repo = None + olddir = dir dir = os.path.dirname(dir) return (repo, os.path.join(dir, repodir)) From 727ee98a401b5993f6b952074f43c7f770604acf Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Tue, 7 Dec 2010 08:46:14 -0800 Subject: [PATCH 2/8] Use os.environ.copy() instead of dict() Signed-off-by: Shawn O. Pearce (cherry picked from commit 3218c13205694434edb2375ab8a8515554eed366) --- git_command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git_command.py b/git_command.py index 4aeacd57..513b9ebf 100644 --- a/git_command.py +++ b/git_command.py @@ -127,7 +127,7 @@ class GitCommand(object): ssh_proxy = False, cwd = None, gitdir = None): - env = dict(os.environ) + env = os.environ.copy() for e in [REPO_TRACE, GIT_DIR, From de8b2c4276afec670dee5c7942ac74f2d0c66500 Mon Sep 17 00:00:00 2001 From: Thiago Farina Date: Wed, 9 Sep 2009 00:41:34 -0400 Subject: [PATCH 3/8] Fix to display the usage message of the command download when the user don't provide any arguments to 'repo download'. Signed-off-by: Thiago Farina (cherry picked from commit 840ed0fab7cb4c2ab296c7d7d45f13e2523bae1c) --- subcmds/download.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/subcmds/download.py b/subcmds/download.py index a6f3aa45..61eadd54 100644 --- a/subcmds/download.py +++ b/subcmds/download.py @@ -36,6 +36,9 @@ makes it available in your project's local working directory. pass def _ParseChangeIds(self, args): + if not args: + self.Usage() + to_get = [] project = None From 1b5a4a0c5de5fdaa4f8907357a0aa80e365dd199 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 22 Aug 2009 18:50:45 -0700 Subject: [PATCH 4/8] forall: Silently skip missing projects If a project is missing locally, it might be OK to skip over it and continue running the same command in other projects. Bug: REPO-43 Change-Id: I64f97eb315f379ab2c51fc53d24ed340b3d09250 Signed-off-by: Shawn O. Pearce (cherry picked from commit d4cd69bdef28c5a9287c85c48a18ce621eba689d) --- subcmds/forall.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subcmds/forall.py b/subcmds/forall.py index 8209c806..d3e70ae1 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py @@ -169,6 +169,12 @@ terminal and are not redirected. else: cwd = project.worktree + if not os.path.exists(cwd): + if (opt.project_header and opt.verbose) \ + or not opt.project_header: + print >>sys.stderr, 'skipping %s/' % project.relpath + continue + if opt.project_header: stdin = subprocess.PIPE stdout = subprocess.PIPE From f00e0ce556fc22fef180c74a9d78f1908d9aeb0b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 22 Aug 2009 18:39:49 -0700 Subject: [PATCH 5/8] upload: Catch and cleanly report connectivity errors Instead of giving a Python backtrace when there is a connectivity problem during repo upload, report that we cannot access the host, and why, with a halfway decent error message. Bug: REPO-45 Change-Id: I9a45b387e86e48073a2d99bd6d594c1a7d6d99d4 Signed-off-by: Shawn O. Pearce (cherry picked from commit d2dfac81ad6a060179b4b2289060af2dc7a5cdfd) --- git_config.py | 10 +++++++--- subcmds/upload.py | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/git_config.py b/git_config.py index 26fc970b..19c19f19 100644 --- a/git_config.py +++ b/git_config.py @@ -23,6 +23,8 @@ try: except ImportError: import dummy_threading as _threading import time +import urllib2 + from signal import SIGTERM from urllib2 import urlopen, HTTPError from error import GitError, UploadError @@ -563,23 +565,25 @@ class Remote(object): try: info = urlopen(u).read() if info == 'NOT_AVAILABLE': - raise UploadError('Upload over ssh unavailable') + raise UploadError('%s: SSH disabled' % self.review) if '<' in info: # Assume the server gave us some sort of HTML # response back, like maybe a login page. # - raise UploadError('Cannot read %s:\n%s' % (u, info)) + raise UploadError('%s: Cannot parse response' % u) self._review_protocol = 'ssh' self._review_host = info.split(" ")[0] self._review_port = info.split(" ")[1] + except urllib2.URLError, e: + raise UploadError('%s: %s' % (self.review, e.reason[1])) except HTTPError, e: if e.code == 404: self._review_protocol = 'http-post' self._review_host = None self._review_port = None else: - raise UploadError('Cannot guess Gerrit version') + raise UploadError('Upload over ssh unavailable') REVIEW_CACHE[u] = ( self._review_protocol, diff --git a/subcmds/upload.py b/subcmds/upload.py index 1964bffa..20822096 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py @@ -283,15 +283,19 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ have_errors = True print >>sys.stderr, '' - print >>sys.stderr, '--------------------------------------------' + print >>sys.stderr, '----------------------------------------------------------------------' if have_errors: for branch in todo: if not branch.uploaded: - print >>sys.stderr, '[FAILED] %-15s %-15s (%s)' % ( + if len(str(branch.error)) <= 30: + fmt = ' (%s)' + else: + fmt = '\n (%s)' + print >>sys.stderr, ('[FAILED] %-15s %-15s' + fmt) % ( branch.project.relpath + '/', \ branch.name, \ - branch.error) + str(branch.error)) print >>sys.stderr, '' for branch in todo: From 2bf9db0d3b0b4cf4e11187ea7438ddeb1262fe21 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Tue, 14 Jul 2009 15:23:39 -0400 Subject: [PATCH 6/8] Add "repo branch" as an alias for "repo branches" For those of us that are used to typing "git branch". Signed-off-by: Mike Lockwood (cherry picked from commit 33f0e786bb35ea11da1e3d1746c431da5f1d93eb) --- main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.py b/main.py index 31a18e18..f068fd47 100755 --- a/main.py +++ b/main.py @@ -61,6 +61,8 @@ class _Repo(object): def __init__(self, repodir): self.repodir = repodir self.commands = all_commands + # add 'branch' as an alias for 'branches' + all_commands['branch'] = all_commands['branches'] def _Run(self, argv): name = None From 0d2b61f11d0501fcf1e5a1c19f18dac03e0b09bc Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 3 Jul 2009 15:22:49 -0700 Subject: [PATCH 7/8] sync: Run `git gc --auto` after fetch Users may wind up with a lot of loose object content in projects they don't frequently make changes in, but that are modified by others. Since we bypass many git code paths that would have otherwise called out to `git gc --auto`, its possible for these projects to have their loose object database grow out of control. To help prevent that, we now invoke it ourselves during the network half of sync. Signed-off-by: Shawn O. Pearce (cherry picked from commit 1875ddd47c0bf38e5cc52e1e5875caabce2d8742) --- subcmds/selfupdate.py | 1 + subcmds/sync.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/subcmds/selfupdate.py b/subcmds/selfupdate.py index 4f46a129..46aa3a19 100644 --- a/subcmds/selfupdate.py +++ b/subcmds/selfupdate.py @@ -55,6 +55,7 @@ need to be performed by an end-user. print >>sys.stderr, "error: can't update repo" sys.exit(1) + rp.bare_git.gc('--auto') _PostRepoFetch(rp, no_repo_verify = opt.no_repo_verify, verbose = True) diff --git a/subcmds/sync.py b/subcmds/sync.py index 80bba1aa..36ef16db 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -185,6 +185,8 @@ later is required to fix a server side protocol bug. t.join() pm.end() + for project in projects: + project.bare_git.gc('--auto') return fetched def UpdateProjectList(self): From c7c57e34dbcc58c38c565dc98cfea4bf7736560a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 3 Jun 2009 17:43:16 -0700 Subject: [PATCH 8/8] help: Don't show empty Summary or Description sections Signed-off-by: Shawn O. Pearce (cherry picked from commit 60e679209a5495393ef584efaaad287fc8b77c51) --- subcmds/help.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subcmds/help.py b/subcmds/help.py index c5979fd6..90b817db 100644 --- a/subcmds/help.py +++ b/subcmds/help.py @@ -94,6 +94,8 @@ See 'repo help --all' for a complete list of recognized commands. body = getattr(cmd, bodyAttr) except AttributeError: return + if body == '' or body is None: + return self.nl()