##// 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,33 +85,34 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:
95 ctx = repo[node]
98 repo.ui.setconfig("ui", "archivemeta", False)
96 for fn in sorted(files):
99
97 wfn = util.pconvert(fn)
100 archival.archive(repo, base, node, 'files',
98 if wfn not in ctx:
101 matchfn=scmutil.matchfiles(repo, files))
99 # File doesn't exist; could be a bogus modify
102
100 continue
103 ctx = repo[node]
101 ui.note(' %s\n' % wfn)
104 for fn in sorted(files):
102 dest = os.path.join(base, wfn)
105 wfn = util.pconvert(fn)
103 fctx = ctx[wfn]
106 if wfn not in ctx:
104 data = repo.wwritedata(wfn, fctx.data())
107 # File doesn't exist; could be a bogus modify
105 if 'l' in fctx.flags():
108 continue
106 wopener.symlink(data, wfn)
109 ui.note(' %s\n' % wfn)
107 else:
110
108 wopener.write(wfn, data)
111 if node is None:
109 if 'x' in fctx.flags():
112 dest = os.path.join(base, wfn)
110 util.setflags(dest, False, True)
113
111 if node is None:
114 fns_and_mtime.append((dest, repo.wjoin(fn),
112 fns_and_mtime.append((dest, repo.wjoin(fn),
115 os.lstat(dest).st_mtime))
113 os.lstat(dest).st_mtime))
114 return dirname, fns_and_mtime
116 return dirname, fns_and_mtime
115
117
116 def dodiff(ui, repo, cmdline, pats, opts):
118 def dodiff(ui, repo, cmdline, pats, opts):
@@ -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