summaryrefslogtreecommitdiffstats
path: root/git_refs.py
Commit message (Collapse)AuthorAgeFilesLines
* Some fixes for supporting python3Chirayu Desai2013-04-181-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Even more coding style cleanupDavid Pursehouse2012-10-301-2/+2
| | | | | | | | | | | 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
* Coding style cleanupDavid Pursehouse2012-10-091-8/+8
| | | | | | | | | | | | | | | 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
* Improve error handling when reading loose refsv1.7.8Shawn O. Pearce2011-11-291-5/+7
| | | | | | | When repo is trying to figure out branches the repository has by traversing refs/heads, add exception handling for readline. Change-Id: If3b2a3720c6496f52f629aa9a2539f186d6ec882
* Make usage of open safer by setting binary mode and closing fdsShawn O. Pearce2009-04-181-2/+2
| | | | Signed-off-by: Shawn O. Pearce <sop@google.com>
* Fix `repo --trace` to show ref and config loadsShawn O. Pearce2009-04-181-5/+5
| | | | | | | | | The value of the varible TRACE was copied during the import, which happens before the --trace option can be processed. So instead we now use a function to determine if the value is set, as the function can be safely copied early during import. Signed-off-by: Shawn O. Pearce <sop@google.com>
* Enable tracing of ref scans and config unpicklingShawn O. Pearce2009-04-171-0/+6
| | | | | | | | These are not as expensive as spawning a git command, but they are not free either. We want to keep track of how many times we wind up calling them on any particular operation. Signed-off-by: Shawn O. Pearce <sop@google.com>
* Avoid unnecessary git symbolic-ref calls during repo syncShawn O. Pearce2009-04-171-2/+12
| | | | | | | | If the m/BRANCH ref is already pointing at the value set in the manifest there is no reason to set it again. Leave it alone, thus saving a full fork+exec call. Signed-off-by: Shawn O. Pearce <sop@google.com>
* Improve repo sync performance by avoid git forksShawn O. Pearce2009-04-171-0/+11
| | | | | | | | | | | By resolving the current HEAD and the manifest revision using pure Python, we can in the common case of "no changes" avoid a lot of git operations and directly jump out of the local sync method. This reduces the no-op `repo sync -l` time for Android's 114 projects from more than 6s to under 0.8s. Signed-off-by: Shawn O. Pearce <sop@google.com>
* Implement git ref reading purely in PythonShawn O. Pearce2009-04-171-0/+133
Its much faster to read the refs from 114 projects when the reader is pure Python and just doing file IO than forking 114 git commands and parsing their output. The reader caches refs based upon file mtimes. If any single ref file has been modified since the last read, we re-read the entire repository's ref namespace. This simplifies the code as we don't need to worry about shooting down symbolic-refs, but it may cause more IO than is necessary if only one ref gets updated. This change drops `repo branches` in Android from 1.658s to 0.206s. Likewise, `repo sync` improves dramatically as well. Signed-off-by: Shawn O. Pearce <sop@google.com>