##// END OF EJS Templates
batchget: add support for backing up files...
Siddharth Agarwal -
r27656:57c0d488 default
parent child Browse files
Show More
@@ -26,6 +26,7 b' from . import ('
26 26 error,
27 27 filemerge,
28 28 obsolete,
29 scmutil,
29 30 subrepo,
30 31 util,
31 32 worker,
@@ -971,12 +972,27 b' def batchget(repo, mctx, actions):'
971 972 verbose = repo.ui.verbose
972 973 fctx = mctx.filectx
973 974 wwrite = repo.wwrite
975 ui = repo.ui
974 976 i = 0
975 for f, args, msg in actions:
977 for f, (flags, backup), msg in actions:
976 978 repo.ui.debug(" %s: %s -> g\n" % (f, msg))
977 979 if verbose:
978 980 repo.ui.note(_("getting %s\n") % f)
979 wwrite(f, fctx(f).data(), args[0])
981
982 if backup:
983 absf = repo.wjoin(f)
984 orig = scmutil.origpath(ui, repo, absf)
985 try:
986 # TODO Mercurial has always aborted if an untracked directory
987 # is replaced by a tracked file, or generally with
988 # file/directory merges. This needs to be sorted out.
989 if repo.wvfs.isfileorlink(f):
990 util.rename(absf, orig)
991 except OSError as e:
992 if e.errno != errno.ENOENT:
993 raise
994
995 wwrite(f, fctx(f).data(), flags)
980 996 if i == 100:
981 997 yield i, f
982 998 i = 0
General Comments 0
You need to be logged in to leave comments. Login now