Added a rollback command for debugging. It sets back the heads of the p4 branches to the specified p4 change number or earlier.
Signed-off-by: Simon Hausmann <shausman@trolltech.com>maint
parent
7944f1425c
commit
5834684d51
|
|
@ -7,10 +7,7 @@
|
||||||
# 2007 Trolltech ASA
|
# 2007 Trolltech ASA
|
||||||
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
|
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
|
||||||
#
|
#
|
||||||
# TODO: * implement git-p4 rollback <perforce change number> for debugging
|
# TODO: * Consider making --with-origin the default, assuming that the git
|
||||||
# to roll back all p4 remote branches to a commit older or equal to
|
|
||||||
# the specified change.
|
|
||||||
# * Consider making --with-origin the default, assuming that the git
|
|
||||||
# protocol is always more efficient. (needs manual testing first :)
|
# protocol is always more efficient. (needs manual testing first :)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
@ -135,6 +132,35 @@ class P4Debug(Command):
|
||||||
print output
|
print output
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
class P4RollBack(Command):
|
||||||
|
def __init__(self):
|
||||||
|
Command.__init__(self)
|
||||||
|
self.options = [
|
||||||
|
]
|
||||||
|
self.description = "A tool to debug the multi-branch import. Don't use :)"
|
||||||
|
|
||||||
|
def run(self, args):
|
||||||
|
if len(args) != 1:
|
||||||
|
return False
|
||||||
|
maxChange = int(args[0])
|
||||||
|
for line in mypopen("git rev-parse --symbolic --remotes").readlines():
|
||||||
|
if line.startswith("p4/") and line != "p4/HEAD\n":
|
||||||
|
ref = "refs/remotes/" + line[:-1]
|
||||||
|
log = extractLogMessageFromGitCommit(ref)
|
||||||
|
depotPath, change = extractDepotPathAndChangeFromGitLog(log)
|
||||||
|
changed = False
|
||||||
|
while len(change) > 0 and int(change) > maxChange:
|
||||||
|
changed = True
|
||||||
|
print "%s is at %s ; rewinding towards %s" % (ref, change, maxChange)
|
||||||
|
system("git update-ref %s \"%s^\"" % (ref, ref))
|
||||||
|
log = extractLogMessageFromGitCommit(ref)
|
||||||
|
depotPath, change = extractDepotPathAndChangeFromGitLog(log)
|
||||||
|
|
||||||
|
if changed:
|
||||||
|
print "%s is at %s" % (ref, change)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
class P4Submit(Command):
|
class P4Submit(Command):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Command.__init__(self)
|
Command.__init__(self)
|
||||||
|
|
@ -1109,7 +1135,8 @@ commands = {
|
||||||
"submit" : P4Submit(),
|
"submit" : P4Submit(),
|
||||||
"sync" : P4Sync(),
|
"sync" : P4Sync(),
|
||||||
"rebase" : P4Rebase(),
|
"rebase" : P4Rebase(),
|
||||||
"clone" : P4Clone()
|
"clone" : P4Clone(),
|
||||||
|
"rollback" : P4RollBack()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(sys.argv[1:]) == 0:
|
if len(sys.argv[1:]) == 0:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue