Show More
@@ -0,0 +1,18 b'' | |||||
|
1 | #!/bin/bash | |||
|
2 | ||||
|
3 | set -x | |||
|
4 | hg init | |||
|
5 | echo a > a | |||
|
6 | hg add a | |||
|
7 | hg commit -t "1" -u test -d "0 0" | |||
|
8 | hg status | |||
|
9 | cp a b | |||
|
10 | hg copy a b | |||
|
11 | hg status | |||
|
12 | hg -d commit -t "2" -u test -d "0 0" | |||
|
13 | hg history | |||
|
14 | hg log a | |||
|
15 | hexdump -C .hg/data/b.d | |||
|
16 | hg cat b | md5sum | |||
|
17 | hg cat a | md5sum | |||
|
18 | hg verify |
@@ -0,0 +1,51 b'' | |||||
|
1 | + hg init | |||
|
2 | + echo a | |||
|
3 | + hg add a | |||
|
4 | + hg commit -t 1 -u test -d '0 0' | |||
|
5 | + hg status | |||
|
6 | ? .out | |||
|
7 | + cp a b | |||
|
8 | + hg copy a b | |||
|
9 | + hg status | |||
|
10 | A b | |||
|
11 | ? .out | |||
|
12 | + hg -d commit -t 2 -u test -d '0 0' | |||
|
13 | b | |||
|
14 | b: copy a:b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 | |||
|
15 | + hg history | |||
|
16 | changeset: 1:3b5b84850bbed12e8ff8c1b87b32dc93c59ae6d8 | |||
|
17 | user: test | |||
|
18 | date: Wed Dec 31 16:00:00 1969 | |||
|
19 | summary: 2 | |||
|
20 | ||||
|
21 | changeset: 0:c19d34741b0a4ced8e4ba74bb834597d5193851e | |||
|
22 | user: test | |||
|
23 | date: Wed Dec 31 16:00:00 1969 | |||
|
24 | summary: 1 | |||
|
25 | ||||
|
26 | + hg log a | |||
|
27 | revision: 0:b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 | |||
|
28 | changeset: 0:c19d34741b0a4ced8e4ba74bb834597d5193851e | |||
|
29 | user: test | |||
|
30 | date: Wed Dec 31 16:00:00 1969 | |||
|
31 | summary: 1 | |||
|
32 | ||||
|
33 | + hexdump -C .hg/data/b.d | |||
|
34 | 00000000 75 01 0a 63 6f 70 79 72 65 76 3a 20 62 37 38 39 |u..copyrev: b789| | |||
|
35 | 00000010 66 64 64 39 36 64 63 32 66 33 62 64 32 32 39 63 |fdd96dc2f3bd229c| | |||
|
36 | 00000020 31 64 64 38 65 65 64 66 30 66 63 36 30 65 32 62 |1dd8eedf0fc60e2b| | |||
|
37 | 00000030 36 38 65 33 0a 63 6f 70 79 3a 20 61 0a 01 0a 61 |68e3.copy: a...a| | |||
|
38 | 00000040 0a |.| | |||
|
39 | 00000041 | |||
|
40 | + hg cat b | |||
|
41 | + md5sum | |||
|
42 | 60b725f10c9c85c70d97880dfe8191b3 - | |||
|
43 | + hg cat a | |||
|
44 | + md5sum | |||
|
45 | 60b725f10c9c85c70d97880dfe8191b3 - | |||
|
46 | + hg verify | |||
|
47 | checking changesets | |||
|
48 | checking manifests | |||
|
49 | crosschecking files in changesets and manifests | |||
|
50 | checking files | |||
|
51 | 2 files, 2 changesets, 2 total revisions |
@@ -250,6 +250,10 b' def commit(ui, repo, *files, **opts):' | |||||
250 | addremove(ui, repo, *files) |
|
250 | addremove(ui, repo, *files) | |
251 | repo.commit(relpath(repo, files), text, opts['user'], opts['date']) |
|
251 | repo.commit(relpath(repo, files), text, opts['user'], opts['date']) | |
252 |
|
252 | |||
|
253 | def copy(ui, repo, source, dest): | |||
|
254 | """mark a file as copied or renamed for the next commit""" | |||
|
255 | return repo.copy(*relpath(repo, (source, dest))) | |||
|
256 | ||||
253 | def debugaddchangegroup(ui, repo): |
|
257 | def debugaddchangegroup(ui, repo): | |
254 | data = sys.stdin.read() |
|
258 | data = sys.stdin.read() | |
255 | repo.addchangegroup(data) |
|
259 | repo.addchangegroup(data) | |
@@ -608,6 +612,7 b' table = {' | |||||
608 | ('d', 'date', "", 'data'), |
|
612 | ('d', 'date', "", 'data'), | |
609 | ('u', 'user', "", 'user')], |
|
613 | ('u', 'user', "", 'user')], | |
610 | 'hg commit [files]'), |
|
614 | 'hg commit [files]'), | |
|
615 | "copy": (copy, [], 'hg copy <source> <dest>'), | |||
611 | "debugaddchangegroup": (debugaddchangegroup, [], 'debugaddchangegroup'), |
|
616 | "debugaddchangegroup": (debugaddchangegroup, [], 'debugaddchangegroup'), | |
612 | "debugchangegroup": (debugchangegroup, [], 'debugchangegroup [roots]'), |
|
617 | "debugchangegroup": (debugchangegroup, [], 'debugchangegroup [roots]'), | |
613 | "debugindex": (debugindex, [], 'debugindex <file>'), |
|
618 | "debugindex": (debugindex, [], 'debugindex <file>'), |
@@ -204,6 +204,7 b' class dirstate:' | |||||
204 | self.ui = ui |
|
204 | self.ui = ui | |
205 | self.map = None |
|
205 | self.map = None | |
206 | self.pl = None |
|
206 | self.pl = None | |
|
207 | self.copies = {} | |||
207 |
|
208 | |||
208 | def __del__(self): |
|
209 | def __del__(self): | |
209 | if self.dirty: |
|
210 | if self.dirty: | |
@@ -253,8 +254,19 b' class dirstate:' | |||||
253 | l = e[4] |
|
254 | l = e[4] | |
254 | pos += 17 |
|
255 | pos += 17 | |
255 | f = st[pos:pos + l] |
|
256 | f = st[pos:pos + l] | |
|
257 | if '\0' in f: | |||
|
258 | f, c = f.split('\0') | |||
|
259 | self.copies[f] = c | |||
256 | self.map[f] = e[:4] |
|
260 | self.map[f] = e[:4] | |
257 | pos += l |
|
261 | pos += l | |
|
262 | ||||
|
263 | def copy(self, source, dest): | |||
|
264 | self.read() | |||
|
265 | self.dirty = 1 | |||
|
266 | self.copies[dest] = source | |||
|
267 | ||||
|
268 | def copied(self, file): | |||
|
269 | return self.copies.get(file, None) | |||
258 |
|
270 | |||
259 | def update(self, files, state): |
|
271 | def update(self, files, state): | |
260 | ''' current states: |
|
272 | ''' current states: | |
@@ -292,11 +304,14 b' class dirstate:' | |||||
292 | st = self.opener("dirstate", "w") |
|
304 | st = self.opener("dirstate", "w") | |
293 | st.write("".join(self.pl)) |
|
305 | st.write("".join(self.pl)) | |
294 | for f, e in self.map.items(): |
|
306 | for f, e in self.map.items(): | |
|
307 | c = self.copied(f) | |||
|
308 | if c: | |||
|
309 | f = f + "\0" + c | |||
295 | e = struct.pack(">cllll", e[0], e[1], e[2], e[3], len(f)) |
|
310 | e = struct.pack(">cllll", e[0], e[1], e[2], e[3], len(f)) | |
296 | st.write(e + f) |
|
311 | st.write(e + f) | |
297 | self.dirty = 0 |
|
312 | self.dirty = 0 | |
298 |
|
313 | |||
299 |
def |
|
314 | def dup(self): | |
300 | self.read() |
|
315 | self.read() | |
301 | return self.map.copy() |
|
316 | return self.map.copy() | |
302 |
|
317 | |||
@@ -556,10 +571,17 b' class localrepository:' | |||||
556 | self.warn("trouble committing %s!\n" % f) |
|
571 | self.warn("trouble committing %s!\n" % f) | |
557 | raise |
|
572 | raise | |
558 |
|
573 | |||
|
574 | meta = {} | |||
|
575 | cp = self.dirstate.copied(f) | |||
|
576 | if cp: | |||
|
577 | meta["copy"] = cp | |||
|
578 | meta["copyrev"] = hex(m1.get(cp, m2.get(cp, nullid))) | |||
|
579 | self.ui.debug(" %s: copy %s:%s\n" % (f, cp, meta["copyrev"])) | |||
|
580 | ||||
559 | r = self.file(f) |
|
581 | r = self.file(f) | |
560 | fp1 = m1.get(f, nullid) |
|
582 | fp1 = m1.get(f, nullid) | |
561 | fp2 = m2.get(f, nullid) |
|
583 | fp2 = m2.get(f, nullid) | |
562 |
new[f] = r.add(t, |
|
584 | new[f] = r.add(t, meta, tr, linkrev, fp1, fp2) | |
563 |
|
585 | |||
564 | # update manifest |
|
586 | # update manifest | |
565 | m1.update(new) |
|
587 | m1.update(new) | |
@@ -600,7 +622,7 b' class localrepository:' | |||||
600 | changeset = self.dirstate.parents()[0] |
|
622 | changeset = self.dirstate.parents()[0] | |
601 | change = self.changelog.read(changeset) |
|
623 | change = self.changelog.read(changeset) | |
602 | mf = self.manifest.read(change[0]) |
|
624 | mf = self.manifest.read(change[0]) | |
603 |
dc = self.dirstate. |
|
625 | dc = self.dirstate.dup() | |
604 |
|
626 | |||
605 | def fcmp(fn): |
|
627 | def fcmp(fn): | |
606 | t1 = self.wfile(fn).read() |
|
628 | t1 = self.wfile(fn).read() | |
@@ -689,6 +711,15 b' class localrepository:' | |||||
689 | else: |
|
711 | else: | |
690 | self.dirstate.update([f], "r") |
|
712 | self.dirstate.update([f], "r") | |
691 |
|
713 | |||
|
714 | def copy(self, source, dest): | |||
|
715 | p = self.wjoin(dest) | |||
|
716 | if not os.path.isfile(dest): | |||
|
717 | self.ui.warn("%s does not exist!\n" % dest) | |||
|
718 | else: | |||
|
719 | if self.dirstate.state(dest) == '?': | |||
|
720 | self.dirstate.update([dest], "a") | |||
|
721 | self.dirstate.copy(source, dest) | |||
|
722 | ||||
692 | def heads(self): |
|
723 | def heads(self): | |
693 | return self.changelog.heads() |
|
724 | return self.changelog.heads() | |
694 |
|
725 |
General Comments 0
You need to be logged in to leave comments.
Login now