From d8da2c1053ff1b153891b70dfbb8ef6fec681a50 Mon Sep 17 00:00:00 2001 From: "sky@chromium.org" Date: Fri, 9 Apr 2010 16:28:09 +0000 Subject: [PATCH] Changes GetSVNBranch to prefer the first ref over the last. The scenario I encountered was I've added another one of my machines as a remote, and because we preferred the last ref my diffs were always against my remote machine rather than local trunk. This change prefers the first over the last. Another option would be to prefer something like remotes/origin/trunk. Let me know what you think. I've got a similar change to git-cl, but I'll wait until we agree upon this before uploading that one. Review URL: http://codereview.chromium.org/1622011 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@44094 0039d316-1c4b-4281-b951-d872f2087c98 --- scm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scm.py b/scm.py index 209e064631..3febbe495d 100644 --- a/scm.py +++ b/scm.py @@ -172,7 +172,9 @@ class GIT(object): for ref in remotes: match = git_svn_re.search( GIT.Capture(['cat-file', '-p', ref], cwd)[0]) - if match: + if match and match.group(1) not in svn_refs: + # To prefer local refs over remote ones we only set the first occurence. + # The assumption being local refs are usually first. svn_refs[match.group(1)] = ref svn_branch = ''