Show More
@@ -27,7 +27,7 b' class convert_mercurial(converter_sink):' | |||
|
27 | 27 | def putfile(self, f, e, data): |
|
28 | 28 | self.repo.wwrite(f, data, e) |
|
29 | 29 | if self.repo.dirstate.state(f) == '?': |
|
30 |
self.repo.dirstate. |
|
|
30 | self.repo.dirstate.add(f) | |
|
31 | 31 | |
|
32 | 32 | def copyfile(self, source, dest): |
|
33 | 33 | self.repo.copy(source, dest) |
@@ -501,8 +501,10 b' class queue:' | |||
|
501 | 501 | merged.append(f) |
|
502 | 502 | else: |
|
503 | 503 | removed.append(f) |
|
504 | repo.dirstate.update(repo.dirstate.filterfiles(removed), 'r') | |
|
505 | repo.dirstate.update(repo.dirstate.filterfiles(merged), 'm') | |
|
504 | for f in removed: | |
|
505 | repo.dirstate.remove(f) | |
|
506 | for f in merged: | |
|
507 | repo.dirstate.merge(f) | |
|
506 | 508 | p1, p2 = repo.dirstate.parents() |
|
507 | 509 | repo.dirstate.setparents(p1, merge) |
|
508 | 510 | files = patch.updatedir(self.ui, repo, files, wlock=wlock) |
@@ -868,7 +870,8 b' class queue:' | |||
|
868 | 870 | for f in r: |
|
869 | 871 | getfile(f, mmap[f]) |
|
870 | 872 | util.set_exec(repo.wjoin(f), mmap.execf(f)) |
|
871 | repo.dirstate.update(m + r, 'n') | |
|
873 | for f in m + r: | |
|
874 | repo.dirstate.normal(f) | |
|
872 | 875 | for f in a: |
|
873 | 876 | try: |
|
874 | 877 | os.unlink(repo.wjoin(f)) |
@@ -877,8 +880,7 b' class queue:' | |||
|
877 | 880 | raise |
|
878 | 881 | try: os.removedirs(os.path.dirname(repo.wjoin(f))) |
|
879 | 882 | except: pass |
|
880 | if a: | |
|
881 | repo.dirstate.forget(a) | |
|
883 | repo.dirstate.forget(f) | |
|
882 | 884 | repo.dirstate.setparents(qp, revlog.nullid) |
|
883 | 885 | self.strip(repo, rev, update=False, backup='strip', wlock=wlock) |
|
884 | 886 | del self.applied[start:end] |
@@ -1010,7 +1012,7 b' class queue:' | |||
|
1010 | 1012 | if src is None: |
|
1011 | 1013 | continue |
|
1012 | 1014 | copies.setdefault(src, []).append(dst) |
|
1013 |
repo.dirstate. |
|
|
1015 | repo.dirstate.add(dst) | |
|
1014 | 1016 | # remember the copies between patchparent and tip |
|
1015 | 1017 | # this may be slow, so don't do it if we're not tracking copies |
|
1016 | 1018 | if self.diffopts().git: |
@@ -1027,7 +1029,8 b' class queue:' | |||
|
1027 | 1029 | for src, dsts in copies.iteritems(): |
|
1028 | 1030 | for dst in dsts: |
|
1029 | 1031 | repo.dirstate.copy(src, dst) |
|
1030 | repo.dirstate.update(r, 'r') | |
|
1032 | for f in r: | |
|
1033 | repo.dirstate.remove(f) | |
|
1031 | 1034 | # if the patch excludes a modified file, mark that file with mtime=0 |
|
1032 | 1035 | # so status can see it. |
|
1033 | 1036 | mm = [] |
@@ -1035,9 +1038,12 b' class queue:' | |||
|
1035 | 1038 | if not matchfn(m[i]): |
|
1036 | 1039 | mm.append(m[i]) |
|
1037 | 1040 | del m[i] |
|
1038 | repo.dirstate.update(m, 'n') | |
|
1039 | repo.dirstate.update(mm, 'n', st_mtime=-1, st_size=-1) | |
|
1040 | repo.dirstate.forget(forget) | |
|
1041 | for f in m: | |
|
1042 | repo.dirstate.normal(f) | |
|
1043 | for f in mm: | |
|
1044 | repo.dirstate.normaldirty(f) | |
|
1045 | for f in forget: | |
|
1046 | repo.dirstate.forget(f) | |
|
1041 | 1047 | |
|
1042 | 1048 | if not msg: |
|
1043 | 1049 | if not message: |
@@ -1068,7 +1074,7 b' class queue:' | |||
|
1068 | 1074 | except: pass |
|
1069 | 1075 | # forget the file copies in the dirstate |
|
1070 | 1076 | # push should readd the files later on |
|
1071 |
repo.dirstate.forget(a |
|
|
1077 | repo.dirstate.forget(a) | |
|
1072 | 1078 | self.pop(repo, force=True, wlock=wlock) |
|
1073 | 1079 | self.push(repo, force=True, wlock=wlock) |
|
1074 | 1080 |
@@ -2415,11 +2415,15 b' def revert(ui, repo, *pats, **opts):' | |||
|
2415 | 2415 | handle(remove, False) |
|
2416 | 2416 | |
|
2417 | 2417 | if not opts.get('dry_run'): |
|
2418 |
|
|
|
2418 | for f in forget[0]: | |
|
2419 | repo.dirstate.forget(f) | |
|
2419 | 2420 | r = hg.revert(repo, node, update.has_key, wlock) |
|
2420 | repo.dirstate.update(add[0], 'a') | |
|
2421 |
repo.dirstate. |
|
|
2422 | repo.dirstate.update(remove[0], 'r') | |
|
2421 | for f in add[0]: | |
|
2422 | repo.dirstate.add(f) | |
|
2423 | for f in undelete[0]: | |
|
2424 | repo.dirstate.normal(f) | |
|
2425 | for f in remove[0]: | |
|
2426 | repo.dirstate.remove(f) | |
|
2423 | 2427 | return r |
|
2424 | 2428 | |
|
2425 | 2429 | def rollback(ui, repo): |
@@ -118,6 +118,11 b' class dirstate(object):' | |||
|
118 | 118 | self._opener("branch", "w").write(branch + '\n') |
|
119 | 119 | |
|
120 | 120 | def state(self, key): |
|
121 | ''' current states: | |
|
122 | n normal | |
|
123 | m needs merging | |
|
124 | r marked for removal | |
|
125 | a marked for addition''' | |
|
121 | 126 | return self._map.get(key, ("?",))[0] |
|
122 | 127 | |
|
123 | 128 | def _read(self): |
@@ -197,41 +202,55 b' class dirstate(object):' | |||
|
197 | 202 | raise util.Abort(_('file named %r already in dirstate') % d) |
|
198 | 203 | self._incpath(f) |
|
199 | 204 | |
|
200 | def update(self, files, state, **kw): | |
|
201 | ''' current states: | |
|
202 | n normal | |
|
203 | m needs merging | |
|
204 | r marked for removal | |
|
205 | a marked for addition''' | |
|
206 | ||
|
207 | if not files: return | |
|
205 | def normal(self, f): | |
|
206 | 'mark a file normal' | |
|
208 | 207 | self._dirty = True |
|
209 | for f in files: | |
|
208 | s = os.lstat(self.wjoin(f)) | |
|
209 | self._map[f] = ('n', s.st_mode, s.st_size, s.st_mtime) | |
|
210 | 210 |
|
|
211 | 211 |
|
|
212 | 212 | |
|
213 | if state == "r": | |
|
214 | self._map[f] = ('r', 0, 0, 0) | |
|
215 | self._decpath(f) | |
|
216 | continue | |
|
217 | else: | |
|
218 | if state == "a": | |
|
213 | def normaldirty(self, f): | |
|
214 | 'mark a file normal, but possibly dirty' | |
|
215 | self._dirty = True | |
|
216 | s = os.lstat(self.wjoin(f)) | |
|
217 | self._map[f] = ('n', s.st_mode, -1, -1) | |
|
218 | if f in self._copymap: | |
|
219 | del self._copymap[f] | |
|
220 | ||
|
221 | def add(self, f): | |
|
222 | 'mark a file added' | |
|
223 | self._dirty = True | |
|
219 | 224 |
|
|
220 | 225 |
|
|
221 | st_size = kw.get('st_size', s.st_size) | |
|
222 | st_mtime = kw.get('st_mtime', s.st_mtime) | |
|
223 | self._map[f] = (state, s.st_mode, st_size, st_mtime) | |
|
226 | self._map[f] = ('a', s.st_mode, s.st_size, s.st_mtime) | |
|
227 | if f in self._copymap: | |
|
228 | del self._copymap[f] | |
|
229 | ||
|
230 | def remove(self, f): | |
|
231 | 'mark a file removed' | |
|
232 | self._dirty = True | |
|
233 | self._map[f] = ('r', 0, 0, 0) | |
|
234 | self._decpath(f) | |
|
235 | if f in self._copymap: | |
|
236 | del self._copymap[f] | |
|
224 | 237 | |
|
225 |
def |
|
|
226 |
|
|
|
238 | def merge(self, f): | |
|
239 | 'mark a file merged' | |
|
227 | 240 | self._dirty = True |
|
228 | for f in files: | |
|
241 | s = os.lstat(self.wjoin(f)) | |
|
242 | self._map[f] = ('m', s.st_mode, s.st_size, s.st_mtime) | |
|
243 | if f in self._copymap: | |
|
244 | del self._copymap[f] | |
|
245 | ||
|
246 | def forget(self, f): | |
|
247 | 'forget a file' | |
|
248 | self._dirty = True | |
|
229 | 249 |
|
|
230 | 250 |
|
|
231 | 251 |
|
|
232 | 252 |
|
|
233 | 253 |
|
|
234 | pass | |
|
235 | 254 | |
|
236 | 255 | def rebuild(self, parent, files): |
|
237 | 256 | self.invalidate() |
@@ -792,8 +792,10 b' class localrepository(repo.repository):' | |||
|
792 | 792 | if use_dirstate or update_dirstate: |
|
793 | 793 | self.dirstate.setparents(n) |
|
794 | 794 | if use_dirstate: |
|
795 | self.dirstate.update(new, "n") | |
|
796 |
self.dirstate. |
|
|
795 | for f in new: | |
|
796 | self.dirstate.normal(f) | |
|
797 | for f in removed: | |
|
798 | self.dirstate.forget(f) | |
|
797 | 799 | |
|
798 | 800 | self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2) |
|
799 | 801 | return n |
@@ -901,7 +903,7 b' class localrepository(repo.repository):' | |||
|
901 | 903 | except lock.LockException: |
|
902 | 904 | pass |
|
903 | 905 | if wlock: |
|
904 |
self.dirstate. |
|
|
906 | self.dirstate.normal(f) | |
|
905 | 907 | else: |
|
906 | 908 | # we are comparing working dir against non-parent |
|
907 | 909 | # generate a pseudo-manifest for the working dir |
@@ -971,7 +973,7 b' class localrepository(repo.repository):' | |||
|
971 | 973 | elif self.dirstate.state(f) in 'an': |
|
972 | 974 | self.ui.warn(_("%s already tracked!\n") % f) |
|
973 | 975 | else: |
|
974 |
self.dirstate. |
|
|
976 | self.dirstate.add(f) | |
|
975 | 977 | |
|
976 | 978 | def forget(self, list, wlock=None): |
|
977 | 979 | if not wlock: |
@@ -980,7 +982,7 b' class localrepository(repo.repository):' | |||
|
980 | 982 | if self.dirstate.state(f) not in 'ai': |
|
981 | 983 | self.ui.warn(_("%s not added!\n") % f) |
|
982 | 984 | else: |
|
983 |
self.dirstate.forget( |
|
|
985 | self.dirstate.forget(f) | |
|
984 | 986 | |
|
985 | 987 | def remove(self, list, unlink=False, wlock=None): |
|
986 | 988 | if unlink: |
@@ -996,11 +998,11 b' class localrepository(repo.repository):' | |||
|
996 | 998 | if unlink and os.path.exists(self.wjoin(f)): |
|
997 | 999 | self.ui.warn(_("%s still exists!\n") % f) |
|
998 | 1000 | elif self.dirstate.state(f) == 'a': |
|
999 |
self.dirstate.forget( |
|
|
1001 | self.dirstate.forget(f) | |
|
1000 | 1002 | elif f not in self.dirstate: |
|
1001 | 1003 | self.ui.warn(_("%s not tracked!\n") % f) |
|
1002 | 1004 | else: |
|
1003 |
self.dirstate. |
|
|
1005 | self.dirstate.remove(f) | |
|
1004 | 1006 | |
|
1005 | 1007 | def undelete(self, list, wlock=None): |
|
1006 | 1008 | p = self.dirstate.parents()[0] |
@@ -1014,7 +1016,7 b' class localrepository(repo.repository):' | |||
|
1014 | 1016 | else: |
|
1015 | 1017 | t = self.file(f).read(m[f]) |
|
1016 | 1018 | self.wwrite(f, t, m.flags(f)) |
|
1017 |
self.dirstate. |
|
|
1019 | self.dirstate.normal(f) | |
|
1018 | 1020 | |
|
1019 | 1021 | def copy(self, source, dest, wlock=None): |
|
1020 | 1022 | p = self.wjoin(dest) |
@@ -1027,7 +1029,7 b' class localrepository(repo.repository):' | |||
|
1027 | 1029 | if not wlock: |
|
1028 | 1030 | wlock = self.wlock() |
|
1029 | 1031 | if self.dirstate.state(dest) == '?': |
|
1030 |
self.dirstate. |
|
|
1032 | self.dirstate.add(dest) | |
|
1031 | 1033 | self.dirstate.copy(source, dest) |
|
1032 | 1034 | |
|
1033 | 1035 | def heads(self, start=None): |
@@ -447,25 +447,25 b' def recordupdates(repo, action, branchme' | |||
|
447 | 447 | f, m = a[:2] |
|
448 | 448 | if m == "r": # remove |
|
449 | 449 | if branchmerge: |
|
450 |
repo.dirstate. |
|
|
450 | repo.dirstate.remove(f) | |
|
451 | 451 | else: |
|
452 |
repo.dirstate.forget( |
|
|
452 | repo.dirstate.forget(f) | |
|
453 | 453 | elif m == "f": # forget |
|
454 |
repo.dirstate.forget( |
|
|
454 | repo.dirstate.forget(f) | |
|
455 | 455 | elif m == "g": # get |
|
456 | 456 | if branchmerge: |
|
457 |
repo.dirstate. |
|
|
457 | repo.dirstate.normaldirty(f) | |
|
458 | 458 | else: |
|
459 |
repo.dirstate. |
|
|
459 | repo.dirstate.normal(f) | |
|
460 | 460 | elif m == "m": # merge |
|
461 | 461 | f2, fd, flag, move = a[2:] |
|
462 | 462 | if branchmerge: |
|
463 | 463 | # We've done a branch merge, mark this file as merged |
|
464 | 464 | # so that we properly record the merger later |
|
465 |
repo.dirstate. |
|
|
465 | repo.dirstate.merge(fd) | |
|
466 | 466 | if f != f2: # copy/rename |
|
467 | 467 | if move: |
|
468 |
repo.dirstate. |
|
|
468 | repo.dirstate.remove(f) | |
|
469 | 469 | if f != fd: |
|
470 | 470 | repo.dirstate.copy(f, fd) |
|
471 | 471 | else: |
@@ -476,25 +476,25 b' def recordupdates(repo, action, branchme' | |||
|
476 | 476 | # of that file some time in the past. Thus our |
|
477 | 477 | # merge will appear as a normal local file |
|
478 | 478 | # modification. |
|
479 |
repo.dirstate. |
|
|
479 | repo.dirstate.normaldirty(fd) | |
|
480 | 480 | if move: |
|
481 |
repo.dirstate.forget( |
|
|
481 | repo.dirstate.forget(f) | |
|
482 | 482 | elif m == "d": # directory rename |
|
483 | 483 | f2, fd, flag = a[2:] |
|
484 | 484 | if not f2 and f not in repo.dirstate: |
|
485 | 485 | # untracked file moved |
|
486 | 486 | continue |
|
487 | 487 | if branchmerge: |
|
488 |
repo.dirstate. |
|
|
488 | repo.dirstate.add(fd) | |
|
489 | 489 | if f: |
|
490 |
repo.dirstate. |
|
|
490 | repo.dirstate.remove(f) | |
|
491 | 491 | repo.dirstate.copy(f, fd) |
|
492 | 492 | if f2: |
|
493 | 493 | repo.dirstate.copy(f2, fd) |
|
494 | 494 | else: |
|
495 |
repo.dirstate. |
|
|
495 | repo.dirstate.normal(fd) | |
|
496 | 496 | if f: |
|
497 |
repo.dirstate.forget( |
|
|
497 | repo.dirstate.forget(f) | |
|
498 | 498 | |
|
499 | 499 | def update(repo, node, branchmerge, force, partial, wlock): |
|
500 | 500 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now