[PATCH 6 of 7 checkunknown] batchget: add support for backing up files
Siddharth Agarwal
sid0 at fb.com
Sat Jan 2 11:25:10 UTC 2016
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1451733661 28800
# Sat Jan 02 03:21:01 2016 -0800
# Node ID d2b847835e055f08e538ecf3ad336b7a1cb57e30
# Parent c1ad84b3d9c0cc4c80e8df426dc9d8bf4c4fc488
# Available At http://42.netv6.net/sid0-wip/hg/
# hg pull http://42.netv6.net/sid0-wip/hg/ -r d2b847835e05
batchget: add support for backing up files
We're going to use this in an upcoming feature.
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -971,11 +971,26 @@ def batchget(repo, mctx, actions):
verbose = repo.ui.verbose
fctx = mctx.filectx
wwrite = repo.wwrite
+ ui = repo.ui
i = 0
for f, args, msg in actions:
repo.ui.debug(" %s: %s -> g\n" % (f, msg))
if verbose:
repo.ui.note(_("getting %s\n") % f)
+
+ if args[1]: # backup
+ absf = repo.wjoin(f)
+ orig = scmutil.origpath(ui, repo, absf)
+ try:
+ # TODO Mercurial has always aborted if an untracked directory
+ # is replaced by a tracked file, or generally with
+ # file/directory merges. This needs to be sorted out.
+ if repo.wvfs.isfileorlink(f):
+ util.rename(absf, orig)
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
+
wwrite(f, fctx(f).data(), args[0])
if i == 100:
yield i, f
More information about the Mercurial-devel
mailing list