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