@matheusbsbs / matheus-bagliano / commits / 0c66a78393
Fork 0

Make rollback work with locally imported branches

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

Simon Hausmann committed May 23, 2007 at 20:07 UTC 0c66a783936d5cd7b1f28400c6b192c37690304a
1 file changed +14 -4
contrib/fast-import/git-p4
+14 -4
@@ -136,18 +136,28 @@ class P4RollBack(Command):
136 def __init__(self):
137 Command.__init__(self)
138 self.options = [
139 - optparse.make_option("--verbose", dest="verbose", action="store_true")
139 + optparse.make_option("--verbose", dest="verbose", action="store_true"),
140 + optparse.make_option("--local", dest="rollbackLocalBranches", action="store_true")
141 ]
142 self.description = "A tool to debug the multi-branch import. Don't use :)"
143 self.verbose = False
144 + self.rollbackLocalBranches = False
145
146 def run(self, args):
147 if len(args) != 1:
148 return False
149 maxChange = int(args[0])
148 - for line in mypopen("git rev-parse --symbolic --remotes").readlines():
149 - if line.startswith("p4/") and line != "p4/HEAD\n":
150 - ref = "refs/remotes/" + line[:-1]
150 +
151 + if self.rollbackLocalBranches:
152 + refPrefix = "refs/heads/"
153 + lines = mypopen("git rev-parse --symbolic --branches").readlines()
154 + else:
155 + refPrefix = "refs/remotes/"
156 + lines = mypopen("git rev-parse --symbolic --remotes").readlines()
157 +
158 + for line in lines:
159 + if self.rollbackLocalBranches or (line.startswith("p4/") and line != "p4/HEAD\n"):
160 + ref = refPrefix + line[:-1]
161 log = extractLogMessageFromGitCommit(ref)
162 depotPath, change = extractDepotPathAndChangeFromGitLog(log)
163 changed = False