bisect

What git commit practice is better?

空扰寡人 提交于 2019-12-03 07:27:06
I truly believe that to have one commit on one issue is a good practice. I'm sure I read it somewhere in an article like “Best practices”. As such, my workflow has been the following: For a new issue, I create a new local branch with git checkout -b new-issue . Commit all changes into it. Sometimes this involves lots of commits. When done, I squash the commits and rebase them into current thematic branch. If something goes wrong, I can git revert the commit, find the bug, fix it, and commit new patch into the thematic branch. I won't change the remote repository’s history. But today, I was

Finding first appearance of text in Mercurial repository

别等时光非礼了梦想. 提交于 2019-12-03 04:54:22
I have a Mercurial repository with ~800 changesets and I need to find the first changeset where the word Example appeared. The word appears inside a .php file and not on a commit comment etc. What is the quickest/easiest way to do that? try hg grep Example *.php hg grep [OPTION]... PATTERN [FILE]... search for a pattern in specified files and revisions Search revisions of files for a regular expression. This command behaves differently than Unix grep. It only accepts Python/Perl regexps. It searches repository history, not the working directory. It always prints the revision number in which a

using bisect on list of tuples but compare using first value only

烈酒焚心 提交于 2019-12-01 19:31:04
问题 I read that question about how to use bisect on a list of tuples, and I used that information to answer that question. It works, but I'd like a more generic solution. Since bisect doesn't allow to specify a key function, if I have this: import bisect test_array = [(1,2),(3,4),(5,6),(5,7000),(7,8),(9,10)] and I want to find the first item where x > 5 for those (x,y) tuples (not considering y at all, I'm currently doing this: bisect.bisect_left(test_array,(5,10000)) and I get the correct result

using bisect on list of tuples but compare using first value only

孤人 提交于 2019-12-01 19:04:16
I read that question about how to use bisect on a list of tuples, and I used that information to answer that question . It works, but I'd like a more generic solution. Since bisect doesn't allow to specify a key function, if I have this: import bisect test_array = [(1,2),(3,4),(5,6),(5,7000),(7,8),(9,10)] and I want to find the first item where x > 5 for those (x,y) tuples (not considering y at all, I'm currently doing this: bisect.bisect_left(test_array,(5,10000)) and I get the correct result because I know that no y is greater than 10000, so bisect points me to the index of (7,8) . Had I put

How could I use git bisect to find the first GOOD commit?

旧城冷巷雨未停 提交于 2019-11-29 20:05:29
I have the following problem: the version at master works fine the version of the last tag before master (say last ) has a bug a colleague needs a patch for his last revision for that certain bug Okay. Let's ask our friend git bisect for the revision that fixed the bug: git bisect start git bisect bad last git bisect good master But that's not going to work: Some good revs are not ancestor of the bad rev. git bisect cannot work properly in this case. Maybe you mistake good and bad revs? Any hints to overcome this? Did I miss something in the docs? Michael Wolf As of git 2.7, you can use the

How to use bisect.insort_left with a key?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 05:27:41
Doc's are lacking an example...How do you use bisect.insort_left)_ based on a key? Trying to insert based on key. bisect.insort_left(data, ('brown', 7)) puts insert at data[0] . From docs... bisect.insort_left( a, x, lo=0, hi=len(a) ) Insert x in a in sorted order. This is equivalent to a.insert(bisect.bisect_left(a, x, lo, hi), x) assuming that a is already sorted. Keep in mind that the O(log n) search is dominated by the slow O(n) insertion step. Sample usage: >>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)] >>> data.sort(key=lambda r: r[1]) >>> keys = [r[1] for r in data] #

How to use bisect.insort_left with a key?

爷,独闯天下 提交于 2019-11-27 22:57:52
问题 Doc's are lacking an example...How do you use bisect.insort_left)_ based on a key? Trying to insert based on key. bisect.insort_left(data, ('brown', 7)) puts insert at data[0] . From docs... bisect.insort_left( a, x, lo=0, hi=len(a) ) Insert x in a in sorted order. This is equivalent to a.insert(bisect.bisect_left(a, x, lo, hi), x) assuming that a is already sorted. Keep in mind that the O(log n) search is dominated by the slow O(n) insertion step. Sample usage: >>> data = [('red', 5), ('blue