##// END OF EJS Templates
extdiff: use archiver to take snapshots of committed revisions...
Matt Harbison -
r25812:68822b7c default
parent child Browse files
Show More
@@ -63,6 +63,7 b' pretty fast (at least faster than having'
63 from mercurial.i18n import _
63 from mercurial.i18n import _
64 from mercurial.node import short, nullid
64 from mercurial.node import short, nullid
65 from mercurial import cmdutil, scmutil, util, commands, encoding, filemerge
65 from mercurial import cmdutil, scmutil, util, commands, encoding, filemerge
66 from mercurial import archival
66 import os, shlex, shutil, tempfile, re
67 import os, shlex, shutil, tempfile, re
67
68
68 cmdtable = {}
69 cmdtable = {}
@@ -84,14 +85,21 b' def snapshot(ui, repo, files, node, tmpr'
84 dirname = '%s.%s' % (dirname, short(node))
85 dirname = '%s.%s' % (dirname, short(node))
85 base = os.path.join(tmproot, dirname)
86 base = os.path.join(tmproot, dirname)
86 os.mkdir(base)
87 os.mkdir(base)
88 fns_and_mtime = []
89
87 if node is not None:
90 if node is not None:
88 ui.note(_('making snapshot of %d files from rev %s\n') %
91 ui.note(_('making snapshot of %d files from rev %s\n') %
89 (len(files), short(node)))
92 (len(files), short(node)))
90 else:
93 else:
91 ui.note(_('making snapshot of %d files from working directory\n') %
94 ui.note(_('making snapshot of %d files from working directory\n') %
92 (len(files)))
95 (len(files)))
93 wopener = scmutil.opener(base)
96
94 fns_and_mtime = []
97 if files:
98 repo.ui.setconfig("ui", "archivemeta", False)
99
100 archival.archive(repo, base, node, 'files',
101 matchfn=scmutil.matchfiles(repo, files))
102
95 ctx = repo[node]
103 ctx = repo[node]
96 for fn in sorted(files):
104 for fn in sorted(files):
97 wfn = util.pconvert(fn)
105 wfn = util.pconvert(fn)
@@ -99,16 +107,10 b' def snapshot(ui, repo, files, node, tmpr'
99 # File doesn't exist; could be a bogus modify
107 # File doesn't exist; could be a bogus modify
100 continue
108 continue
101 ui.note(' %s\n' % wfn)
109 ui.note(' %s\n' % wfn)
110
111 if node is None:
102 dest = os.path.join(base, wfn)
112 dest = os.path.join(base, wfn)
103 fctx = ctx[wfn]
113
104 data = repo.wwritedata(wfn, fctx.data())
105 if 'l' in fctx.flags():
106 wopener.symlink(data, wfn)
107 else:
108 wopener.write(wfn, data)
109 if 'x' in fctx.flags():
110 util.setflags(dest, False, True)
111 if node is None:
112 fns_and_mtime.append((dest, repo.wjoin(fn),
114 fns_and_mtime.append((dest, repo.wjoin(fn),
113 os.lstat(dest).st_mtime))
115 os.lstat(dest).st_mtime))
114 return dirname, fns_and_mtime
116 return dirname, fns_and_mtime
@@ -20,6 +20,20 b' directory (and ".hg/largefiles/dirstate"'
20 $ echo 'large1 in #1' > large1
20 $ echo 'large1 in #1' > large1
21 $ echo 'normal1 in #1' > normal1
21 $ echo 'normal1 in #1' > normal1
22 $ hg commit -m '#1'
22 $ hg commit -m '#1'
23 $ hg extdiff -r '.^' --config extensions.extdiff=
24 diff -Npru repo.0d9d9b8dc9a3/.hglf/large1 repo/.hglf/large1
25 --- repo.0d9d9b8dc9a3/.hglf/large1 * (glob)
26 +++ repo/.hglf/large1 * (glob)
27 @@ -1 +1 @@
28 -4669e532d5b2c093a78eca010077e708a071bb64
29 +58e24f733a964da346e2407a2bee99d9001184f5
30 diff -Npru repo.0d9d9b8dc9a3/normal1 repo/normal1
31 --- repo.0d9d9b8dc9a3/normal1 * (glob)
32 +++ repo/normal1 * (glob)
33 @@ -1 +1 @@
34 -normal1
35 +normal1 in #1
36 [1]
23 $ hg update -q -C 0
37 $ hg update -q -C 0
24 $ echo 'large2 in #2' > large2
38 $ echo 'large2 in #2' > large2
25 $ hg commit -m '#2'
39 $ hg commit -m '#2'
General Comments 0
You need to be logged in to leave comments. Login now