mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	Added some more machinery -- still not finished
This commit is contained in:
		
							parent
							
								
									8bcd301cc6
								
							
						
					
					
						commit
						ae21ced5da
					
				
					 1 changed files with 89 additions and 13 deletions
				
			
		| 
						 | 
					@ -12,16 +12,64 @@ from cmdfw import CommandFrameWork
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MyFile(File):
 | 
					class MyFile(File):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def update(self):
 | 
						def action(self):
 | 
				
			||||||
		print self.file, '...'
 | 
							"""Return a code indicating the update status of this file.
 | 
				
			||||||
		if self.lsum == self.esum == self.rsum:
 | 
					 | 
				
			||||||
			print '=', self.file
 | 
					 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		if self.lsum and not self.erev and not self.rrev:
 | 
					 | 
				
			||||||
			print '?', self.file
 | 
					 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		print 'X', self.file
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							The possible return values are:
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							'=' -- everything's fine
 | 
				
			||||||
 | 
							'0' -- file doesn't exist anywhere
 | 
				
			||||||
 | 
							'?' -- exists locally only
 | 
				
			||||||
 | 
							'A' -- new locally
 | 
				
			||||||
 | 
							'R' -- deleted locally
 | 
				
			||||||
 | 
							'U' -- changed remotely, no changes locally
 | 
				
			||||||
 | 
							'M' -- changed locally, no changes remotely
 | 
				
			||||||
 | 
							'C' -- conflict: changed locally as well as remotely
 | 
				
			||||||
 | 
							       (includes cases where the file has been added
 | 
				
			||||||
 | 
							       or removed locally and remotely)
 | 
				
			||||||
 | 
							"""
 | 
				
			||||||
 | 
							if not self.eseen:
 | 
				
			||||||
 | 
								pass
 | 
				
			||||||
 | 
							return '?'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						def update(self):
 | 
				
			||||||
 | 
							code = self.action()
 | 
				
			||||||
 | 
							print code, self.file
 | 
				
			||||||
 | 
							if code == 'U':
 | 
				
			||||||
 | 
								self.get()
 | 
				
			||||||
 | 
							elif code == 'C':
 | 
				
			||||||
 | 
								print "%s: conflict resolution not yet implemented" % \
 | 
				
			||||||
 | 
								      self.file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						def commit(self, message = ""):
 | 
				
			||||||
 | 
							code = self.action()
 | 
				
			||||||
 | 
							if code in ('A', 'M'):
 | 
				
			||||||
 | 
								self.put(message)
 | 
				
			||||||
 | 
							elif code == 'R':
 | 
				
			||||||
 | 
								print "%s: committing removes not yet implemented" % \
 | 
				
			||||||
 | 
								      self.file
 | 
				
			||||||
 | 
							elif code == 'C':
 | 
				
			||||||
 | 
								print "%s: conflict resolution not yet implemented" % \
 | 
				
			||||||
 | 
								      self.file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						def commitcheck(self):
 | 
				
			||||||
 | 
							return self.action() != 'C'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						def put(self, message = ""):
 | 
				
			||||||
 | 
							print "%s: put not yet implemented" % self.file
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						def get(self):
 | 
				
			||||||
 | 
							data = self.proxy.get(self.file)
 | 
				
			||||||
 | 
							f = open(self.file, 'w')
 | 
				
			||||||
 | 
							f.write(data)
 | 
				
			||||||
 | 
							f.close()
 | 
				
			||||||
 | 
							self.eseen = 1
 | 
				
			||||||
 | 
							self.esum = self.rsum
 | 
				
			||||||
 | 
							self.emtime, self.ectime = os.stat(self.file)[-2:]
 | 
				
			||||||
 | 
							self.erev = self.rrev
 | 
				
			||||||
 | 
							self.enew = 0
 | 
				
			||||||
 | 
							self.edeleted = 0
 | 
				
			||||||
 | 
							# XXX anything else?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RCVS(CVS):
 | 
					class RCVS(CVS):
 | 
				
			||||||
| 
						 | 
					@ -38,6 +86,18 @@ class RCVS(CVS):
 | 
				
			||||||
				return e.eseen or e.rseen
 | 
									return e.eseen or e.rseen
 | 
				
			||||||
			files[:] = filter(ok, self.entries.keys())
 | 
								files[:] = filter(ok, self.entries.keys())
 | 
				
			||||||
			files.sort()
 | 
								files.sort()
 | 
				
			||||||
 | 
								if not files:
 | 
				
			||||||
 | 
									print "no files to be processed"
 | 
				
			||||||
 | 
									return 1
 | 
				
			||||||
 | 
								else:
 | 
				
			||||||
 | 
									return None
 | 
				
			||||||
 | 
							else:
 | 
				
			||||||
 | 
								sts = None
 | 
				
			||||||
 | 
								for file in files:
 | 
				
			||||||
 | 
									if not self.entries.has_key(file):
 | 
				
			||||||
 | 
										print "%s: nothing known" % file
 | 
				
			||||||
 | 
										sts = 1
 | 
				
			||||||
 | 
								return sts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class rcvs(CommandFrameWork):
 | 
					class rcvs(CommandFrameWork):
 | 
				
			||||||
| 
						 | 
					@ -64,19 +124,35 @@ class rcvs(CommandFrameWork):
 | 
				
			||||||
		self.cvs.getremotefiles(self.proxy)
 | 
							self.cvs.getremotefiles(self.proxy)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def default(self):
 | 
						def default(self):
 | 
				
			||||||
 | 
							files = []
 | 
				
			||||||
 | 
							if self.cvs.checkfiles(files):
 | 
				
			||||||
 | 
								return 1
 | 
				
			||||||
		self.cvs.report()
 | 
							self.cvs.report()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def do_update(self, opts, files):
 | 
						def do_update(self, opts, files):
 | 
				
			||||||
		self.cvs.checkfiles(files)
 | 
							"""update [file] ..."""
 | 
				
			||||||
		if not files:
 | 
							if self.cvs.checkfiles(files):
 | 
				
			||||||
			print "no files"
 | 
								return 1
 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		for file in files:
 | 
							for file in files:
 | 
				
			||||||
			if not self.cvs.entries.has_key(file):
 | 
								if not self.cvs.entries.has_key(file):
 | 
				
			||||||
				print "%s: not found" % file
 | 
									print "%s: not found" % file
 | 
				
			||||||
			else:
 | 
								else:
 | 
				
			||||||
				self.cvs.entries[file].update()
 | 
									self.cvs.entries[file].update()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						def do_commit(self, opts, files):
 | 
				
			||||||
 | 
							"""commit [file] ..."""
 | 
				
			||||||
 | 
							if self.cvs.checkfiles(files):
 | 
				
			||||||
 | 
								return 1
 | 
				
			||||||
 | 
							sts = 0
 | 
				
			||||||
 | 
							for file in files:
 | 
				
			||||||
 | 
								if not self.entries[file].commitcheck():
 | 
				
			||||||
 | 
									sts = 1
 | 
				
			||||||
 | 
							if sts:
 | 
				
			||||||
 | 
								return sts
 | 
				
			||||||
 | 
							message = raw_input("One-liner: ")
 | 
				
			||||||
 | 
							for file in files:
 | 
				
			||||||
 | 
								self.entries[file].commit(message)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
	rcvs().run()
 | 
						rcvs().run()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue