Add 'rebase="false"' attribute to the <project/> XML.

This new attribute can prevent 'repo sync' from automatically rebasing.

I hit a situation in where one of the git repositories I was tracking
was actually an external repository that I wanted to pull commits
into and merge myself. (NOT rebase, since that would lose the merge
history.) In this case, I'm not using 'repo upload', I'm manually
managing the merges to and from this repository.

Everything was going great until I typed 'repo sync' and it rebased
my manually-merged tree. Hence the option to skip it.

Change-Id: I965e0dd1acb87f4a56752ebedc7e2de1c502dbf8
This commit is contained in:
Mike Pontillo 2012-02-28 11:53:24 -08:00 committed by Shawn O. Pearce
parent 43bda84362
commit d315382572
2 changed files with 13 additions and 3 deletions

View File

@ -498,6 +498,12 @@ class XmlManifest(object):
"project %s path cannot be absolute in %s" % \ "project %s path cannot be absolute in %s" % \
(name, self.manifestFile) (name, self.manifestFile)
rebase = node.getAttribute('rebase')
if not rebase:
rebase = True
else:
rebase = rebase.lower() in ("yes", "true", "1")
if self.IsMirror: if self.IsMirror:
relpath = None relpath = None
worktree = None worktree = None
@ -513,7 +519,8 @@ class XmlManifest(object):
worktree = worktree, worktree = worktree,
relpath = path, relpath = path,
revisionExpr = revisionExpr, revisionExpr = revisionExpr,
revisionId = None) revisionId = None,
rebase = rebase)
for n in node.childNodes: for n in node.childNodes:
if n.nodeName == 'copyfile': if n.nodeName == 'copyfile':

View File

@ -503,7 +503,8 @@ class Project(object):
worktree, worktree,
relpath, relpath,
revisionExpr, revisionExpr,
revisionId): revisionId,
rebase = True):
self.manifest = manifest self.manifest = manifest
self.name = name self.name = name
self.remote = remote self.remote = remote
@ -522,6 +523,8 @@ class Project(object):
else: else:
self.revisionId = revisionId self.revisionId = revisionId
self.rebase = rebase
self.snapshots = {} self.snapshots = {}
self.copyfiles = [] self.copyfiles = []
self.config = GitConfig.ForRepository( self.config = GitConfig.ForRepository(
@ -1096,7 +1099,7 @@ class Project(object):
branch.merge = self.revisionExpr branch.merge = self.revisionExpr
branch.Save() branch.Save()
if cnt_mine > 0: if cnt_mine > 0 and self.rebase:
def _dorebase(): def _dorebase():
self._Rebase(upstream = '%s^1' % last_mine, onto = revid) self._Rebase(upstream = '%s^1' % last_mine, onto = revid)
self._CopyFiles() self._CopyFiles()