##// END OF EJS Templates
Merge with crew-stable
Patrick Mezard -
r8066:aece3c9e merge default
parent child Browse files
Show More
@@ -48,7 +48,7 b' class p4_source(converter_source):'
48
48
49 def _parse_view(self, path):
49 def _parse_view(self, path):
50 "Read changes affecting the path"
50 "Read changes affecting the path"
51 cmd = "p4 -G changes -s submitted '%s'" % path
51 cmd = 'p4 -G changes -s submitted "%s"' % path
52 stdout = util.popen(cmd)
52 stdout = util.popen(cmd)
53 for d in loaditer(stdout):
53 for d in loaditer(stdout):
54 c = d.get("change", None)
54 c = d.get("change", None)
@@ -67,7 +67,7 b' class p4_source(converter_source):'
67 else:
67 else:
68 views = {"//": ""}
68 views = {"//": ""}
69 else:
69 else:
70 cmd = "p4 -G client -o '%s'" % path
70 cmd = 'p4 -G client -o "%s"' % path
71 clientspec = marshal.load(util.popen(cmd))
71 clientspec = marshal.load(util.popen(cmd))
72
72
73 views = {}
73 views = {}
@@ -142,7 +142,7 b' class p4_source(converter_source):'
142 return self.heads
142 return self.heads
143
143
144 def getfile(self, name, rev):
144 def getfile(self, name, rev):
145 cmd = "p4 -G print '%s#%s'" % (self.depotname[name], rev)
145 cmd = 'p4 -G print "%s#%s"' % (self.depotname[name], rev)
146 stdout = util.popen(cmd)
146 stdout = util.popen(cmd)
147
147
148 mode = None
148 mode = None
@@ -50,16 +50,25 b' from mercurial.node import short'
50 from mercurial import cmdutil, util, commands
50 from mercurial import cmdutil, util, commands
51 import os, shlex, shutil, tempfile
51 import os, shlex, shutil, tempfile
52
52
53 def snapshot_node(ui, repo, files, node, tmproot):
53 def snapshot(ui, repo, files, node, tmproot):
54 '''snapshot files as of some revision'''
54 '''snapshot files as of some revision
55 if not using snapshot, -I/-X does not work and recursive diff
56 in tools like kdiff3 and meld displays too many files.'''
55 dirname = os.path.basename(repo.root)
57 dirname = os.path.basename(repo.root)
56 if dirname == "":
58 if dirname == "":
57 dirname = "root"
59 dirname = "root"
60 if node is not None:
58 dirname = '%s.%s' % (dirname, short(node))
61 dirname = '%s.%s' % (dirname, short(node))
59 base = os.path.join(tmproot, dirname)
62 base = os.path.join(tmproot, dirname)
60 os.mkdir(base)
63 os.mkdir(base)
64 if node is not None:
61 ui.note(_('making snapshot of %d files from rev %s\n') %
65 ui.note(_('making snapshot of %d files from rev %s\n') %
62 (len(files), short(node)))
66 (len(files), short(node)))
67 else:
68 ui.note(_('making snapshot of %d files from working directory\n') %
69 (len(files)))
70 wopener = util.opener(base)
71 fns_and_mtime = []
63 ctx = repo[node]
72 ctx = repo[node]
64 for fn in files:
73 for fn in files:
65 wfn = util.pconvert(fn)
74 wfn = util.pconvert(fn)
@@ -68,47 +77,18 b' def snapshot_node(ui, repo, files, node,'
68 continue
77 continue
69 ui.note(' %s\n' % wfn)
78 ui.note(' %s\n' % wfn)
70 dest = os.path.join(base, wfn)
79 dest = os.path.join(base, wfn)
71 destdir = os.path.dirname(dest)
80 fctx = ctx[wfn]
72 if not os.path.isdir(destdir):
81 data = repo.wwritedata(wfn, fctx.data())
73 os.makedirs(destdir)
82 if 'l' in fctx.flags():
74 data = repo.wwritedata(wfn, ctx[wfn].data())
83 wopener.symlink(data, wfn)
75 open(dest, 'wb').write(data)
84 else:
76 return dirname
85 wopener(wfn, 'w').write(data)
77
86 if 'x' in fctx.flags():
78
87 util.set_flags(dest, False, True)
79 def snapshot_wdir(ui, repo, files, tmproot):
88 if node is None:
80 '''snapshot files from working directory.
81 if not using snapshot, -I/-X does not work and recursive diff
82 in tools like kdiff3 and meld displays too many files.'''
83 dirname = os.path.basename(repo.root)
84 if dirname == "":
85 dirname = "root"
86 base = os.path.join(tmproot, dirname)
87 os.mkdir(base)
88 ui.note(_('making snapshot of %d files from working directory\n') %
89 (len(files)))
90
91 fns_and_mtime = []
92
93 for fn in files:
94 wfn = util.pconvert(fn)
95 ui.note(' %s\n' % wfn)
96 dest = os.path.join(base, wfn)
97 destdir = os.path.dirname(dest)
98 if not os.path.isdir(destdir):
99 os.makedirs(destdir)
100
101 fp = open(dest, 'wb')
102 for chunk in util.filechunkiter(repo.wopener(wfn)):
103 fp.write(chunk)
104 fp.close()
105
106 fns_and_mtime.append((dest, repo.wjoin(fn), os.path.getmtime(dest)))
89 fns_and_mtime.append((dest, repo.wjoin(fn), os.path.getmtime(dest)))
107
108
109 return dirname, fns_and_mtime
90 return dirname, fns_and_mtime
110
91
111
112 def dodiff(ui, repo, diffcmd, diffopts, pats, opts):
92 def dodiff(ui, repo, diffcmd, diffopts, pats, opts):
113 '''Do the actuall diff:
93 '''Do the actuall diff:
114
94
@@ -139,24 +119,17 b' def dodiff(ui, repo, diffcmd, diffopts, '
139 dir2root = ''
119 dir2root = ''
140 try:
120 try:
141 # Always make a copy of node1
121 # Always make a copy of node1
142 dir1 = snapshot_node(ui, repo, modified + removed, node1, tmproot)
122 dir1 = snapshot(ui, repo, modified + removed, node1, tmproot)[0]
143 changes = len(modified) + len(removed) + len(added)
123 changes = len(modified) + len(removed) + len(added)
144
124
145 fns_and_mtime = []
146
147 # If node2 in not the wc or there is >1 change, copy it
125 # If node2 in not the wc or there is >1 change, copy it
148 if node2:
126 if node2 or changes > 1:
149 dir2 = snapshot_node(ui, repo, modified + added, node2, tmproot)
127 dir2, fns_and_mtime = snapshot(ui, repo, modified + added, node2, tmproot)
150 elif changes > 1:
151 #we only actually need to get the files to copy back to the working
152 #dir in this case (because the other cases are: diffing 2 revisions
153 #or single file -- in which case the file is already directly passed
154 #to the diff tool).
155 dir2, fns_and_mtime = snapshot_wdir(ui, repo, modified + added, tmproot)
156 else:
128 else:
157 # This lets the diff tool open the changed file directly
129 # This lets the diff tool open the changed file directly
158 dir2 = ''
130 dir2 = ''
159 dir2root = repo.root
131 dir2root = repo.root
132 fns_and_mtime = []
160
133
161 # If only one change, diff the files instead of the directories
134 # If only one change, diff the files instead of the directories
162 if changes == 1 :
135 if changes == 1 :
@@ -513,7 +513,7 b' class workingctx(changectx):'
513 return True
513 return True
514
514
515 def __contains__(self, key):
515 def __contains__(self, key):
516 return self._dirstate[key] not in "?r"
516 return self._repo.dirstate[key] not in "?r"
517
517
518 def _manifest(self):
518 def _manifest(self):
519 """generate a manifest corresponding to the working directory"""
519 """generate a manifest corresponding to the working directory"""
1 NO CONTENT: modified file chmod 100644 => 100755
NO CONTENT: modified file chmod 100644 => 100755
@@ -28,7 +28,7 b" hg ci -d '1 0' -mtest2"
28 hg falabala -r 0:1
28 hg falabala -r 0:1
29
29
30 # test diff during merge
30 # test diff during merge
31 hg update 0
31 hg update -C 0
32 echo c >> c
32 echo c >> c
33 hg add c
33 hg add c
34 hg ci -m "new branch" -d '1 0'
34 hg ci -m "new branch" -d '1 0'
@@ -43,3 +43,24 b' hg falabala -c 1'
43 # check diff are made from the first parent
43 # check diff are made from the first parent
44 hg falabala -c 3 || echo "diff-like tools yield a non-zero exit code"
44 hg falabala -c 3 || echo "diff-like tools yield a non-zero exit code"
45 #hg log
45 #hg log
46
47 echo
48 echo '% test extdiff of multiple files in tmp dir:'
49 hg update -C 0 > /dev/null
50 echo changed > a
51 echo changed > b
52 chmod +x b
53 echo '% diff in working directory, before'
54 hg diff --git
55 echo '% edit with extdiff -p'
56 # prepare custom diff/edit tool
57 cat > differ.sh << EOT
58 #!/bin/sh
59 sleep 1 # avoid unchanged-timestamp problems
60 echo edited >> a/a
61 echo edited >> a/b
62 EOT
63 chmod +x differ.sh
64 hg extdiff -p `pwd`/differ.sh # will change to /tmp/extdiff.TMP and populate directories a.TMP and a and start tool
65 echo '% diff in working directory, after'
66 hg diff --git
@@ -34,3 +34,38 b' diffing a.2a13a4d2da36/a [tmp]/test-extd'
34 diffing a.8a5febb7f867/a a.34eed99112ab/a
34 diffing a.8a5febb7f867/a a.34eed99112ab/a
35 diffing a.2a13a4d2da36/a a.46c0e4daeb72/a
35 diffing a.2a13a4d2da36/a a.46c0e4daeb72/a
36 diff-like tools yield a non-zero exit code
36 diff-like tools yield a non-zero exit code
37
38 % test extdiff of multiple files in tmp dir:
39 % diff in working directory, before
40 diff --git a/a b/a
41 --- a/a
42 +++ b/a
43 @@ -1,1 +1,1 @@
44 -a
45 +changed
46 diff --git a/b b/b
47 old mode 100644
48 new mode 100755
49 --- a/b
50 +++ b/b
51 @@ -1,1 +1,1 @@
52 -b
53 +changed
54 % edit with extdiff -p
55 % diff in working directory, after
56 diff --git a/a b/a
57 --- a/a
58 +++ b/a
59 @@ -1,1 +1,2 @@
60 -a
61 +changed
62 +edited
63 diff --git a/b b/b
64 old mode 100644
65 new mode 100755
66 --- a/b
67 +++ b/b
68 @@ -1,1 +1,2 @@
69 -b
70 +changed
71 +edited
1 NO CONTENT: modified file chmod 100644 => 100755
NO CONTENT: modified file chmod 100644 => 100755
General Comments 0
You need to be logged in to leave comments. Login now