summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--git_config.py12
-rw-r--r--git_refs.py11
-rw-r--r--subcmds/start.py10
3 files changed, 21 insertions, 12 deletions
diff --git a/git_config.py b/git_config.py
index e00f6be2..8c247394 100644
--- a/git_config.py
+++ b/git_config.py
@@ -50,16 +50,24 @@ else:
50from git_command import GitCommand 50from git_command import GitCommand
51from git_command import ssh_sock 51from git_command import ssh_sock
52from git_command import terminate_ssh_clients 52from git_command import terminate_ssh_clients
53from git_refs import R_CHANGES, R_HEADS, R_TAGS
53 54
54R_HEADS = 'refs/heads/'
55R_TAGS = 'refs/tags/'
56ID_RE = re.compile(r'^[0-9a-f]{40}$') 55ID_RE = re.compile(r'^[0-9a-f]{40}$')
57 56
58REVIEW_CACHE = dict() 57REVIEW_CACHE = dict()
59 58
59def IsChange(rev):
60 return rev.startswith(R_CHANGES)
61
60def IsId(rev): 62def IsId(rev):
61 return ID_RE.match(rev) 63 return ID_RE.match(rev)
62 64
65def IsTag(rev):
66 return rev.startswith(R_TAGS)
67
68def IsImmutable(rev):
69 return IsChange(rev) or IsId(rev) or IsTag(rev)
70
63def _key(name): 71def _key(name):
64 parts = name.split('.') 72 parts = name.split('.')
65 if len(parts) < 2: 73 if len(parts) < 2:
diff --git a/git_refs.py b/git_refs.py
index 3c266061..58c838a6 100644
--- a/git_refs.py
+++ b/git_refs.py
@@ -16,11 +16,12 @@
16import os 16import os
17from trace import Trace 17from trace import Trace
18 18
19HEAD = 'HEAD' 19HEAD = 'HEAD'
20R_HEADS = 'refs/heads/' 20R_CHANGES = 'refs/changes/'
21R_TAGS = 'refs/tags/' 21R_HEADS = 'refs/heads/'
22R_PUB = 'refs/published/' 22R_TAGS = 'refs/tags/'
23R_M = 'refs/remotes/m/' 23R_PUB = 'refs/published/'
24R_M = 'refs/remotes/m/'
24 25
25 26
26class GitRefs(object): 27class GitRefs(object):
diff --git a/subcmds/start.py b/subcmds/start.py
index 290b6897..c3ec303e 100644
--- a/subcmds/start.py
+++ b/subcmds/start.py
@@ -18,7 +18,7 @@ import os
18import sys 18import sys
19 19
20from command import Command 20from command import Command
21from git_config import IsId 21from git_config import IsImmutable
22from git_command import git 22from git_command import git
23import gitc_utils 23import gitc_utils
24from progress import Progress 24from progress import Progress
@@ -96,11 +96,11 @@ revision specified in the manifest.
96 project.Sync_LocalHalf(sync_buf) 96 project.Sync_LocalHalf(sync_buf)
97 project.revisionId = gitc_project.old_revision 97 project.revisionId = gitc_project.old_revision
98 98
99 # If the current revision is a specific SHA1 then we can't push back 99 # If the current revision is immutable, such as a SHA1, a tag or
100 # to it; so substitute with dest_branch if defined, or with manifest 100 # a change, then we can't push back to it. Substitute with
101 # default revision instead. 101 # dest_branch, if defined; or with manifest default revision instead.
102 branch_merge = '' 102 branch_merge = ''
103 if IsId(project.revisionExpr): 103 if IsImmutable(project.revisionExpr):
104 if project.dest_branch: 104 if project.dest_branch:
105 branch_merge = project.dest_branch 105 branch_merge = project.dest_branch
106 else: 106 else: