comparison mercurial/merge.py @ 30172:90a6c18a7c1d

update: warn if cwd was deleted During update directories are deleted as soon as they have no entries. But if current working directory is deleted then it cause problems in complex commands like 'hg split'. This commit adds a warning that will help users figure the problem faster.
author Stanislau Hlebik <stash@fb.com>
date Tue, 04 Oct 2016 04:06:48 -0700
parents 5cb830801855
children a2804ddcf9ae
comparison
equal deleted inserted replaced
30171:7a3b59f0329a 30172:90a6c18a7c1d
1036 """ 1036 """
1037 verbose = repo.ui.verbose 1037 verbose = repo.ui.verbose
1038 unlink = util.unlinkpath 1038 unlink = util.unlinkpath
1039 wjoin = repo.wjoin 1039 wjoin = repo.wjoin
1040 audit = repo.wvfs.audit 1040 audit = repo.wvfs.audit
1041 try:
1042 cwd = os.getcwd()
1043 except OSError as err:
1044 if err.errno != errno.ENOENT:
1045 raise
1046 cwd = None
1041 i = 0 1047 i = 0
1042 for f, args, msg in actions: 1048 for f, args, msg in actions:
1043 repo.ui.debug(" %s: %s -> r\n" % (f, msg)) 1049 repo.ui.debug(" %s: %s -> r\n" % (f, msg))
1044 if verbose: 1050 if verbose:
1045 repo.ui.note(_("removing %s\n") % f) 1051 repo.ui.note(_("removing %s\n") % f)
1053 yield i, f 1059 yield i, f
1054 i = 0 1060 i = 0
1055 i += 1 1061 i += 1
1056 if i > 0: 1062 if i > 0:
1057 yield i, f 1063 yield i, f
1064 if cwd:
1065 # cwd was present before we started to remove files
1066 # let's check if it is present after we removed them
1067 try:
1068 os.getcwd()
1069 except OSError as err:
1070 if err.errno != errno.ENOENT:
1071 raise
1072 # Print a warning if cwd was deleted
1073 repo.ui.warn(_("current directory was removed\n"
1074 "(consider changing to repo root: %s)\n") %
1075 repo.root)
1058 1076
1059 def batchget(repo, mctx, actions): 1077 def batchget(repo, mctx, actions):
1060 """apply gets to the working directory 1078 """apply gets to the working directory
1061 1079
1062 mctx is the context to get from 1080 mctx is the context to get from