summaryrefslogtreecommitdiffstats
path: root/main.py
Commit message (Collapse)AuthorAgeFilesLines
* pylint: Fix unused-{argument,variable} warningStefan Beller2016-06-211-1/+1
| | | | | | | | | | | | | | | | This commit fixes 4 out of the remaining 5 pylint warnings: $ pylint --rcfile=.pylintrc *.py ************* Module gitc_utils W:146, 0: TODO(sbasi/jorg): Come up with a solution to remove the sleep below. (fixme) W:130, 6: Unused variable 'name' (unused-variable) ************* Module main W:382,32: Unused argument 'fp' (unused-argument) W:382,36: Unused argument 'code' (unused-argument) W:382,42: Unused argument 'msg' (unused-argument) Change-Id: Ie3d77b9a65b7daefaa9aa4b80f4b682c1678fd58 Signed-off-by: Stefan Beller <sbeller@google.com>
* Add GitcClientCommand class for GITC-specific commandsDan Willemsen2015-09-291-2/+7
| | | | | | | These won't show up as common commands in the help text unless in a GITC client, and will refuse to execute. Change-Id: Iffe82adcc9d6ddde9cb4b204f83ff018042bdab0
* gitc: Improve help visibilityv1.12.28Dan Willemsen2015-09-011-0/+6
| | | | | | | This improves the visiblity of gitc-init if we can get the gitc config, and hides it otherwise. Change-Id: I82830b0b07c311e8c74397ba79eb4c361f8b6fb5
* GITC: Add repo start support.Simran Basi2015-08-281-1/+8
| | | | | | | | | | | | | | | | | | | | | Add repo start support for GITC checkouts. If the user is in the GITC FS view, they can now run repo start to check out the sources and create a new working branch. When "repo start" is called on a GITC project, the revision tag is set to an empty string and saved in a new tag: old-revision. This tells the GITC filesystem to display the local copy of the sources when being viewed. The local copy is created by pulling the project sources and the new branch is created based off the original project revision. Updated main.py to setup each command's gitc_manifest when appropriate. Updated repo sync's logic to sync opened projects and updating the GITC manifest file for the rest. Change-Id: I7e4809d1c4fc43c69b26f2f1bebe45aab0cae628
* Improve error message when syncing a project with invalid groups.Jarkko Pöyry2015-06-191-0/+7
| | | | Change-Id: Iaf5c2a0f00667dc09bcf455cfe2f39bfbaa2bfc0
* add a global --color optionMike Frysinger2014-12-301-0/+6
| | | | | | | | | | | If you want to turn off colors for commands, you have to manually adjust the git config settings (in various locations). If you're writing scripts though, you often don't want to modify those locations. Add a commandline option to explicitly control things. The default behavior is unchanged -- we still scan the config files. Change-Id: I54a3fd8e1918bac180aadd7c7d3004f069b02522
* More verbose errors for NoManifestExceptions.Dan Sandler2014-03-111-11/+16
| | | | | | | | | | | | | | | | The old "manifest required for this command -- please run init" is replaced by a more helpful message that lists the command repo was trying to execute (with arguments) as well as the str() of the NoManifestException. For example: > error: in `sync`: [Errno 2] No such file or directory: > 'path/to/.repo/manifests/.git/HEAD' > error: manifest missing or unreadable -- please run init Other failure points in basic command parsing and dispatch are more clearly explained in the same fashion. Change-Id: I6212e5c648bc5d57e27145d55a5391ca565e4149
* Implement Kerberos HTTP authentication handlerCarlos Aguado2014-02-041-0/+87
| | | | | | | | | | | | This commit implements a Kerberos HTTP authentication handler. It uses credentials from a local cache to perform an HTTP authentication negotiation using the GSSAPI. The purpose of this handler is to allow the use Kerberos authentication to access review endpoints without the need to transmit the user password. Change-Id: Id2c3fc91a58b15a3e83e4bd9ca87203fa3d647c8
* Add wrapper moduleConley Owens2014-01-301-15/+5
| | | | | | | | This takes the wrapper importing code from main.py and moves it into its own module so that other modules may import it without causing circular imports with main.py. Change-Id: I9402950573933ed6f14ce0bfb600f74f32727705
* Move Python version checking to a separate moduleDavid Pursehouse2013-05-231-8/+7
| | | | | | | | | | | | | | | | | Add a new module with methods for checking the Python version. Instead of handling Python3 imports with try...except blocks, first check the python version and then import the relevant modules. This makes the code a bit cleaner and will result in less diff when/if we remove support for Python < 3 later. Use the same mechanism to handle `input` vs. `raw_input` and add suppression of pylint warnings caused by redefinition of the built-in method `input`. Change-Id: Ia403e525b88d77640a741ac50382146e7d635924 Also-by: Chirayu Desai <cdesai@cyanogenmod.org> Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org>
* Some fixes for supporting python3Chirayu Desai2013-04-181-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix imports. * Use python3 syntax. * Wrap map() calls with list(). * Use list() only wherever needed. (Thanks Conley!) * Fix dictionary iteration methods (s/iteritems/items/). * Make use of sorted() in appropriate places * Use iterators directly in the loop. * Don't use .keys() wherever it isn't needed. * Use sys.maxsize instead of sys.maxint TODO: * Make repo work fully with python3. :) Some of this was done by the '2to3' tool [1], by applying the needed fixes in a way that doesn't break compatibility with python2. Links: [1]: http://docs.python.org/2/library/2to3.html Change-Id: Ibdf3bf9a530d716db905733cb9bfef83a48820f7 Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org>
* Allow command options to be set from environment variablesDavid Pursehouse2012-11-171-0/+1
| | | | | | | | | | | | Extend the Command base class to allow options to be set from values in environment variables, if the user has not given the option on the command line and the environment variable is set. Derived classes of Command can override the implementation of the method _GetEnvironmentOptions to configure which of its options may be set from environment variables. Change-Id: I7c780bcf9644d6567893d9930984c054bce7351e
* Raise a NoManifestException when the manifest DNEConley Owens2012-11-151-0/+5
| | | | | | | | | When a command (eg, `repo forall`) expects the manifest project to exist, but there is no manifest, an IOException gets raised. This change defines a new Exception type to be raised in these cases and raises it when project.py fails to read the manifest. Change-Id: Iac576c293a37f7d8f60cd4f6aa95b2c97f9e7957
* Merge "Simplify error handling in subcommand execution"Conley Owens2012-11-141-16/+15
|\
| * Simplify error handling in subcommand executionConley Owens2012-11-141-16/+15
| | | | | | | | | | | | | | Instead of using a nested try (which repo is plagued with), use a single try when executing the appropriate subcommand. Change-Id: I32dbfc010c740c0cc42ef8fb6a83dfe87f87e54a
* | Fix inconsistent indentationDavid Pursehouse2012-11-141-11/+11
|/ | | | | | | | | | The repo coding style is to indent at 2 characters, but there are many places where this is not followed. Enable pylint warning "W0311: Bad indentation" and make sure all indentation is at multiples of 2 characters. Change-Id: I68f0f64470789ce2429ab11104d15d380a63e6a8
* Change print statements to work in python3Sarah Owens2012-11-131-26/+24
| | | | | | This is part of a series of changes to introduce Python3 support. Change-Id: I373be5de7141aa127d7debdbce1df39148dbec32
* More code style cleanupDavid Pursehouse2012-11-141-1/+0
| | | | | | | | | Clean up a few more unnecessary usages of lambda in `repo` that were missed in the previous sweep that only considered files ending in .py. Remove a duplicate import. Change-Id: I03cf467a5630cbe4eee6649520c52e94a7db76be
* Remove magic hackDavid Pursehouse2012-11-141-9/+1
| | | | | | | | | | | | | It should be assumed that on modern development environments, python is accessible to /usr/bin/env Change the shebang as necessary and remove the magic hack. This also means losing the -E option on the call to python, so that PYTHONPATH and PYTHONHOME will be respected and local configuration problems in those vars would be noticed Change-Id: I6f0708ca7693f05a4c3621c338f03619563ba630
* Merge "Print an error message when aborted by user"Conley Owens2012-11-121-0/+1
|\
| * Print an error message when aborted by userDavid Pursehouse2012-11-131-0/+1
| | | | | | | | Change-Id: If7378c5deaace0ac6ab2be961e38644d9373557d
* | Merge "Handle manifest parse errors in main"Conley Owens2012-11-121-0/+4
|\|
| * Handle manifest parse errors in mainDavid Pursehouse2012-11-131-0/+4
| | | | | | | | | | | | | | | | Add handling of manifest parse errors in the main method, and print an error. This will prevent python tracebacks being dumped in many cases. Change-Id: I75e73539afa34049f73c993dbfda203f1ad33b45
* | Merge "Change usages of xrange() to range()"Conley Owens2012-11-121-1/+1
|\ \ | |/ |/|
| * Change usages of xrange() to range()Sarah Owens2012-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | In Python3, range() creates a generator rather than a list. None of the parameters in the ranges changed looked large enough to create an impact in memory in Python2. Note: the only use of range() was for iteration and did not need to be changed. This is part of a series of changes to introduce Python3 support. Change-Id: I50b665f9296ea160a5076c71f36a65f76e47029f
* | Fix pylint warning W0108: Lambda may not be necessaryDavid Pursehouse2012-11-071-4/+3
|/ | | | | | Remove unnecessary usage of lambda. Change-Id: I06d41933057d60d15d307ee800cca052a44754c6
* Use python3 urllib when urllib2 not availableSarah Owens2012-10-311-13/+22
| | | | | | This is part of a series of changes to introduce Python3 support. Change-Id: I605b145791053c1f2d7bf3c907c5a68649b21d12
* Even more coding style cleanupDavid Pursehouse2012-10-301-1/+0
| | | | | | | | | | | Fixing some more pylint warnings: W1401: Anomalous backslash in string W0623: Redefining name 'name' from outer scope W0702: No exception type(s) specified E0102: name: function already defined line n Change-Id: I5afcdb4771ce210390a79981937806e30900a93c
* Update PGP keys during _PostRepoUpgrade in `sync`Conley Owens2012-10-251-9/+9
| | | | | | | | Previously, if a key was added, a client wouldn't add the key during the sync step. This would cause issues if a new key were added and a subsequent release were signed by that key. Change-Id: I4fac317573cd9d0e8da62aa42e00faf08bfeb26c
* Use modern Python exception syntaxSarah Owens2012-10-231-5/+5
| | | | | | | | | | | "except Exception as e" instead of "except Exception, e" This is part of a transition to supporting Python 3. Python >= 2.6 support "as" syntax. Note: this removes Python 2.5 support. Change-Id: I309599f3981bba2b46111c43102bee38ff132803
* More coding style cleanupDavid Pursehouse2012-10-221-1/+1
| | | | | | | | | | | | | | | | Fixing more issues found with pylint. Some that were supposed to have been fixed in the previous sweep (Ie0db839e) but were missed: C0321: More than one statement on a single line W0622: Redefining built-in 'name' And some more: W0631: Using possibly undefined loop variable 'name' W0223: Method 'name' is abstract in class 'name' but is not overridden W0231: __init__ method from base class 'name' is not called Change-Id: Ie119183708609d6279e973057a385fde864230c3
* Support HTTP authentication using user input as fallbackJoonCheol Park2012-10-121-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If repo could not find authentication credentials from ~/.netrc, this patch tries to get user and password from user's console input. This could be a good choice if user doesn't want to save his plain password in ~/.netrc or if user doesn't know about the netrc usage. The user will be prompted only if authentication infomation does not exist in the password manager. Since main.py firstly loads auth infomation from ~/.netrc, this will be executed only as fallback mechanism. Example: $ repo upload . Upload project xxx/ to remote branch master: branch yyy ( 1 commit, ...): to https://review.zzz.com/gerrit/ (y/N)? y (repo may try to access to https://review.zzz.com/gerrit/ssh_info and will get the 401 HTTP Basic Authentication response from server. If no authentication info in ~/.netrc, This patch will ask username/passwd) Authorization Required (Message from Web Server) User: pororo Password: .... [OK ] xxx/ Change-Id: Ia348a4609ac40060d9093c7dc8d7c2560020455a
* Rename "dir" variablesMickaël Salaün2012-10-101-2/+2
| | | | | | | 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
* Coding style cleanupDavid Pursehouse2012-10-091-5/+5
| | | | | | | | | | | | | | | Fix the following issues reported by pylint: C0321: More than one statement on a single line W0622: Redefining built-in 'name' W0612: Unused variable 'name' W0613: Unused argument 'name' W0102: Dangerous default value 'value' as argument W0105: String statement has no effect Also fixed a few cases of inconsistent indentation. Change-Id: Ie0db839e7c57d576cff12d8c055fe87030d00744
* Remove unused importsDavid Pursehouse2012-08-231-1/+0
| | | | | | There are several imports that are not used. Remove them. Change-Id: I2ac3be66827bd68d3faedcef7d6bbf30ea01d3f2
* Add support for Apache Digest authentication for repo init.Xiaodong Xu2012-03-141-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | repo tool supports only Basic authentication for now. For those who want to use this tool to manage their own projects, in case the administrator has configured the Apache server with Digest authentication method, users will fail to be authenticated when they run the command 'repo init'. Add the digest authentication password manager to the handler list will fix this issue. Since Git HTTP protocol will require the user be authenticated for fetch operation first before pushing commits to the remote, it is unlikely for the administrator to implement anonymous read (aka pull) access and write access (aka push) for authenticated user. Both read and write have to be authenticated. Be aware that the user may have to add an extra line in his ~/.netrc file: ------------------- account example.com ------------------- where 'example.com' is the realm for Apache Digest authentication. Change-Id: I76eb27b205554426d9ce1965deaaf727b87916cd Signed-off-by: Xiaodong Xu <stid.smth@gmail.com>
* Describe the repo launch version in `repo version`Shawn O. Pearce2011-11-291-0/+4
| | | | | | | | | | | | repo version v1.7.8 (from https://android.googlesource.com/tools/repo.git) repo launcher version 1.14 (from /home/sop/bin/repo) git version 1.7.8.rc2.256.gcc761 Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] Change-Id: Ifcbe5b0e226a1a6ca85455eb62e4da5e9a0f0ca0
* Propagate result codes from subcmds to sys.exit().Daniel Sandler2011-11-291-10/+17
| | | | | | | Allows scripts driving repo to know when git failures have occurred, not just repo internal errors. Change-Id: Id20fbbb405c35a148e72c87b822da3f3bf93839c
* Fix sync on Python 2.6.6v1.7.7.4Shawn O. Pearce2011-10-111-0/+2
| | | | | | | | | | Python 2.6.6 has the same bug as Python 2.7, where HTTP authentication just stops working, but does not have the setter method to clear the retry counter. Work around by setting the field directly if it exists. Change-Id: I6a742e606bb7750dc66c33fc7c5d1310541db2c8 Signed-off-by: Shawn O. Pearce <sop@google.com>
* Fix Python 2.4 supportShawn O. Pearce2011-10-111-1/+8
| | | | | Change-Id: I89521ae52fa564f0d849cc51e71fee65b3c47bab Signed-off-by: Shawn O. Pearce <sop@google.com>
* Work around Python 2.7 urllib2 bugShawn O. Pearce2011-10-111-1/+10
| | | | | | | | | | | | | | | If the remote is using authenticated HTTP, but does not have $GIT_URL/clone.bundle files in each repository, an initial sync would fail around 8 projects in due to the library not resetting the number of failures after getting a 404. Work around this by updating the retry counter ourselves. The urllib2 library is also not thread-safe. Make it somewhat safer by wrapping the critical section with a lock. Change-Id: I886e2750ef4793cbe2150c3b5396eb9f10974f7f Signed-off-by: Shawn O. Pearce <sop@google.com>
* sync: Support downloading bundle to initialize repositoryv1.7.7Shawn O. Pearce2011-09-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | An HTTP (or HTTPS) based remote server may now offer a 'clone.bundle' file in each repository's Git directory. Over an http:// or https:// remote repo will first ask for '$URL/clone.bundle', and if present download this to bootstrap the local client, rather than relying on the native Git transport to initialize the new repository. Bundles may be hosted elsewhere. The client automatically follows a HTTP 302 redirect to acquire the bundle file. This allows servers to direct clients to cached copies residing on content delivery networks, where the bundle may be closer to the end-user. Bundle downloads are resumeable from where they last left off, allowing clients to initialize large repositories even when the connection gets interrupted. If a bundle does not exist for a repository (a HTTP 404 response code is returned for '$URL/clone.bundle'), the native Git transport is used instead. If the client is performing a shallow sync, the bundle transport is not used, as there is no way to embed shallow data into the bundle. Change-Id: I05dad17792fd6fd20635a0f71589566e557cc743 Signed-off-by: Shawn O. Pearce <sop@google.com>
* Ignore missing ~/.netrcv1.7.6.1Shawn O. Pearce2011-09-231-0/+2
| | | | | Change-Id: Ifa6065d57a6cb11ad57ddd44bc88d9690fe234ab Signed-off-by: Shawn O. Pearce <sop@google.com>
* Add global option --time to track executionShawn O. Pearce2011-09-221-1/+18
| | | | | | | | | This prints a simple line after a command ends, providing information about how long it executed for using real wall clock time. Its mostly useful for looking at sync times. Change-Id: Ie0997df0a0f90150270835d94b58a01a10bc3956 Signed-off-by: Shawn O. Pearce <sop@google.com>
* Support ~/.netrc for HTTP Basic authenticationShawn O. Pearce2011-09-191-0/+12
| | | | | | | | | If repo tries to access a URL over HTTP and the user needs to authenticate, offer a match from ~/.netrc. This matches behavior with the Git command line client. Change-Id: I803f3c5d562177ea0330941350cff3cc1e1bef08 Signed-off-by: Shawn O. Pearce <sop@google.com>
* Enhance HTTP supportShawn O. Pearce2011-09-191-2/+58
| | | | | | | | | | | | | | Setting REPO_CURL_VERBOSE=1 in the environment will register a debug level HTTPHandler on the urllib2 library, showing HTTP requests and responses on the stderr channel of repo. During any HTTP or HTTPS request created inside of the repo process, a custom User-Agent header is now defined: User-Agent: git-repo/1.7.5 (Linux) git/1.7.7 Python/2.6.5 Change-Id: Ia5026fb1e1500659bd2af27416d85e205048bf26 Signed-off-by: Shawn O. Pearce <sop@google.com>
* Honor http_proxy variable globallyShawn O. Pearce2011-09-111-0/+8
| | | | | | | | If the http_proxy environment variable was set, honor it during the entire repo session for any Python created HTTP connections. Change-Id: Ib4ae833cb2cdd47ab0126949f6b399d2c142887d Signed-off-by: Shawn O. Pearce <sop@google.com>
* Add "repo branch" as an alias for "repo branches"Mike Lockwood2011-01-091-0/+2
| | | | | | | For those of us that are used to typing "git branch". Signed-off-by: Mike Lockwood <lockwood@android.com> (cherry picked from commit 33f0e786bb35ea11da1e3d1746c431da5f1d93eb)
* Fixed race condition in 'repo sync -jN' that would open multiple masters.v1.7.2Doug Anderson2010-12-211-1/+2
| | | | | | | | This fixes the SSH Control Masters to be managed in a thread-safe fashion. This is important because "repo sync -jN" uses threads to sync more than one repository at the same time. The problem didn't show up earlier because it was masked if all of the threads tried to connect to the same host that was used on the "repo init" line.
* Refactor Manifest to be XmlManifestShawn O. Pearce2009-05-291-2/+2
| | | | | | | | We'll soon be supporting two different manifest formats, but we can't immediately remove support for the current XML one that is in wide spread use within Android. Signed-off-by: Shawn O. Pearce <sop@google.com>