Skip to content

Commit

Permalink
Fixes for rollback, delete branches that did not exist at the specifi…
Browse files Browse the repository at this point in the history
…ed p4 change

Signed-off-by: Simon Hausmann <shausman@trolltech.com>
  • Loading branch information
Simon Hausmann committed May 21, 2007
1 parent af8da89 commit 52102d4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions contrib/fast-import/git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ class P4RollBack(Command):
def __init__(self):
Command.__init__(self)
self.options = [
optparse.make_option("--verbose", dest="verbose", action="store_true")
]
self.description = "A tool to debug the multi-branch import. Don't use :)"
self.verbose = False

def run(self, args):
if len(args) != 1:
Expand All @@ -149,15 +151,22 @@ class P4RollBack(Command):
log = extractLogMessageFromGitCommit(ref)
depotPath, change = extractDepotPathAndChangeFromGitLog(log)
changed = False

if len(p4Cmd("changes -m 1 %s...@%s" % (depotPath, maxChange))) == 0:
print "Branch %s did not exist at change %s, deleting." % (ref, maxChange)
system("git update-ref -d %s `git rev-parse %s`" % (ref, ref))
continue

while len(change) > 0 and int(change) > maxChange:
changed = True
print "%s is at %s ; rewinding towards %s" % (ref, change, maxChange)
if self.verbose:
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)
print "%s rewound to %s" % (ref, change)

return True

Expand Down

0 comments on commit 52102d4

Please sign in to comment.