Show More
@@ -66,9 +66,8 b' def diff(files = None, node1 = None, nod' | |||
|
66 | 66 | else: |
|
67 | 67 | date2 = time.asctime() |
|
68 | 68 | if not node1: |
|
69 |
node1 = repo. |
|
|
69 | node1 = repo.dirstate.parents()[0] | |
|
70 | 70 | (c, a, d, u) = repo.diffdir(repo.root, node1) |
|
71 | a = [] # ignore unknown files in repo, by popular request | |
|
72 | 71 | def read(f): return file(os.path.join(repo.root, f)).read() |
|
73 | 72 | |
|
74 | 73 | change = repo.changelog.read(node1) |
@@ -139,9 +138,9 b' elif cmd == "remove" or cmd == "rm" or c' | |||
|
139 | 138 | elif cmd == "commit" or cmd == "checkin" or cmd == "ci": |
|
140 | 139 | if 1: |
|
141 | 140 | if len(args) > 0: |
|
142 |
repo.commit( |
|
|
141 | repo.commit(args) | |
|
143 | 142 | else: |
|
144 |
repo.commit( |
|
|
143 | repo.commit() | |
|
145 | 144 | elif cmd == "rawcommit": |
|
146 | 145 | "raw commit interface" |
|
147 | 146 | rc = {} |
@@ -204,7 +203,7 b' elif cmd == "import" or cmd == "patch":' | |||
|
204 | 203 | if files: |
|
205 | 204 | if os.system("patch -p%d < %s %s" % (strip, pf, quiet)): |
|
206 | 205 | raise "patch failed!" |
|
207 |
repo.commit( |
|
|
206 | repo.commit(files, text) | |
|
208 | 207 | |
|
209 | 208 | elif cmd == "diff": |
|
210 | 209 | revs = [] |
@@ -102,7 +102,7 b' def annotate(u, repo, *args, **ops):' | |||
|
102 | 102 | ops['number'] = 1 |
|
103 | 103 | |
|
104 | 104 | args = relpath(repo, args) |
|
105 |
node = repo. |
|
|
105 | node = repo.dirstate.parents()[0] | |
|
106 | 106 | if ops['revision']: |
|
107 | 107 | node = repo.changelog.lookup(ops['revision']) |
|
108 | 108 | change = repo.changelog.read(node) |
@@ -142,6 +142,17 b' def heads(ui, repo):' | |||
|
142 | 142 | print "description:" |
|
143 | 143 | print changes[4] |
|
144 | 144 | |
|
145 | def parents(ui, repo, node = None): | |
|
146 | '''show the parents of the current working dir''' | |
|
147 | if node: | |
|
148 | p = repo.changelog.parents(repo.lookup(hg.bin(node))) | |
|
149 | else: | |
|
150 | p = repo.dirstate.parents() | |
|
151 | ||
|
152 | for n in p: | |
|
153 | if n != hg.nullid: | |
|
154 | ui.write("%d:%s\n" % (repo.changelog.rev(n), hg.hex(n))) | |
|
155 | ||
|
145 | 156 | def status(ui, repo): |
|
146 | 157 | '''show changed files in the working directory |
|
147 | 158 | |
@@ -172,6 +183,7 b' table = {' | |||
|
172 | 183 | ('n', 'number', None, 'show revision number'), |
|
173 | 184 | ('c', 'changeset', None, 'show changeset')], |
|
174 | 185 | 'hg annotate [-u] [-c] [-n] [-r id] [files]'), |
|
186 | "parents": (parents, [], 'hg parents [node]'), | |
|
175 | 187 | "status": (status, [], 'hg status'), |
|
176 | 188 | "undo": (undo, [], 'hg undo'), |
|
177 | 189 | } |
@@ -155,6 +155,7 b' class dirstate:' | |||
|
155 | 155 | self.dirty = 0 |
|
156 | 156 | self.ui = ui |
|
157 | 157 | self.map = None |
|
158 | self.pl = None | |
|
158 | 159 | |
|
159 | 160 | def __del__(self): |
|
160 | 161 | if self.dirty: |
@@ -171,6 +172,15 b' class dirstate:' | |||
|
171 | 172 | if not self.map: self.read() |
|
172 | 173 | return key in self.map |
|
173 | 174 | |
|
175 | def parents(self): | |
|
176 | if not self.pl: | |
|
177 | self.read() | |
|
178 | return self.pl | |
|
179 | ||
|
180 | def setparents(self, p1, p2 = nullid): | |
|
181 | self.dirty = 1 | |
|
182 | self.pl = p1, p2 | |
|
183 | ||
|
174 | 184 | def state(self, key): |
|
175 | 185 | try: |
|
176 | 186 | return self[key][0] |
@@ -181,11 +191,14 b' class dirstate:' | |||
|
181 | 191 | if self.map is not None: return self.map |
|
182 | 192 | |
|
183 | 193 | self.map = {} |
|
194 | self.pl = [nullid, nullid] | |
|
184 | 195 | try: |
|
185 | 196 | st = self.opener("dirstate").read() |
|
186 | 197 | except: return |
|
187 | 198 | |
|
188 | pos = 0 | |
|
199 | self.pl = [st[:20], st[20: 40]] | |
|
200 | ||
|
201 | pos = 40 | |
|
189 | 202 | while pos < len(st): |
|
190 | 203 | e = struct.unpack(">cllll", st[pos:pos+17]) |
|
191 | 204 | l = e[4] |
@@ -232,6 +245,7 b' class dirstate:' | |||
|
232 | 245 | |
|
233 | 246 | def write(self): |
|
234 | 247 | st = self.opener("dirstate", "w") |
|
248 | st.write("".join(self.pl)) | |
|
235 | 249 | for f, e in self.map.items(): |
|
236 | 250 | e = struct.pack(">cllll", e[0], e[1], e[2], e[3], len(f)) |
|
237 | 251 | st.write(e + f) |
@@ -297,15 +311,7 b' class localrepository:' | |||
|
297 | 311 | |
|
298 | 312 | if not self.remote: |
|
299 | 313 | self.dirstate = dirstate(self.opener, ui) |
|
300 | try: | |
|
301 | self.current = bin(self.opener("current").read()) | |
|
302 | except IOError: | |
|
303 | self.current = None | |
|
304 | 314 | |
|
305 | def setcurrent(self, node): | |
|
306 | self.current = node | |
|
307 | self.opener("current", "w").write(hex(node)) | |
|
308 | ||
|
309 | 315 | def ignore(self, f): |
|
310 | 316 | if self.ignorelist is None: |
|
311 | 317 | self.ignorelist = [] |
@@ -366,7 +372,7 b' class localrepository:' | |||
|
366 | 372 | node = self.changelog.tip() |
|
367 | 373 | f.sort() |
|
368 | 374 | |
|
369 |
self. |
|
|
375 | self.dirstate.setparents(node) | |
|
370 | 376 | self.dirstate.update(f, 'i') |
|
371 | 377 | |
|
372 | 378 | else: |
@@ -486,7 +492,7 b' class localrepository:' | |||
|
486 | 492 | os.makedirs(os.path.dirname(f)) |
|
487 | 493 | file(f, "w").write(t) |
|
488 | 494 | |
|
489 |
self. |
|
|
495 | self.dirstate.setparents(node) | |
|
490 | 496 | self.dirstate.clear() |
|
491 | 497 | self.dirstate.update([f for f,n in l], "n") |
|
492 | 498 |
General Comments 0
You need to be logged in to leave comments.
Login now