@matheusbsbs / matheus-bagliano / commits / 52102d4784
Fork 0

Fixes for rollback, delete branches that did not exist at the specified p4 change

Signed-off-by: Simon Hausmann <shausman@trolltech.com>

Simon Hausmann committed May 21, 2007 at 23:44 UTC 52102d4784a5f16fd84eaf98b61f714460b68693
1 file changed +11 -2
contrib/fast-import/git-p4
+11 -2
@@ -136,8 +136,10 @@ class P4RollBack(Command):
136 def __init__(self):
137 Command.__init__(self)
138 self.options = [
139 + optparse.make_option("--verbose", dest="verbose", action="store_true")
140 ]
141 self.description = "A tool to debug the multi-branch import. Don't use :)"
142 + self.verbose = False
143
144 def run(self, args):
145 if len(args) != 1:
@@ -149,15 +151,22 @@ class P4RollBack(Command):
151 log = extractLogMessageFromGitCommit(ref)
152 depotPath, change = extractDepotPathAndChangeFromGitLog(log)
153 changed = False
154 +
155 + if len(p4Cmd("changes -m 1 %s...@%s" % (depotPath, maxChange))) == 0:
156 + print "Branch %s did not exist at change %s, deleting." % (ref, maxChange)
157 + system("git update-ref -d %s `git rev-parse %s`" % (ref, ref))
158 + continue
159 +
160 while len(change) > 0 and int(change) > maxChange:
161 changed = True
154 - print "%s is at %s ; rewinding towards %s" % (ref, change, maxChange)
162 + if self.verbose:
163 + print "%s is at %s ; rewinding towards %s" % (ref, change, maxChange)
164 system("git update-ref %s \"%s^\"" % (ref, ref))
165 log = extractLogMessageFromGitCommit(ref)
166 depotPath, change = extractDepotPathAndChangeFromGitLog(log)
167
168 if changed:
160 - print "%s is at %s" % (ref, change)
169 + print "%s rewound to %s" % (ref, change)
170
171 return True
172