diff options
author | Simon Hausmann <simon@lst.de> | 2007-05-20 10:55:54 +0200 |
---|---|---|
committer | Simon Hausmann <simon@lst.de> | 2007-05-20 10:55:54 +0200 |
commit | b607e71efdd23cd676645b5d7bf49d985834fab8 (patch) | |
tree | 942cb7cdbaf3a396378290980045dfae7114fbae /contrib | |
parent | 9bda3a8556681c90309ec34e2ee5ae50306b61a6 (diff) | |
download | git-b607e71efdd23cd676645b5d7bf49d985834fab8.tar.gz |
Cache the output of "p4 users" for faster syncs on high latency links.
Signed-off-by: Simon Hausmann <simon@lst.de>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/fast-import/git-p4 | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4 index f76d198d64..e5e7c6be12 100755 --- a/contrib/fast-import/git-p4 +++ b/contrib/fast-import/git-p4 @@ -501,6 +501,8 @@ class P4Sync(Command): # gitStream.write("mark :%s\n" % details["change"]) self.committedChanges.add(int(details["change"])) committer = "" + if author not in self.users: + self.getUserMapFromPerforceServer() if author in self.users: committer = "%s %s %s" % (self.users[author], epoch, self.tz) else: @@ -591,7 +593,7 @@ class P4Sync(Command): if not self.silent: print "Tag %s does not match with change %s: file count is different." % (labelDetails["label"], change) - def getUserMap(self): + def getUserMapFromPerforceServer(self): self.users = {} for output in p4CmdList("users"): @@ -599,6 +601,23 @@ class P4Sync(Command): continue self.users[output["User"]] = output["FullName"] + " <" + output["Email"] + ">" + cache = open(gitdir + "/p4-usercache.txt", "wb") + for user in self.users.keys(): + cache.write("%s\t%s\n" % (user, self.users[user])) + cache.close(); + + def loadUserMapFromCache(self): + self.users = {} + try: + cache = open(gitdir + "/p4-usercache.txt", "rb") + lines = cache.readlines() + cache.close() + for line in lines: + entry = line[:-1].split("\t") + self.users[entry[0]] = entry[1] + except IOError: + self.getUserMapFromPerforceServer() + def getLabels(self): self.labels = {} @@ -772,7 +791,7 @@ class P4Sync(Command): if not self.depotPath.endswith("/"): self.depotPath += "/" - self.getUserMap() + self.loadUserMapFromCache() self.labels = {} if self.detectLabels: self.getLabels(); |