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: from git_command import GitCommand from git_command import ssh_sock from git_command import terminate_ssh_clients +from git_refs import R_CHANGES, R_HEADS, R_TAGS -R_HEADS = 'refs/heads/' -R_TAGS = 'refs/tags/' ID_RE = re.compile(r'^[0-9a-f]{40}$') REVIEW_CACHE = dict() +def IsChange(rev): + return rev.startswith(R_CHANGES) + def IsId(rev): return ID_RE.match(rev) +def IsTag(rev): + return rev.startswith(R_TAGS) + +def IsImmutable(rev): + return IsChange(rev) or IsId(rev) or IsTag(rev) + def _key(name): parts = name.split('.') 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 @@ import os from trace import Trace -HEAD = 'HEAD' -R_HEADS = 'refs/heads/' -R_TAGS = 'refs/tags/' -R_PUB = 'refs/published/' -R_M = 'refs/remotes/m/' +HEAD = 'HEAD' +R_CHANGES = 'refs/changes/' +R_HEADS = 'refs/heads/' +R_TAGS = 'refs/tags/' +R_PUB = 'refs/published/' +R_M = 'refs/remotes/m/' class 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 import sys from command import Command -from git_config import IsId +from git_config import IsImmutable from git_command import git import gitc_utils from progress import Progress @@ -96,11 +96,11 @@ revision specified in the manifest. project.Sync_LocalHalf(sync_buf) project.revisionId = gitc_project.old_revision - # If the current revision is a specific SHA1 then we can't push back - # to it; so substitute with dest_branch if defined, or with manifest - # default revision instead. + # If the current revision is immutable, such as a SHA1, a tag or + # a change, then we can't push back to it. Substitute with + # dest_branch, if defined; or with manifest default revision instead. branch_merge = '' - if IsId(project.revisionExpr): + if IsImmutable(project.revisionExpr): if project.dest_branch: branch_merge = project.dest_branch else: