##// END OF EJS Templates
Merge with crew
Matt Mackall -
r4276:cb6107f7 merge default
parent child Browse files
Show More
@@ -2255,7 +2255,8 b' def revert(ui, repo, *pats, **opts):'
2255 def handle(xlist, dobackup):
2255 def handle(xlist, dobackup):
2256 xlist[0].append(abs)
2256 xlist[0].append(abs)
2257 update[abs] = 1
2257 update[abs] = 1
2258 if dobackup and not opts['no_backup'] and os.path.exists(rel):
2258 if (dobackup and not opts['no_backup'] and
2259 (os.path.islink(rel) or os.path.exists(rel))):
2259 bakname = "%s.orig" % rel
2260 bakname = "%s.orig" % rel
2260 ui.note(_('saving current version of %s as %s\n') %
2261 ui.note(_('saving current version of %s as %s\n') %
2261 (rel, bakname))
2262 (rel, bakname))
@@ -102,11 +102,6 b' class localrepository(repo.repository):'
102 self.filterpats = {}
102 self.filterpats = {}
103 self.transhandle = None
103 self.transhandle = None
104
104
105 self._link = lambda x: False
106 if util.checklink(self.root):
107 r = self.root # avoid circular reference in lambda
108 self._link = lambda x: util.is_link(os.path.join(r, x))
109
110 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root)
105 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root)
111
106
112 def url(self):
107 def url(self):
@@ -505,6 +500,9 b' class localrepository(repo.repository):'
505 def wfile(self, f, mode='r'):
500 def wfile(self, f, mode='r'):
506 return self.wopener(f, mode)
501 return self.wopener(f, mode)
507
502
503 def _link(self, f):
504 return os.path.islink(self.wjoin(f))
505
508 def _filter(self, filter, filename, data):
506 def _filter(self, filter, filename, data):
509 if filter not in self.filterpats:
507 if filter not in self.filterpats:
510 l = []
508 l = []
@@ -1052,10 +1050,11 b' class localrepository(repo.repository):'
1052
1050
1053 def copy(self, source, dest, wlock=None):
1051 def copy(self, source, dest, wlock=None):
1054 p = self.wjoin(dest)
1052 p = self.wjoin(dest)
1055 if not os.path.exists(p):
1053 if not (os.path.exists(p) or os.path.islink(p)):
1056 self.ui.warn(_("%s does not exist!\n") % dest)
1054 self.ui.warn(_("%s does not exist!\n") % dest)
1057 elif not os.path.isfile(p):
1055 elif not (os.path.isfile(p) or os.path.islink(p)):
1058 self.ui.warn(_("copy failed: %s is not a file\n") % dest)
1056 self.ui.warn(_("copy failed: %s is not a file or a "
1057 "symbolic link\n") % dest)
1059 else:
1058 else:
1060 if not wlock:
1059 if not wlock:
1061 wlock = self.wlock()
1060 wlock = self.wlock()
@@ -614,11 +614,18 b' def unlink(f):'
614
614
615 def copyfile(src, dest):
615 def copyfile(src, dest):
616 "copy a file, preserving mode"
616 "copy a file, preserving mode"
617 try:
617 if os.path.islink(src):
618 shutil.copyfile(src, dest)
618 try:
619 shutil.copymode(src, dest)
619 os.unlink(dest)
620 except shutil.Error, inst:
620 except:
621 raise Abort(str(inst))
621 pass
622 os.symlink(os.readlink(src), dest)
623 else:
624 try:
625 shutil.copyfile(src, dest)
626 shutil.copymode(src, dest)
627 except shutil.Error, inst:
628 raise Abort(str(inst))
622
629
623 def copyfiles(src, dst, hardlink=None):
630 def copyfiles(src, dst, hardlink=None):
624 """Copy a directory tree using hardlinks if possible"""
631 """Copy a directory tree using hardlinks if possible"""
@@ -785,7 +792,7 b' def checklink(path):'
785 def linkfunc(path, fallback):
792 def linkfunc(path, fallback):
786 '''return an is_link() function with default to fallback'''
793 '''return an is_link() function with default to fallback'''
787 if checklink(path):
794 if checklink(path):
788 return lambda x: is_link(os.path.join(path, x))
795 return lambda x: os.path.islink(os.path.join(path, x))
789 return fallback
796 return fallback
790
797
791 # Platform specific variants
798 # Platform specific variants
@@ -961,10 +968,6 b' else:'
961 else:
968 else:
962 os.chmod(f, s & 0666)
969 os.chmod(f, s & 0666)
963
970
964 def is_link(f):
965 """check whether a file is a symlink"""
966 return (os.lstat(f).st_mode & 0120000 == 0120000)
967
968 def set_link(f, mode):
971 def set_link(f, mode):
969 """make a file a symbolic link/regular file
972 """make a file a symbolic link/regular file
970
973
@@ -972,7 +975,7 b' else:'
972 if a link is changed to a file, its link data become its contents
975 if a link is changed to a file, its link data become its contents
973 """
976 """
974
977
975 m = is_link(f)
978 m = os.path.islink(f)
976 if m == bool(mode):
979 if m == bool(mode):
977 return
980 return
978
981
General Comments 0
You need to be logged in to leave comments. Login now