Show More
@@ -150,7 +150,33 b' elif cmd == "commit" or cmd == "checkin"' | |||||
150 | repo.commit(repo.current, args) |
|
150 | repo.commit(repo.current, args) | |
151 | else: |
|
151 | else: | |
152 | repo.commit(repo.current) |
|
152 | repo.commit(repo.current) | |
153 |
|
153 | elif cmd == "rawcommit": | ||
|
154 | "raw commit interface" | |||
|
155 | rc = {} | |||
|
156 | opts = [('p', 'parent', [], 'parent'), | |||
|
157 | ('d', 'date', "", 'data'), | |||
|
158 | ('u', 'user', "", 'user'), | |||
|
159 | ('F', 'files', "", 'file list'), | |||
|
160 | ('t', 'text', "", 'commit text'), | |||
|
161 | ('l', 'logfile', "", 'commit text file') | |||
|
162 | ] | |||
|
163 | args = fancyopts.fancyopts(args, opts, rc, | |||
|
164 | "hg rawcommit [options] files") | |||
|
165 | text = rc['text'] | |||
|
166 | if not text and rc['logfile']: | |||
|
167 | try: text = open(rc['logfile']).read() | |||
|
168 | except IOError: pass | |||
|
169 | if not text and not rc['logfile']: | |||
|
170 | print "missing commit text" | |||
|
171 | sys.exit(0) | |||
|
172 | if rc['files']: | |||
|
173 | files = open(rc['files']).read().splitlines() | |||
|
174 | else: | |||
|
175 | files = args | |||
|
176 | ||||
|
177 | repo.rawcommit(files, text, rc['user'], rc['date'], *rc['parent']) | |||
|
178 | ||||
|
179 | ||||
154 | elif cmd == "import" or cmd == "patch": |
|
180 | elif cmd == "import" or cmd == "patch": | |
155 | try: |
|
181 | try: | |
156 | import psyco |
|
182 | import psyco |
@@ -137,11 +137,13 b' class changelog(revlog):' | |||||
137 | def read(self, node): |
|
137 | def read(self, node): | |
138 | return self.extract(self.revision(node)) |
|
138 | return self.extract(self.revision(node)) | |
139 |
|
139 | |||
140 |
def add(self, manifest, list, desc, transaction, p1=None, p2=None |
|
140 | def add(self, manifest, list, desc, transaction, p1=None, p2=None, | |
141 | user = (os.environ.get("HGUSER") or |
|
141 | user=None, date=None): | |
|
142 | user = (user or | |||
|
143 | os.environ.get("HGUSER") or | |||
142 | os.environ.get("EMAIL") or |
|
144 | os.environ.get("EMAIL") or | |
143 | os.environ.get("LOGNAME", "unknown") + '@' + socket.getfqdn()) |
|
145 | os.environ.get("LOGNAME", "unknown") + '@' + socket.getfqdn()) | |
144 | date = "%d %d" % (time.time(), time.timezone) |
|
146 | date = date or "%d %d" % (time.time(), time.timezone) | |
145 | list.sort() |
|
147 | list.sort() | |
146 | l = [hex(manifest), user, date] + list + ["", desc] |
|
148 | l = [hex(manifest), user, date] + list + ["", desc] | |
147 | text = "\n".join(l) |
|
149 | text = "\n".join(l) | |
@@ -344,6 +346,30 b' class localrepository:' | |||||
344 | return lock.lock(self.join("lock"), wait) |
|
346 | return lock.lock(self.join("lock"), wait) | |
345 | raise inst |
|
347 | raise inst | |
346 |
|
348 | |||
|
349 | def rawcommit(self, files, text, user, date, p1=None, p2=None): | |||
|
350 | p1 = p1 or self.current or nullid | |||
|
351 | pchange = self.changelog.read(p1) | |||
|
352 | pmmap = self.manifest.read(pchange[0]) | |||
|
353 | tr = self.transaction() | |||
|
354 | mmap = {} | |||
|
355 | linkrev = self.changelog.count() | |||
|
356 | for f in files: | |||
|
357 | try: | |||
|
358 | t = file(f).read() | |||
|
359 | except IOError: | |||
|
360 | self.ui.warn("Read file %s error, skipped\n" % f) | |||
|
361 | continue | |||
|
362 | r = self.file(f) | |||
|
363 | prev = pmmap.get(f, nullid) | |||
|
364 | mmap[f] = r.add(t, tr, linkrev, prev) | |||
|
365 | ||||
|
366 | mnode = self.manifest.add(mmap, tr, linkrev, pchange[0]) | |||
|
367 | n = self.changelog.add(mnode, files, text, tr, p1, p2, user ,date, ) | |||
|
368 | tr.close() | |||
|
369 | self.setcurrent(n) | |||
|
370 | self.dircache.clear() | |||
|
371 | self.dircache.update(mmap) | |||
|
372 | ||||
347 | def commit(self, parent, update = None, text = ""): |
|
373 | def commit(self, parent, update = None, text = ""): | |
348 | self.lock() |
|
374 | self.lock() | |
349 | try: |
|
375 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now