Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 4904:6fd953d5faea
dirstate: break update into separate functions
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 21 Jul 2007 16:02:09 -0500 |
parents | d69b1fb111b9 |
children | 30847b8af7ca |
comparison
equal
deleted
inserted
replaced
4903:81078e177266 | 4904:6fd953d5faea |
---|---|
790 self.branchcache[util.tolocal(extra["branch"])] = n | 790 self.branchcache[util.tolocal(extra["branch"])] = n |
791 | 791 |
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.forget(removed) | 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 |
800 | 802 |
801 def walk(self, node=None, files=[], match=util.always, badmatch=None): | 803 def walk(self, node=None, files=[], match=util.always, badmatch=None): |
899 try: | 901 try: |
900 wlock = self.wlock(wait=0) | 902 wlock = self.wlock(wait=0) |
901 except lock.LockException: | 903 except lock.LockException: |
902 pass | 904 pass |
903 if wlock: | 905 if wlock: |
904 self.dirstate.update([f], "n") | 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 |
908 # XXX: create it in dirstate.py ? | 910 # XXX: create it in dirstate.py ? |
909 mf2 = mfmatches(self.dirstate.parents()[0]) | 911 mf2 = mfmatches(self.dirstate.parents()[0]) |
969 self.ui.warn(_("%s not added: only files and symlinks " | 971 self.ui.warn(_("%s not added: only files and symlinks " |
970 "supported currently\n") % f) | 972 "supported currently\n") % f) |
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.update([f], "a") | 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: |
978 wlock = self.wlock() | 980 wlock = self.wlock() |
979 for f in list: | 981 for f in list: |
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([f]) | 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: |
987 for f in list: | 989 for f in list: |
988 try: | 990 try: |
994 wlock = self.wlock() | 996 wlock = self.wlock() |
995 for f in list: | 997 for f in list: |
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([f]) | 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.update([f], "r") | 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] |
1007 mn = self.changelog.read(p)[0] | 1009 mn = self.changelog.read(p)[0] |
1008 m = self.manifest.read(mn) | 1010 m = self.manifest.read(mn) |
1012 if self.dirstate.state(f) not in "r": | 1014 if self.dirstate.state(f) not in "r": |
1013 self.ui.warn("%s not removed!\n" % f) | 1015 self.ui.warn("%s not removed!\n" % f) |
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.update([f], "n") | 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) |
1021 if not (os.path.exists(p) or os.path.islink(p)): | 1023 if not (os.path.exists(p) or os.path.islink(p)): |
1022 self.ui.warn(_("%s does not exist!\n") % dest) | 1024 self.ui.warn(_("%s does not exist!\n") % dest) |
1025 "symbolic link\n") % dest) | 1027 "symbolic link\n") % dest) |
1026 else: | 1028 else: |
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.update([dest], "a") | 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): |
1034 heads = self.changelog.heads(start) | 1036 heads = self.changelog.heads(start) |
1035 # sort the output in rev descending order | 1037 # sort the output in rev descending order |