remove merge-recursive-old
This frees the Porcelain-ish that comes with the core Python-free. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Nov 20, 2006 at 00:49 UTC
7cdbff14d4823c3a3d64c2011ab0b23f794efef8
14 files changed
+10
-2497
.gitignore
-1
@@ -66,7 +66,6 @@ git-merge-one-file
66
git-merge-ours
67
git-merge-recur
68
git-merge-recursive
69
-git-merge-recursive-old
69
git-merge-resolve
70
git-merge-stupid
71
git-mktag
INSTALL
-3
@@ -99,9 +99,6 @@ Issues of note:
99
- "perl" and POSIX-compliant shells are needed to use most of
100
the barebone Porcelainish scripts.
101
102
- - "python" 2.3 or more recent; if you have 2.3, you may need
103
- to build with "make WITH_OWN_SUBPROCESS_PY=YesPlease".
104
-
102
- Some platform specific issues are dealt with Makefile rules,
103
but depending on your specific installation, you may not
104
have all the libraries/tools needed, or you may have
Makefile
+2
-43
@@ -69,8 +69,6 @@ all:
69
#
70
# Define NO_MMAP if you want to avoid mmap.
71
#
72
-# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
73
-#
72
# Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
73
#
74
# Define NO_SOCKADDR_STORAGE if your platform does not have struct
@@ -116,7 +114,6 @@ prefix = $(HOME)
114
bindir = $(prefix)/bin
115
gitexecdir = $(bindir)
116
template_dir = $(prefix)/share/git-core/templates/
119
-GIT_PYTHON_DIR = $(prefix)/share/git-core/python
117
# DESTDIR=
118
119
# default configuration for gitweb
@@ -135,7 +132,7 @@ GITWEB_FAVICON = git-favicon.png
132
GITWEB_SITE_HEADER =
133
GITWEB_SITE_FOOTER =
134
138
-export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR
135
+export prefix bindir gitexecdir template_dir
136
137
CC = gcc
138
AR = ar
@@ -179,12 +176,8 @@ SCRIPT_PERL = \
176
git-svnimport.perl git-cvsexportcommit.perl \
177
git-send-email.perl git-svn.perl
178
182
-SCRIPT_PYTHON = \
183
- git-merge-recursive-old.py
184
-
179
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
180
$(patsubst %.perl,%,$(SCRIPT_PERL)) \
187
- $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
181
git-cherry-pick git-status git-instaweb
182
183
# ... and all the rest that could be moved out of bindir to gitexecdir
@@ -227,12 +220,6 @@ endif
220
ifndef PERL_PATH
221
PERL_PATH = /usr/bin/perl
222
endif
230
-ifndef PYTHON_PATH
231
- PYTHON_PATH = /usr/bin/python
232
-endif
233
-
234
-PYMODULES = \
235
- gitMergeCommon.py
223
224
LIB_FILE=libgit.a
225
XDIFF_LIB=xdiff/lib.a
@@ -423,16 +410,6 @@ endif
410
-include config.mak.autogen
411
-include config.mak
412
426
-ifdef WITH_OWN_SUBPROCESS_PY
427
- PYMODULES += compat/subprocess.py
428
-else
429
- ifeq ($(NO_PYTHON),)
430
- ifneq ($(shell $(PYTHON_PATH) -c 'import subprocess;print"OK"' 2>/dev/null),OK)
431
- PYMODULES += compat/subprocess.py
432
- endif
433
- endif
434
-endif
435
-
413
ifndef NO_CURL
414
ifdef CURLDIR
415
# This is still problematic -- gcc does not always want -R.
@@ -574,8 +551,6 @@ prefix_SQ = $(subst ','\'',$(prefix))
551
552
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
553
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
577
-PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
578
-GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT_PYTHON_DIR))
554
555
LIBS = $(GITLIBS) $(EXTLIBS)
556
@@ -622,7 +597,6 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
597
-e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
598
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
599
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
625
- -e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
600
$@.sh >$@+
601
chmod +x $@+
602
mv $@+ $@
@@ -644,15 +618,6 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
618
chmod +x $@+
619
mv $@+ $@
620
647
-$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py GIT-CFLAGS
648
- rm -f $@ $@+
649
- sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
650
- -e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR_SQ)|g' \
651
- -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
652
- $@.py >$@+
653
- chmod +x $@+
654
- mv $@+ $@
655
-
621
git-cherry-pick: git-revert
622
cp $< $@+
623
mv $@+ $@
@@ -689,7 +654,6 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
654
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
655
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
656
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
692
- -e 's/@@NO_PYTHON@@/$(NO_PYTHON)/g' \
657
-e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
658
-e '/@@GITWEB_CGI@@/d' \
659
-e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
@@ -709,7 +673,6 @@ configure: configure.ac
673
git$X git.spec \
674
$(patsubst %.sh,%,$(SCRIPT_SH)) \
675
$(patsubst %.perl,%,$(SCRIPT_PERL)) \
712
- $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
676
: GIT-VERSION-FILE
677
678
%.o: %.c GIT-CFLAGS
@@ -783,7 +746,7 @@ tags:
746
find . -name '*.[hcS]' -print | xargs ctags -a
747
748
### Detect prefix changes
786
-TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):$(GIT_PYTHON_DIR_SQ):\
749
+TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
750
$(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
751
752
GIT-CFLAGS: .FORCE-GIT-CFLAGS
@@ -799,7 +762,6 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
762
# However, the environment gets quite big, and some programs have problems
763
# with that.
764
802
-export NO_PYTHON
765
export NO_SVN_TESTS
766
767
test: all
@@ -834,8 +796,6 @@ install: all
796
$(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
797
$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
798
$(MAKE) -C perl install
837
- $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
838
- $(INSTALL) $(PYMODULES) '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
799
if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
800
then \
801
ln -f '$(DESTDIR_SQ)$(bindir_SQ)/git$X' \
@@ -922,7 +882,6 @@ check-docs::
882
case "$$v" in \
883
git-merge-octopus | git-merge-ours | git-merge-recursive | \
884
git-merge-resolve | git-merge-stupid | git-merge-recur | \
925
- git-merge-recursive-old | \
885
git-ssh-pull | git-ssh-push ) continue ;; \
886
esac ; \
887
test -f "Documentation/$$v.txt" || \
compat/subprocess.py
deleted
-1149
@@ -1,1149 +0,0 @@
1
-# subprocess - Subprocesses with accessible I/O streams
2
-#
3
-# For more information about this module, see PEP 324.
4
-#
5
-# This module should remain compatible with Python 2.2, see PEP 291.
6
-#
7
-# Copyright (c) 2003-2005 by Peter Astrand <astrand@lysator.liu.se>
8
-#
9
-# Licensed to PSF under a Contributor Agreement.
10
-# See http://www.python.org/2.4/license for licensing details.
11
-
12
-r"""subprocess - Subprocesses with accessible I/O streams
13
-
14
-This module allows you to spawn processes, connect to their
15
-input/output/error pipes, and obtain their return codes. This module
16
-intends to replace several other, older modules and functions, like:
17
-
18
-os.system
19
-os.spawn*
20
-os.popen*
21
-popen2.*
22
-commands.*
23
-
24
-Information about how the subprocess module can be used to replace these
25
-modules and functions can be found below.
26
-
27
-
28
-
29
-Using the subprocess module
30
-===========================
31
-This module defines one class called Popen:
32
-
33
-class Popen(args, bufsize=0, executable=None,
34
- stdin=None, stdout=None, stderr=None,
35
- preexec_fn=None, close_fds=False, shell=False,
36
- cwd=None, env=None, universal_newlines=False,
37
- startupinfo=None, creationflags=0):
38
-
39
-
40
-Arguments are:
41
-
42
-args should be a string, or a sequence of program arguments. The
43
-program to execute is normally the first item in the args sequence or
44
-string, but can be explicitly set by using the executable argument.
45
-
46
-On UNIX, with shell=False (default): In this case, the Popen class
47
-uses os.execvp() to execute the child program. args should normally
48
-be a sequence. A string will be treated as a sequence with the string
49
-as the only item (the program to execute).
50
-
51
-On UNIX, with shell=True: If args is a string, it specifies the
52
-command string to execute through the shell. If args is a sequence,
53
-the first item specifies the command string, and any additional items
54
-will be treated as additional shell arguments.
55
-
56
-On Windows: the Popen class uses CreateProcess() to execute the child
57
-program, which operates on strings. If args is a sequence, it will be
58
-converted to a string using the list2cmdline method. Please note that
59
-not all MS Windows applications interpret the command line the same
60
-way: The list2cmdline is designed for applications using the same
61
-rules as the MS C runtime.
62
-
63
-bufsize, if given, has the same meaning as the corresponding argument
64
-to the built-in open() function: 0 means unbuffered, 1 means line
65
-buffered, any other positive value means use a buffer of
66
-(approximately) that size. A negative bufsize means to use the system
67
-default, which usually means fully buffered. The default value for
68
-bufsize is 0 (unbuffered).
69
-
70
-stdin, stdout and stderr specify the executed programs' standard
71
-input, standard output and standard error file handles, respectively.
72
-Valid values are PIPE, an existing file descriptor (a positive
73
-integer), an existing file object, and None. PIPE indicates that a
74
-new pipe to the child should be created. With None, no redirection
75
-will occur; the child's file handles will be inherited from the
76
-parent. Additionally, stderr can be STDOUT, which indicates that the
77
-stderr data from the applications should be captured into the same
78
-file handle as for stdout.
79
-
80
-If preexec_fn is set to a callable object, this object will be called
81
-in the child process just before the child is executed.
82
-
83
-If close_fds is true, all file descriptors except 0, 1 and 2 will be
84
-closed before the child process is executed.
85
-
86
-if shell is true, the specified command will be executed through the
87
-shell.
88
-
89
-If cwd is not None, the current directory will be changed to cwd
90
-before the child is executed.
91
-
92
-If env is not None, it defines the environment variables for the new
93
-process.
94
-
95
-If universal_newlines is true, the file objects stdout and stderr are
96
-opened as a text files, but lines may be terminated by any of '\n',
97
-the Unix end-of-line convention, '\r', the Macintosh convention or
98
-'\r\n', the Windows convention. All of these external representations
99
-are seen as '\n' by the Python program. Note: This feature is only
100
-available if Python is built with universal newline support (the
101
-default). Also, the newlines attribute of the file objects stdout,
102
-stdin and stderr are not updated by the communicate() method.
103
-
104
-The startupinfo and creationflags, if given, will be passed to the
105
-underlying CreateProcess() function. They can specify things such as
106
-appearance of the main window and priority for the new process.
107
-(Windows only)
108
-
109
-
110
-This module also defines two shortcut functions:
111
-
112
-call(*args, **kwargs):
113
- Run command with arguments. Wait for command to complete, then
114
- return the returncode attribute.
115
-
116
- The arguments are the same as for the Popen constructor. Example:
117
-
118
- retcode = call(["ls", "-l"])
119
-
120
-
121
-Exceptions
122
-----------
123
-Exceptions raised in the child process, before the new program has
124
-started to execute, will be re-raised in the parent. Additionally,
125
-the exception object will have one extra attribute called
126
-'child_traceback', which is a string containing traceback information
127
-from the childs point of view.
128
-
129
-The most common exception raised is OSError. This occurs, for
130
-example, when trying to execute a non-existent file. Applications
131
-should prepare for OSErrors.
132
-
133
-A ValueError will be raised if Popen is called with invalid arguments.
134
-
135
-
136
-Security
137
---------
138
-Unlike some other popen functions, this implementation will never call
139
-/bin/sh implicitly. This means that all characters, including shell
140
-metacharacters, can safely be passed to child processes.
141
-
142
-
143
-Popen objects
144
-=============
145
-Instances of the Popen class have the following methods:
146
-
147
-poll()
148
- Check if child process has terminated. Returns returncode
149
- attribute.
150
-
151
-wait()
152
- Wait for child process to terminate. Returns returncode attribute.
153
-
154
-communicate(input=None)
155
- Interact with process: Send data to stdin. Read data from stdout
156
- and stderr, until end-of-file is reached. Wait for process to
157
- terminate. The optional stdin argument should be a string to be
158
- sent to the child process, or None, if no data should be sent to
159
- the child.
160
-
161
- communicate() returns a tuple (stdout, stderr).
162
-
163
- Note: The data read is buffered in memory, so do not use this
164
- method if the data size is large or unlimited.
165
-
166
-The following attributes are also available:
167
-
168
-stdin
169
- If the stdin argument is PIPE, this attribute is a file object
170
- that provides input to the child process. Otherwise, it is None.
171
-
172
-stdout
173
- If the stdout argument is PIPE, this attribute is a file object
174
- that provides output from the child process. Otherwise, it is
175
- None.
176
-
177
-stderr
178
- If the stderr argument is PIPE, this attribute is file object that
179
- provides error output from the child process. Otherwise, it is
180
- None.
181
-
182
-pid
183
- The process ID of the child process.
184
-
185
-returncode
186
- The child return code. A None value indicates that the process
187
- hasn't terminated yet. A negative value -N indicates that the
188
- child was terminated by signal N (UNIX only).
189
-
190
-
191
-Replacing older functions with the subprocess module
192
-====================================================
193
-In this section, "a ==> b" means that b can be used as a replacement
194
-for a.
195
-
196
-Note: All functions in this section fail (more or less) silently if
197
-the executed program cannot be found; this module raises an OSError
198
-exception.
199
-
200
-In the following examples, we assume that the subprocess module is
201
-imported with "from subprocess import *".
202
-
203
-
204
-Replacing /bin/sh shell backquote
205
----------------------------------
206
-output=`mycmd myarg`
207
-==>
208
-output = Popen(["mycmd", "myarg"], stdout=PIPE).communicate()[0]
209
-
210
-
211
-Replacing shell pipe line
212
--------------------------
213
-output=`dmesg | grep hda`
214
-==>
215
-p1 = Popen(["dmesg"], stdout=PIPE)
216
-p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
217
-output = p2.communicate()[0]
218
-
219
-
220
-Replacing os.system()
221
----------------------
222
-sts = os.system("mycmd" + " myarg")
223
-==>
224
-p = Popen("mycmd" + " myarg", shell=True)
225
-sts = os.waitpid(p.pid, 0)
226
-
227
-Note:
228
-
229
-* Calling the program through the shell is usually not required.
230
-
231
-* It's easier to look at the returncode attribute than the
232
- exitstatus.
233
-
234
-A more real-world example would look like this:
235
-
236
-try:
237
- retcode = call("mycmd" + " myarg", shell=True)
238
- if retcode < 0:
239
- print >>sys.stderr, "Child was terminated by signal", -retcode
240
- else:
241
- print >>sys.stderr, "Child returned", retcode
242
-except OSError, e:
243
- print >>sys.stderr, "Execution failed:", e
244
-
245
-
246
-Replacing os.spawn*
247
--------------------
248
-P_NOWAIT example:
249
-
250
-pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg")
251
-==>
252
-pid = Popen(["/bin/mycmd", "myarg"]).pid
253
-
254
-
255
-P_WAIT example:
256
-
257
-retcode = os.spawnlp(os.P_WAIT, "/bin/mycmd", "mycmd", "myarg")
258
-==>
259
-retcode = call(["/bin/mycmd", "myarg"])
260
-
261
-
262
-Vector example:
263
-
264
-os.spawnvp(os.P_NOWAIT, path, args)
265
-==>
266
-Popen([path] + args[1:])
267
-
268
-
269
-Environment example:
270
-
271
-os.spawnlpe(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg", env)
272
-==>
273
-Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"})
274
-
275
-
276
-Replacing os.popen*
277
--------------------
278
-pipe = os.popen(cmd, mode='r', bufsize)
279
-==>
280
-pipe = Popen(cmd, shell=True, bufsize=bufsize, stdout=PIPE).stdout
281
-
282
-pipe = os.popen(cmd, mode='w', bufsize)
283
-==>
284
-pipe = Popen(cmd, shell=True, bufsize=bufsize, stdin=PIPE).stdin
285
-
286
-
287
-(child_stdin, child_stdout) = os.popen2(cmd, mode, bufsize)
288
-==>
289
-p = Popen(cmd, shell=True, bufsize=bufsize,
290
- stdin=PIPE, stdout=PIPE, close_fds=True)
291
-(child_stdin, child_stdout) = (p.stdin, p.stdout)
292
-
293
-
294
-(child_stdin,
295
- child_stdout,
296
- child_stderr) = os.popen3(cmd, mode, bufsize)
297
-==>
298
-p = Popen(cmd, shell=True, bufsize=bufsize,
299
- stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
300
-(child_stdin,
301
- child_stdout,
302
- child_stderr) = (p.stdin, p.stdout, p.stderr)
303
-
304
-
305
-(child_stdin, child_stdout_and_stderr) = os.popen4(cmd, mode, bufsize)
306
-==>
307
-p = Popen(cmd, shell=True, bufsize=bufsize,
308
- stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
309
-(child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout)
310
-
311
-
312
-Replacing popen2.*
313
-------------------
314
-Note: If the cmd argument to popen2 functions is a string, the command
315
-is executed through /bin/sh. If it is a list, the command is directly
316
-executed.
317
-
318
-(child_stdout, child_stdin) = popen2.popen2("somestring", bufsize, mode)
319
-==>
320
-p = Popen(["somestring"], shell=True, bufsize=bufsize
321
- stdin=PIPE, stdout=PIPE, close_fds=True)
322
-(child_stdout, child_stdin) = (p.stdout, p.stdin)
323
-
324
-
325
-(child_stdout, child_stdin) = popen2.popen2(["mycmd", "myarg"], bufsize, mode)
326
-==>
327
-p = Popen(["mycmd", "myarg"], bufsize=bufsize,
328
- stdin=PIPE, stdout=PIPE, close_fds=True)
329
-(child_stdout, child_stdin) = (p.stdout, p.stdin)
330
-
331
-The popen2.Popen3 and popen3.Popen4 basically works as subprocess.Popen,
332
-except that:
333
-
334
-* subprocess.Popen raises an exception if the execution fails
335
-* the capturestderr argument is replaced with the stderr argument.
336
-* stdin=PIPE and stdout=PIPE must be specified.
337
-* popen2 closes all filedescriptors by default, but you have to specify
338
- close_fds=True with subprocess.Popen.
339
-
340
-
341
-"""
342
-
343
-import sys
344
-mswindows = (sys.platform == "win32")
345
-
346
-import os
347
-import types
348
-import traceback
349
-
350
-if mswindows:
351
- import threading
352
- import msvcrt
353
- if 0: # <-- change this to use pywin32 instead of the _subprocess driver
354
- import pywintypes
355
- from win32api import GetStdHandle, STD_INPUT_HANDLE, \
356
- STD_OUTPUT_HANDLE, STD_ERROR_HANDLE
357
- from win32api import GetCurrentProcess, DuplicateHandle, \
358
- GetModuleFileName, GetVersion
359
- from win32con import DUPLICATE_SAME_ACCESS, SW_HIDE
360
- from win32pipe import CreatePipe
361
- from win32process import CreateProcess, STARTUPINFO, \
362
- GetExitCodeProcess, STARTF_USESTDHANDLES, \
363
- STARTF_USESHOWWINDOW, CREATE_NEW_CONSOLE
364
- from win32event import WaitForSingleObject, INFINITE, WAIT_OBJECT_0
365
- else:
366
- from _subprocess import *
367
- class STARTUPINFO:
368
- dwFlags = 0
369
- hStdInput = None
370
- hStdOutput = None
371
- hStdError = None
372
- class pywintypes:
373
- error = IOError
374
-else:
375
- import select
376
- import errno
377
- import fcntl
378
- import pickle
379
-
380
-__all__ = ["Popen", "PIPE", "STDOUT", "call"]
381
-
382
-try:
383
- MAXFD = os.sysconf("SC_OPEN_MAX")
384
-except:
385
- MAXFD = 256
386
-
387
-# True/False does not exist on 2.2.0
388
-try:
389
- False
390
-except NameError:
391
- False = 0
392
- True = 1
393
-
394
-_active = []
395
-
396
-def _cleanup():
397
- for inst in _active[:]:
398
- inst.poll()
399
-
400
-PIPE = -1
401
-STDOUT = -2
402
-
403
-
404
-def call(*args, **kwargs):
405
- """Run command with arguments. Wait for command to complete, then
406
- return the returncode attribute.
407
-
408
- The arguments are the same as for the Popen constructor. Example:
409
-
410
- retcode = call(["ls", "-l"])
411
- """
412
- return Popen(*args, **kwargs).wait()
413
-
414
-
415
-def list2cmdline(seq):
416
- """
417
- Translate a sequence of arguments into a command line
418
- string, using the same rules as the MS C runtime:
419
-
420
- 1) Arguments are delimited by white space, which is either a
421
- space or a tab.
422
-
423
- 2) A string surrounded by double quotation marks is
424
- interpreted as a single argument, regardless of white space
425
- contained within. A quoted string can be embedded in an
426
- argument.
427
-
428
- 3) A double quotation mark preceded by a backslash is
429
- interpreted as a literal double quotation mark.
430
-
431
- 4) Backslashes are interpreted literally, unless they
432
- immediately precede a double quotation mark.
433
-
434
- 5) If backslashes immediately precede a double quotation mark,
435
- every pair of backslashes is interpreted as a literal
436
- backslash. If the number of backslashes is odd, the last
437
- backslash escapes the next double quotation mark as
438
- described in rule 3.
439
- """
440
-
441
- # See
442
- # http://msdn.microsoft.com/library/en-us/vccelng/htm/progs_12.asp
443
- result = []
444
- needquote = False
445
- for arg in seq:
446
- bs_buf = []
447
-
448
- # Add a space to separate this argument from the others
449
- if result:
450
- result.append(' ')
451
-
452
- needquote = (" " in arg) or ("\t" in arg)
453
- if needquote:
454
- result.append('"')
455
-
456
- for c in arg:
457
- if c == '\\':
458
- # Don't know if we need to double yet.
459
- bs_buf.append(c)
460
- elif c == '"':
461
- # Double backspaces.
462
- result.append('\\' * len(bs_buf)*2)
463
- bs_buf = []
464
- result.append('\\"')
465
- else:
466
- # Normal char
467
- if bs_buf:
468
- result.extend(bs_buf)
469
- bs_buf = []
470
- result.append(c)
471
-
472
- # Add remaining backspaces, if any.
473
- if bs_buf:
474
- result.extend(bs_buf)
475
-
476
- if needquote:
477
- result.extend(bs_buf)
478
- result.append('"')
479
-
480
- return ''.join(result)
481
-
482
-
483
-class Popen(object):
484
- def __init__(self, args, bufsize=0, executable=None,
485
- stdin=None, stdout=None, stderr=None,
486
- preexec_fn=None, close_fds=False, shell=False,
487
- cwd=None, env=None, universal_newlines=False,
488
- startupinfo=None, creationflags=0):
489
- """Create new Popen instance."""
490
- _cleanup()
491
-
492
- if not isinstance(bufsize, (int, long)):
493
- raise TypeError("bufsize must be an integer")
494
-
495
- if mswindows:
496
- if preexec_fn is not None:
497
- raise ValueError("preexec_fn is not supported on Windows "
498
- "platforms")
499
- if close_fds:
500
- raise ValueError("close_fds is not supported on Windows "
501
- "platforms")
502
- else:
503
- # POSIX
504
- if startupinfo is not None:
505
- raise ValueError("startupinfo is only supported on Windows "
506
- "platforms")
507
- if creationflags != 0:
508
- raise ValueError("creationflags is only supported on Windows "
509
- "platforms")
510
-
511
- self.stdin = None
512
- self.stdout = None
513
- self.stderr = None
514
- self.pid = None
515
- self.returncode = None
516
- self.universal_newlines = universal_newlines
517
-
518
- # Input and output objects. The general principle is like
519
- # this:
520
- #
521
- # Parent Child
522
- # ------ -----
523
- # p2cwrite ---stdin---> p2cread
524
- # c2pread <--stdout--- c2pwrite
525
- # errread <--stderr--- errwrite
526
- #
527
- # On POSIX, the child objects are file descriptors. On
528
- # Windows, these are Windows file handles. The parent objects
529
- # are file descriptors on both platforms. The parent objects
530
- # are None when not using PIPEs. The child objects are None
531
- # when not redirecting.
532
-
533
- (p2cread, p2cwrite,
534
- c2pread, c2pwrite,
535
- errread, errwrite) = self._get_handles(stdin, stdout, stderr)
536
-
537
- self._execute_child(args, executable, preexec_fn, close_fds,
538
- cwd, env, universal_newlines,
539
- startupinfo, creationflags, shell,
540
- p2cread, p2cwrite,
541
- c2pread, c2pwrite,
542
- errread, errwrite)
543
-
544
- if p2cwrite:
545
- self.stdin = os.fdopen(p2cwrite, 'wb', bufsize)
546
- if c2pread:
547
- if universal_newlines:
548
- self.stdout = os.fdopen(c2pread, 'rU', bufsize)
549
- else:
550
- self.stdout = os.fdopen(c2pread, 'rb', bufsize)
551
- if errread:
552
- if universal_newlines:
553
- self.stderr = os.fdopen(errread, 'rU', bufsize)
554
- else:
555
- self.stderr = os.fdopen(errread, 'rb', bufsize)
556
-
557
- _active.append(self)
558
-
559
-
560
- def _translate_newlines(self, data):
561
- data = data.replace("\r\n", "\n")
562
- data = data.replace("\r", "\n")
563
- return data
564
-
565
-
566
- if mswindows:
567
- #
568
- # Windows methods
569
- #
570
- def _get_handles(self, stdin, stdout, stderr):
571
- """Construct and return tuple with IO objects:
572
- p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
573
- """
574
- if stdin == None and stdout == None and stderr == None:
575
- return (None, None, None, None, None, None)
576
-
577
- p2cread, p2cwrite = None, None
578
- c2pread, c2pwrite = None, None
579
- errread, errwrite = None, None
580
-
581
- if stdin == None:
582
- p2cread = GetStdHandle(STD_INPUT_HANDLE)
583
- elif stdin == PIPE:
584
- p2cread, p2cwrite = CreatePipe(None, 0)
585
- # Detach and turn into fd
586
- p2cwrite = p2cwrite.Detach()
587
- p2cwrite = msvcrt.open_osfhandle(p2cwrite, 0)
588
- elif type(stdin) == types.IntType:
589
- p2cread = msvcrt.get_osfhandle(stdin)
590
- else:
591
- # Assuming file-like object
592
- p2cread = msvcrt.get_osfhandle(stdin.fileno())
593
- p2cread = self._make_inheritable(p2cread)
594
-
595
- if stdout == None:
596
- c2pwrite = GetStdHandle(STD_OUTPUT_HANDLE)
597
- elif stdout == PIPE:
598
- c2pread, c2pwrite = CreatePipe(None, 0)
599
- # Detach and turn into fd
600
- c2pread = c2pread.Detach()
601
- c2pread = msvcrt.open_osfhandle(c2pread, 0)
602
- elif type(stdout) == types.IntType:
603
- c2pwrite = msvcrt.get_osfhandle(stdout)
604
- else:
605
- # Assuming file-like object
606
- c2pwrite = msvcrt.get_osfhandle(stdout.fileno())
607
- c2pwrite = self._make_inheritable(c2pwrite)
608
-
609
- if stderr == None:
610
- errwrite = GetStdHandle(STD_ERROR_HANDLE)
611
- elif stderr == PIPE:
612
- errread, errwrite = CreatePipe(None, 0)
613
- # Detach and turn into fd
614
- errread = errread.Detach()
615
- errread = msvcrt.open_osfhandle(errread, 0)
616
- elif stderr == STDOUT:
617
- errwrite = c2pwrite
618
- elif type(stderr) == types.IntType:
619
- errwrite = msvcrt.get_osfhandle(stderr)
620
- else:
621
- # Assuming file-like object
622
- errwrite = msvcrt.get_osfhandle(stderr.fileno())
623
- errwrite = self._make_inheritable(errwrite)
624
-
625
- return (p2cread, p2cwrite,
626
- c2pread, c2pwrite,
627
- errread, errwrite)
628
-
629
-
630
- def _make_inheritable(self, handle):
631
- """Return a duplicate of handle, which is inheritable"""
632
- return DuplicateHandle(GetCurrentProcess(), handle,
633
- GetCurrentProcess(), 0, 1,
634
- DUPLICATE_SAME_ACCESS)
635
-
636
-
637
- def _find_w9xpopen(self):
638
- """Find and return absolute path to w9xpopen.exe"""
639
- w9xpopen = os.path.join(os.path.dirname(GetModuleFileName(0)),
640
- "w9xpopen.exe")
641
- if not os.path.exists(w9xpopen):
642
- # Eeek - file-not-found - possibly an embedding
643
- # situation - see if we can locate it in sys.exec_prefix
644
- w9xpopen = os.path.join(os.path.dirname(sys.exec_prefix),
645
- "w9xpopen.exe")
646
- if not os.path.exists(w9xpopen):
647
- raise RuntimeError("Cannot locate w9xpopen.exe, which is "
648
- "needed for Popen to work with your "
649
- "shell or platform.")
650
- return w9xpopen
651
-
652
-
653
- def _execute_child(self, args, executable, preexec_fn, close_fds,
654
- cwd, env, universal_newlines,
655
- startupinfo, creationflags, shell,
656
- p2cread, p2cwrite,
657
- c2pread, c2pwrite,
658
- errread, errwrite):
659
- """Execute program (MS Windows version)"""
660
-
661
- if not isinstance(args, types.StringTypes):
662
- args = list2cmdline(args)
663
-
664
- # Process startup details
665
- default_startupinfo = STARTUPINFO()
666
- if startupinfo == None:
667
- startupinfo = default_startupinfo
668
- if not None in (p2cread, c2pwrite, errwrite):
669
- startupinfo.dwFlags |= STARTF_USESTDHANDLES
670
- startupinfo.hStdInput = p2cread
671
- startupinfo.hStdOutput = c2pwrite
672
- startupinfo.hStdError = errwrite
673
-
674
- if shell:
675
- default_startupinfo.dwFlags |= STARTF_USESHOWWINDOW
676
- default_startupinfo.wShowWindow = SW_HIDE
677
- comspec = os.environ.get("COMSPEC", "cmd.exe")
678
- args = comspec + " /c " + args
679
- if (GetVersion() >= 0x80000000L or
680
- os.path.basename(comspec).lower() == "command.com"):
681
- # Win9x, or using command.com on NT. We need to
682
- # use the w9xpopen intermediate program. For more
683
- # information, see KB Q150956
684
- # (http://web.archive.org/web/20011105084002/http://support.microsoft.com/support/kb/articles/Q150/9/56.asp)
685
- w9xpopen = self._find_w9xpopen()
686
- args = '"%s" %s' % (w9xpopen, args)
687
- # Not passing CREATE_NEW_CONSOLE has been known to
688
- # cause random failures on win9x. Specifically a
689
- # dialog: "Your program accessed mem currently in
690
- # use at xxx" and a hopeful warning about the
691
- # stability of your system. Cost is Ctrl+C wont
692
- # kill children.
693
- creationflags |= CREATE_NEW_CONSOLE
694
-
695
- # Start the process
696
- try:
697
- hp, ht, pid, tid = CreateProcess(executable, args,
698
- # no special security
699
- None, None,
700
- # must inherit handles to pass std
701
- # handles
702
- 1,
703
- creationflags,
704
- env,
705
- cwd,
706
- startupinfo)
707
- except pywintypes.error, e:
708
- # Translate pywintypes.error to WindowsError, which is
709
- # a subclass of OSError. FIXME: We should really
710
- # translate errno using _sys_errlist (or simliar), but
711
- # how can this be done from Python?
712
- raise WindowsError(*e.args)
713
-
714
- # Retain the process handle, but close the thread handle
715
- self._handle = hp
716
- self.pid = pid
717
- ht.Close()
718
-
719
- # Child is launched. Close the parent's copy of those pipe
720
- # handles that only the child should have open. You need
721
- # to make sure that no handles to the write end of the
722
- # output pipe are maintained in this process or else the
723
- # pipe will not close when the child process exits and the
724
- # ReadFile will hang.
725
- if p2cread != None:
726
- p2cread.Close()
727
- if c2pwrite != None:
728
- c2pwrite.Close()
729
- if errwrite != None:
730
- errwrite.Close()
731
-
732
-
733
- def poll(self):
734
- """Check if child process has terminated. Returns returncode
735
- attribute."""
736
- if self.returncode == None:
737
- if WaitForSingleObject(self._handle, 0) == WAIT_OBJECT_0:
738
- self.returncode = GetExitCodeProcess(self._handle)
739
- _active.remove(self)
740
- return self.returncode
741
-
742
-
743
- def wait(self):
744
- """Wait for child process to terminate. Returns returncode
745
- attribute."""
746
- if self.returncode == None:
747
- obj = WaitForSingleObject(self._handle, INFINITE)
748
- self.returncode = GetExitCodeProcess(self._handle)
749
- _active.remove(self)
750
- return self.returncode
751
-
752
-
753
- def _readerthread(self, fh, buffer):
754
- buffer.append(fh.read())
755
-
756
-
757
- def communicate(self, input=None):
758
- """Interact with process: Send data to stdin. Read data from
759
- stdout and stderr, until end-of-file is reached. Wait for
760
- process to terminate. The optional input argument should be a
761
- string to be sent to the child process, or None, if no data
762
- should be sent to the child.
763
-
764
- communicate() returns a tuple (stdout, stderr)."""
765
- stdout = None # Return
766
- stderr = None # Return
767
-
768
- if self.stdout:
769
- stdout = []
770
- stdout_thread = threading.Thread(target=self._readerthread,
771
- args=(self.stdout, stdout))
772
- stdout_thread.setDaemon(True)
773
- stdout_thread.start()
774
- if self.stderr:
775
- stderr = []
776
- stderr_thread = threading.Thread(target=self._readerthread,
777
- args=(self.stderr, stderr))
778
- stderr_thread.setDaemon(True)
779
- stderr_thread.start()
780
-
781
- if self.stdin:
782
- if input != None:
783
- self.stdin.write(input)
784
- self.stdin.close()
785
-
786
- if self.stdout:
787
- stdout_thread.join()
788
- if self.stderr:
789
- stderr_thread.join()
790
-
791
- # All data exchanged. Translate lists into strings.
792
- if stdout != None:
793
- stdout = stdout[0]
794
- if stderr != None:
795
- stderr = stderr[0]
796
-
797
- # Translate newlines, if requested. We cannot let the file
798
- # object do the translation: It is based on stdio, which is
799
- # impossible to combine with select (unless forcing no
800
- # buffering).
801
- if self.universal_newlines and hasattr(open, 'newlines'):
802
- if stdout:
803
- stdout = self._translate_newlines(stdout)
804
- if stderr:
805
- stderr = self._translate_newlines(stderr)
806
-
807
- self.wait()
808
- return (stdout, stderr)
809
-
810
- else:
811
- #
812
- # POSIX methods
813
- #
814
- def _get_handles(self, stdin, stdout, stderr):
815
- """Construct and return tuple with IO objects:
816
- p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
817
- """
818
- p2cread, p2cwrite = None, None
819
- c2pread, c2pwrite = None, None
820
- errread, errwrite = None, None
821
-
822
- if stdin == None:
823
- pass
824
- elif stdin == PIPE:
825
- p2cread, p2cwrite = os.pipe()
826
- elif type(stdin) == types.IntType:
827
- p2cread = stdin
828
- else:
829
- # Assuming file-like object
830
- p2cread = stdin.fileno()
831
-
832
- if stdout == None:
833
- pass
834
- elif stdout == PIPE:
835
- c2pread, c2pwrite = os.pipe()
836
- elif type(stdout) == types.IntType:
837
- c2pwrite = stdout
838
- else:
839
- # Assuming file-like object
840
- c2pwrite = stdout.fileno()
841
-
842
- if stderr == None:
843
- pass
844
- elif stderr == PIPE:
845
- errread, errwrite = os.pipe()
846
- elif stderr == STDOUT:
847
- errwrite = c2pwrite
848
- elif type(stderr) == types.IntType:
849
- errwrite = stderr
850
- else:
851
- # Assuming file-like object
852
- errwrite = stderr.fileno()
853
-
854
- return (p2cread, p2cwrite,
855
- c2pread, c2pwrite,
856
- errread, errwrite)
857
-
858
-
859
- def _set_cloexec_flag(self, fd):
860
- try:
861
- cloexec_flag = fcntl.FD_CLOEXEC
862
- except AttributeError:
863
- cloexec_flag = 1
864
-
865
- old = fcntl.fcntl(fd, fcntl.F_GETFD)
866
- fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag)
867
-
868
-
869
- def _close_fds(self, but):
870
- for i in range(3, MAXFD):
871
- if i == but:
872
- continue
873
- try:
874
- os.close(i)
875
- except:
876
- pass
877
-
878
-
879
- def _execute_child(self, args, executable, preexec_fn, close_fds,
880
- cwd, env, universal_newlines,
881
- startupinfo, creationflags, shell,
882
- p2cread, p2cwrite,
883
- c2pread, c2pwrite,
884
- errread, errwrite):
885
- """Execute program (POSIX version)"""
886
-
887
- if isinstance(args, types.StringTypes):
888
- args = [args]
889
-
890
- if shell:
891
- args = ["/bin/sh", "-c"] + args
892
-
893
- if executable == None:
894
- executable = args[0]
895
-
896
- # For transferring possible exec failure from child to parent
897
- # The first char specifies the exception type: 0 means
898
- # OSError, 1 means some other error.
899
- errpipe_read, errpipe_write = os.pipe()
900
- self._set_cloexec_flag(errpipe_write)
901
-
902
- self.pid = os.fork()
903
- if self.pid == 0:
904
- # Child
905
- try:
906
- # Close parent's pipe ends
907
- if p2cwrite:
908
- os.close(p2cwrite)
909
- if c2pread:
910
- os.close(c2pread)
911
- if errread:
912
- os.close(errread)
913
- os.close(errpipe_read)
914
-
915
- # Dup fds for child
916
- if p2cread:
917
- os.dup2(p2cread, 0)
918
- if c2pwrite:
919
- os.dup2(c2pwrite, 1)
920
- if errwrite:
921
- os.dup2(errwrite, 2)
922
-
923
- # Close pipe fds. Make sure we doesn't close the same
924
- # fd more than once.
925
- if p2cread:
926
- os.close(p2cread)
927
- if c2pwrite and c2pwrite not in (p2cread,):
928
- os.close(c2pwrite)
929
- if errwrite and errwrite not in (p2cread, c2pwrite):
930
- os.close(errwrite)
931
-
932
- # Close all other fds, if asked for
933
- if close_fds:
934
- self._close_fds(but=errpipe_write)
935
-
936
- if cwd != None:
937
- os.chdir(cwd)
938
-
939
- if preexec_fn:
940
- apply(preexec_fn)
941
-
942
- if env == None:
943
- os.execvp(executable, args)
944
- else:
945
- os.execvpe(executable, args, env)
946
-
947
- except:
948
- exc_type, exc_value, tb = sys.exc_info()
949
- # Save the traceback and attach it to the exception object
950
- exc_lines = traceback.format_exception(exc_type,
951
- exc_value,
952
- tb)
953
- exc_value.child_traceback = ''.join(exc_lines)
954
- os.write(errpipe_write, pickle.dumps(exc_value))
955
-
956
- # This exitcode won't be reported to applications, so it
957
- # really doesn't matter what we return.
958
- os._exit(255)
959
-
960
- # Parent
961
- os.close(errpipe_write)
962
- if p2cread and p2cwrite:
963
- os.close(p2cread)
964
- if c2pwrite and c2pread:
965
- os.close(c2pwrite)
966
- if errwrite and errread:
967
- os.close(errwrite)
968
-
969
- # Wait for exec to fail or succeed; possibly raising exception
970
- data = os.read(errpipe_read, 1048576) # Exceptions limited to 1 MB
971
- os.close(errpipe_read)
972
- if data != "":
973
- os.waitpid(self.pid, 0)
974
- child_exception = pickle.loads(data)
975
- raise child_exception
976
-
977
-
978
- def _handle_exitstatus(self, sts):
979
- if os.WIFSIGNALED(sts):
980
- self.returncode = -os.WTERMSIG(sts)
981
- elif os.WIFEXITED(sts):
982
- self.returncode = os.WEXITSTATUS(sts)
983
- else:
984
- # Should never happen
985
- raise RuntimeError("Unknown child exit status!")
986
-
987
- _active.remove(self)
988
-
989
-
990
- def poll(self):
991
- """Check if child process has terminated. Returns returncode
992
- attribute."""
993
- if self.returncode == None:
994
- try:
995
- pid, sts = os.waitpid(self.pid, os.WNOHANG)
996
- if pid == self.pid:
997
- self._handle_exitstatus(sts)
998
- except os.error:
999
- pass
1000
- return self.returncode
1001
-
1002
-
1003
- def wait(self):
1004
- """Wait for child process to terminate. Returns returncode
1005
- attribute."""
1006
- if self.returncode == None:
1007
- pid, sts = os.waitpid(self.pid, 0)
1008
- self._handle_exitstatus(sts)
1009
- return self.returncode
1010
-
1011
-
1012
- def communicate(self, input=None):
1013
- """Interact with process: Send data to stdin. Read data from
1014
- stdout and stderr, until end-of-file is reached. Wait for
1015
- process to terminate. The optional input argument should be a
1016
- string to be sent to the child process, or None, if no data
1017
- should be sent to the child.
1018
-
1019
- communicate() returns a tuple (stdout, stderr)."""
1020
- read_set = []
1021
- write_set = []
1022
- stdout = None # Return
1023
- stderr = None # Return
1024
-
1025
- if self.stdin:
1026
- # Flush stdio buffer. This might block, if the user has
1027
- # been writing to .stdin in an uncontrolled fashion.
1028
- self.stdin.flush()
1029
- if input:
1030
- write_set.append(self.stdin)
1031
- else:
1032
- self.stdin.close()
1033
- if self.stdout:
1034
- read_set.append(self.stdout)
1035
- stdout = []
1036
- if self.stderr:
1037
- read_set.append(self.stderr)
1038
- stderr = []
1039
-
1040
- while read_set or write_set:
1041
- rlist, wlist, xlist = select.select(read_set, write_set, [])
1042
-
1043
- if self.stdin in wlist:
1044
- # When select has indicated that the file is writable,
1045
- # we can write up to PIPE_BUF bytes without risk
1046
- # blocking. POSIX defines PIPE_BUF >= 512
1047
- bytes_written = os.write(self.stdin.fileno(), input[:512])
1048
- input = input[bytes_written:]
1049
- if not input:
1050
- self.stdin.close()
1051
- write_set.remove(self.stdin)
1052
-
1053
- if self.stdout in rlist:
1054
- data = os.read(self.stdout.fileno(), 1024)
1055
- if data == "":
1056
- self.stdout.close()
1057
- read_set.remove(self.stdout)
1058
- stdout.append(data)
1059
-
1060
- if self.stderr in rlist:
1061
- data = os.read(self.stderr.fileno(), 1024)
1062
- if data == "":
1063
- self.stderr.close()
1064
- read_set.remove(self.stderr)
1065
- stderr.append(data)
1066
-
1067
- # All data exchanged. Translate lists into strings.
1068
- if stdout != None:
1069
- stdout = ''.join(stdout)
1070
- if stderr != None:
1071
- stderr = ''.join(stderr)
1072
-
1073
- # Translate newlines, if requested. We cannot let the file
1074
- # object do the translation: It is based on stdio, which is
1075
- # impossible to combine with select (unless forcing no
1076
- # buffering).
1077
- if self.universal_newlines and hasattr(open, 'newlines'):
1078
- if stdout:
1079
- stdout = self._translate_newlines(stdout)
1080
- if stderr:
1081
- stderr = self._translate_newlines(stderr)
1082
-
1083
- self.wait()
1084
- return (stdout, stderr)
1085
-
1086
-
1087
-def _demo_posix():
1088
- #
1089
- # Example 1: Simple redirection: Get process list
1090
- #
1091
- plist = Popen(["ps"], stdout=PIPE).communicate()[0]
1092
- print "Process list:"
1093
- print plist
1094
-
1095
- #
1096
- # Example 2: Change uid before executing child
1097
- #
1098
- if os.getuid() == 0:
1099
- p = Popen(["id"], preexec_fn=lambda: os.setuid(100))
1100
- p.wait()
1101
-
1102
- #
1103
- # Example 3: Connecting several subprocesses
1104
- #
1105
- print "Looking for 'hda'..."
1106
- p1 = Popen(["dmesg"], stdout=PIPE)
1107
- p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
1108
- print repr(p2.communicate()[0])
1109
-
1110
- #
1111
- # Example 4: Catch execution error
1112
- #
1113
- print
1114
- print "Trying a weird file..."
1115
- try:
1116
- print Popen(["/this/path/does/not/exist"]).communicate()
1117
- except OSError, e:
1118
- if e.errno == errno.ENOENT:
1119
- print "The file didn't exist. I thought so..."
1120
- print "Child traceback:"
1121
- print e.child_traceback
1122
- else:
1123
- print "Error", e.errno
1124
- else:
1125
- print >>sys.stderr, "Gosh. No error."
1126
-
1127
-
1128
-def _demo_windows():
1129
- #
1130
- # Example 1: Connecting several subprocesses
1131
- #
1132
- print "Looking for 'PROMPT' in set output..."
1133
- p1 = Popen("set", stdout=PIPE, shell=True)
1134
- p2 = Popen('find "PROMPT"', stdin=p1.stdout, stdout=PIPE)
1135
- print repr(p2.communicate()[0])
1136
-
1137
- #
1138
- # Example 2: Simple execution of program
1139
- #
1140
- print "Executing calc..."
1141
- p = Popen("calc")
1142
- p.wait()
1143
-
1144
-
1145
-if __name__ == "__main__":
1146
- if mswindows:
1147
- _demo_windows()
1148
- else:
1149
- _demo_posix()
config.mak.in
-2
@@ -13,7 +13,6 @@ bindir = @bindir@
13
#gitexecdir = @libexecdir@/git-core/
14
datarootdir = @datarootdir@
15
template_dir = @datadir@/git-core/templates/
16
-GIT_PYTHON_DIR = @datadir@/git-core/python
16
17
mandir=@mandir@
18
@@ -23,7 +22,6 @@ VPATH = @srcdir@
22
export exec_prefix mandir
23
export srcdir VPATH
24
26
-NO_PYTHON=@NO_PYTHON@
25
NEEDS_SSL_WITH_CRYPTO=@NEEDS_SSL_WITH_CRYPTO@
26
NO_OPENSSL=@NO_OPENSSL@
27
NO_CURL=@NO_CURL@
configure.ac
-39
@@ -75,20 +75,6 @@ GIT_ARG_SET_PATH(shell)
75
# Define PERL_PATH to provide path to Perl.
76
GIT_ARG_SET_PATH(perl)
77
#
78
-# Define PYTHON_PATH to provide path to Python.
79
-AC_ARG_WITH(python,[AS_HELP_STRING([--with-python=PATH], [provide PATH to python])
80
-AS_HELP_STRING([--without-python], [don't use python scripts])],
81
- [if test "$withval" = "no"; then \
82
- NO_PYTHON=YesPlease; \
83
- elif test "$withval" = "yes"; then \
84
- NO_PYTHON=; \
85
- else \
86
- NO_PYTHON=; \
87
- PYTHON_PATH=$withval; \
88
- fi; \
89
- ])
90
-AC_SUBST(NO_PYTHON)
91
-AC_SUBST(PYTHON_PATH)
78
79
80
## Checks for programs.
@@ -98,18 +84,6 @@ AC_PROG_CC([cc gcc])
84
#AC_PROG_INSTALL # needs install-sh or install.sh in sources
85
AC_CHECK_TOOL(AR, ar, :)
86
AC_CHECK_PROGS(TAR, [gtar tar])
101
-#
102
-# Define PYTHON_PATH to provide path to Python.
103
-if test -z "$NO_PYTHON"; then
104
- if test -z "$PYTHON_PATH"; then
105
- AC_PATH_PROGS(PYTHON_PATH, [python python2.4 python2.3 python2])
106
- fi
107
- if test -n "$PYTHON_PATH"; then
108
- GIT_CONF_APPEND_LINE([PYTHON_PATH=@PYTHON_PATH@])
109
- NO_PYTHON=""
110
- fi
111
-fi
112
-
87
88
## Checks for libraries.
89
AC_MSG_NOTICE([CHECKS for libraries])
@@ -262,22 +236,9 @@ AC_SUBST(NO_SETENV)
236
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
237
# Enable it on Windows. By default, symrefs are still used.
238
#
265
-# Define WITH_OWN_SUBPROCESS_PY if you want to use with python 2.3.
266
-AC_CACHE_CHECK([for subprocess.py],
267
- [ac_cv_python_has_subprocess_py],
268
-[if $PYTHON_PATH -c 'import subprocess' 2>/dev/null; then
269
- ac_cv_python_has_subprocess_py=yes
270
-else
271
- ac_cv_python_has_subprocess_py=no
272
-fi])
273
-if test $ac_cv_python_has_subprocess_py != yes; then
274
- GIT_CONF_APPEND_LINE([WITH_OWN_SUBPROCESS_PY=YesPlease])
275
-fi
276
-#
239
# Define NO_ACCURATE_DIFF if your diff program at least sometimes misses
240
# a missing newline at the end of the file.
241
280
-
242
## Site configuration (override autodetection)
243
## --with-PACKAGE[=ARG] and --without-PACKAGE
244
AC_MSG_NOTICE([CHECKS for site configuration])
git-merge-recursive-old.py
deleted
-944
@@ -1,944 +0,0 @@
1
-#!/usr/bin/python
2
-#
3
-# Copyright (C) 2005 Fredrik Kuivinen
4
-#
5
-
6
-import sys
7
-sys.path.append('''@@GIT_PYTHON_PATH@@''')
8
-
9
-import math, random, os, re, signal, tempfile, stat, errno, traceback
10
-from heapq import heappush, heappop
11
-from sets import Set
12
-
13
-from gitMergeCommon import *
14
-
15
-outputIndent = 0
16
-def output(*args):
17
- sys.stdout.write(' '*outputIndent)
18
- printList(args)
19
-
20
-originalIndexFile = os.environ.get('GIT_INDEX_FILE',
21
- os.environ.get('GIT_DIR', '.git') + '/index')
22
-temporaryIndexFile = os.environ.get('GIT_DIR', '.git') + \
23
- '/merge-recursive-tmp-index'
24
-def setupIndex(temporary):
25
- try:
26
- os.unlink(temporaryIndexFile)
27
- except OSError:
28
- pass
29
- if temporary:
30
- newIndex = temporaryIndexFile
31
- else:
32
- newIndex = originalIndexFile
33
- os.environ['GIT_INDEX_FILE'] = newIndex
34
-
35
-# This is a global variable which is used in a number of places but
36
-# only written to in the 'merge' function.
37
-
38
-# cacheOnly == True => Don't leave any non-stage 0 entries in the cache and
39
-# don't update the working directory.
40
-# False => Leave unmerged entries in the cache and update
41
-# the working directory.
42
-
43
-cacheOnly = False
44
-
45
-# The entry point to the merge code
46
-# ---------------------------------
47
-
48
-def merge(h1, h2, branch1Name, branch2Name, graph, callDepth=0, ancestor=None):
49
- '''Merge the commits h1 and h2, return the resulting virtual
50
- commit object and a flag indicating the cleanness of the merge.'''
51
- assert(isinstance(h1, Commit) and isinstance(h2, Commit))
52
-
53
- global outputIndent
54
-
55
- output('Merging:')
56
- output(h1)
57
- output(h2)
58
- sys.stdout.flush()
59
-
60
- if ancestor:
61
- ca = [ancestor]
62
- else:
63
- assert(isinstance(graph, Graph))
64
- ca = getCommonAncestors(graph, h1, h2)
65
- output('found', len(ca), 'common ancestor(s):')
66
- for x in ca:
67
- output(x)
68
- sys.stdout.flush()
69
-
70
- mergedCA = ca[0]
71
- for h in ca[1:]:
72
- outputIndent = callDepth+1
73
- [mergedCA, dummy] = merge(mergedCA, h,
74
- 'Temporary merge branch 1',
75
- 'Temporary merge branch 2',
76
- graph, callDepth+1)
77
- outputIndent = callDepth
78
- assert(isinstance(mergedCA, Commit))
79
-
80
- global cacheOnly
81
- if callDepth == 0:
82
- setupIndex(False)
83
- cacheOnly = False
84
- else:
85
- setupIndex(True)
86
- runProgram(['git-read-tree', h1.tree()])
87
- cacheOnly = True
88
-
89
- [shaRes, clean] = mergeTrees(h1.tree(), h2.tree(), mergedCA.tree(),
90
- branch1Name, branch2Name)
91
-
92
- if graph and (clean or cacheOnly):
93
- res = Commit(None, [h1, h2], tree=shaRes)
94
- graph.addNode(res)
95
- else:
96
- res = None
97
-
98
- return [res, clean]
99
-
100
-getFilesRE = re.compile(r'^([0-7]+) (\S+) ([0-9a-f]{40})\t(.*)$', re.S)
101
-def getFilesAndDirs(tree):
102
- files = Set()
103
- dirs = Set()
104
- out = runProgram(['git-ls-tree', '-r', '-z', '-t', tree])
105
- for l in out.split('\0'):
106
- m = getFilesRE.match(l)
107
- if m:
108
- if m.group(2) == 'tree':
109
- dirs.add(m.group(4))
110
- elif m.group(2) == 'blob':
111
- files.add(m.group(4))
112
-
113
- return [files, dirs]
114
-
115
-# Those two global variables are used in a number of places but only
116
-# written to in 'mergeTrees' and 'uniquePath'. They keep track of
117
-# every file and directory in the two branches that are about to be
118
-# merged.
119
-currentFileSet = None
120
-currentDirectorySet = None
121
-
122
-def mergeTrees(head, merge, common, branch1Name, branch2Name):
123
- '''Merge the trees 'head' and 'merge' with the common ancestor
124
- 'common'. The name of the head branch is 'branch1Name' and the name of
125
- the merge branch is 'branch2Name'. Return a tuple (tree, cleanMerge)
126
- where tree is the resulting tree and cleanMerge is True iff the
127
- merge was clean.'''
128
-
129
- assert(isSha(head) and isSha(merge) and isSha(common))
130
-
131
- if common == merge:
132
- output('Already uptodate!')
133
- return [head, True]
134
-
135
- if cacheOnly:
136
- updateArg = '-i'
137
- else:
138
- updateArg = '-u'
139
-
140
- [out, code] = runProgram(['git-read-tree', updateArg, '-m',
141
- common, head, merge], returnCode = True)
142
- if code != 0:
143
- die('git-read-tree:', out)
144
-
145
- [tree, code] = runProgram('git-write-tree', returnCode=True)
146
- tree = tree.rstrip()
147
- if code != 0:
148
- global currentFileSet, currentDirectorySet
149
- [currentFileSet, currentDirectorySet] = getFilesAndDirs(head)
150
- [filesM, dirsM] = getFilesAndDirs(merge)
151
- currentFileSet.union_update(filesM)
152
- currentDirectorySet.union_update(dirsM)
153
-
154
- entries = unmergedCacheEntries()
155
- renamesHead = getRenames(head, common, head, merge, entries)
156
- renamesMerge = getRenames(merge, common, head, merge, entries)
157
-
158
- cleanMerge = processRenames(renamesHead, renamesMerge,
159
- branch1Name, branch2Name)
160
- for entry in entries:
161
- if entry.processed:
162
- continue
163
- if not processEntry(entry, branch1Name, branch2Name):
164
- cleanMerge = False
165
-
166
- if cleanMerge or cacheOnly:
167
- tree = runProgram('git-write-tree').rstrip()
168
- else:
169
- tree = None
170
- else:
171
- cleanMerge = True
172
-
173
- return [tree, cleanMerge]
174
-
175
-# Low level file merging, update and removal
176
-# ------------------------------------------
177
-
178
-def mergeFile(oPath, oSha, oMode, aPath, aSha, aMode, bPath, bSha, bMode,
179
- branch1Name, branch2Name):
180
-
181
- merge = False
182
- clean = True
183
-
184
- if stat.S_IFMT(aMode) != stat.S_IFMT(bMode):
185
- clean = False
186
- if stat.S_ISREG(aMode):
187
- mode = aMode
188
- sha = aSha
189
- else:
190
- mode = bMode
191
- sha = bSha
192
- else:
193
- if aSha != oSha and bSha != oSha:
194
- merge = True
195
-
196
- if aMode == oMode:
197
- mode = bMode
198
- else:
199
- mode = aMode
200
-
201
- if aSha == oSha:
202
- sha = bSha
203
- elif bSha == oSha:
204
- sha = aSha
205
- elif stat.S_ISREG(aMode):
206
- assert(stat.S_ISREG(bMode))
207
-
208
- orig = runProgram(['git-unpack-file', oSha]).rstrip()
209
- src1 = runProgram(['git-unpack-file', aSha]).rstrip()
210
- src2 = runProgram(['git-unpack-file', bSha]).rstrip()
211
- try:
212
- [out, code] = runProgram(['merge',
213
- '-L', branch1Name + '/' + aPath,
214
- '-L', 'orig/' + oPath,
215
- '-L', branch2Name + '/' + bPath,
216
- src1, orig, src2], returnCode=True)
217
- except ProgramError, e:
218
- print >>sys.stderr, e
219
- die("Failed to execute 'merge'. merge(1) is used as the "
220
- "file-level merge tool. Is 'merge' in your path?")
221
-
222
- sha = runProgram(['git-hash-object', '-t', 'blob', '-w',
223
- src1]).rstrip()
224
-
225
- os.unlink(orig)
226
- os.unlink(src1)
227
- os.unlink(src2)
228
-
229
- clean = (code == 0)
230
- else:
231
- assert(stat.S_ISLNK(aMode) and stat.S_ISLNK(bMode))
232
- sha = aSha
233
-
234
- if aSha != bSha:
235
- clean = False
236
-
237
- return [sha, mode, clean, merge]
238
-
239
-def updateFile(clean, sha, mode, path):
240
- updateCache = cacheOnly or clean
241
- updateWd = not cacheOnly
242
-
243
- return updateFileExt(sha, mode, path, updateCache, updateWd)
244
-
245
-def updateFileExt(sha, mode, path, updateCache, updateWd):
246
- if cacheOnly:
247
- updateWd = False
248
-
249
- if updateWd:
250
- pathComponents = path.split('/')
251
- for x in xrange(1, len(pathComponents)):
252
- p = '/'.join(pathComponents[0:x])
253
-
254
- try:
255
- createDir = not stat.S_ISDIR(os.lstat(p).st_mode)
256
- except OSError:
257
- createDir = True
258
-
259
- if createDir:
260
- try:
261
- os.mkdir(p)
262
- except OSError, e:
263
- die("Couldn't create directory", p, e.strerror)
264
-
265
- prog = ['git-cat-file', 'blob', sha]
266
- if stat.S_ISREG(mode):
267
- try:
268
- os.unlink(path)
269
- except OSError:
270
- pass
271
- if mode & 0100:
272
- mode = 0777
273
- else:
274
- mode = 0666
275
- fd = os.open(path, os.O_WRONLY | os.O_TRUNC | os.O_CREAT, mode)
276
- proc = subprocess.Popen(prog, stdout=fd)
277
- proc.wait()
278
- os.close(fd)
279
- elif stat.S_ISLNK(mode):
280
- linkTarget = runProgram(prog)
281
- os.symlink(linkTarget, path)
282
- else:
283
- assert(False)
284
-
285
- if updateWd and updateCache:
286
- runProgram(['git-update-index', '--add', '--', path])
287
- elif updateCache:
288
- runProgram(['git-update-index', '--add', '--cacheinfo',
289
- '0%o' % mode, sha, path])
290
-
291
-def setIndexStages(path,
292
- oSHA1, oMode,
293
- aSHA1, aMode,
294
- bSHA1, bMode,
295
- clear=True):
296
- istring = []
297
- if clear:
298
- istring.append("0 " + ("0" * 40) + "\t" + path + "\0")
299
- if oMode:
300
- istring.append("%o %s %d\t%s\0" % (oMode, oSHA1, 1, path))
301
- if aMode:
302
- istring.append("%o %s %d\t%s\0" % (aMode, aSHA1, 2, path))
303
- if bMode:
304
- istring.append("%o %s %d\t%s\0" % (bMode, bSHA1, 3, path))
305
-
306
- runProgram(['git-update-index', '-z', '--index-info'],
307
- input="".join(istring))
308
-
309
-def removeFile(clean, path):
310
- updateCache = cacheOnly or clean
311
- updateWd = not cacheOnly
312
-
313
- if updateCache:
314
- runProgram(['git-update-index', '--force-remove', '--', path])
315
-
316
- if updateWd:
317
- try:
318
- os.unlink(path)
319
- except OSError, e:
320
- if e.errno != errno.ENOENT and e.errno != errno.EISDIR:
321
- raise
322
- try:
323
- os.removedirs(os.path.dirname(path))
324
- except OSError:
325
- pass
326
-
327
-def uniquePath(path, branch):
328
- def fileExists(path):
329
- try:
330
- os.lstat(path)
331
- return True
332
- except OSError, e:
333
- if e.errno == errno.ENOENT:
334
- return False
335
- else:
336
- raise
337
-
338
- branch = branch.replace('/', '_')
339
- newPath = path + '~' + branch
340
- suffix = 0
341
- while newPath in currentFileSet or \
342
- newPath in currentDirectorySet or \
343
- fileExists(newPath):
344
- suffix += 1
345
- newPath = path + '~' + branch + '_' + str(suffix)
346
- currentFileSet.add(newPath)
347
- return newPath
348
-
349
-# Cache entry management
350
-# ----------------------
351
-
352
-class CacheEntry:
353
- def __init__(self, path):
354
- class Stage:
355
- def __init__(self):
356
- self.sha1 = None
357
- self.mode = None
358
-
359
- # Used for debugging only
360
- def __str__(self):
361
- if self.mode != None:
362
- m = '0%o' % self.mode
363
- else:
364
- m = 'None'
365
-
366
- if self.sha1:
367
- sha1 = self.sha1
368
- else:
369
- sha1 = 'None'
370
- return 'sha1: ' + sha1 + ' mode: ' + m
371
-
372
- self.stages = [Stage(), Stage(), Stage(), Stage()]
373
- self.path = path
374
- self.processed = False
375
-
376
- def __str__(self):
377
- return 'path: ' + self.path + ' stages: ' + repr([str(x) for x in self.stages])
378
-
379
-class CacheEntryContainer:
380
- def __init__(self):
381
- self.entries = {}
382
-
383
- def add(self, entry):
384
- self.entries[entry.path] = entry
385
-
386
- def get(self, path):
387
- return self.entries.get(path)
388
-
389
- def __iter__(self):
390
- return self.entries.itervalues()
391
-
392
-unmergedRE = re.compile(r'^([0-7]+) ([0-9a-f]{40}) ([1-3])\t(.*)$', re.S)
393
-def unmergedCacheEntries():
394
- '''Create a dictionary mapping file names to CacheEntry
395
- objects. The dictionary contains one entry for every path with a
396
- non-zero stage entry.'''
397
-
398
- lines = runProgram(['git-ls-files', '-z', '--unmerged']).split('\0')
399
- lines.pop()
400
-
401
- res = CacheEntryContainer()
402
- for l in lines:
403
- m = unmergedRE.match(l)
404
- if m:
405
- mode = int(m.group(1), 8)
406
- sha1 = m.group(2)
407
- stage = int(m.group(3))
408
- path = m.group(4)
409
-
410
- e = res.get(path)
411
- if not e:
412
- e = CacheEntry(path)
413
- res.add(e)
414
-
415
- e.stages[stage].mode = mode
416
- e.stages[stage].sha1 = sha1
417
- else:
418
- die('Error: Merge program failed: Unexpected output from',
419
- 'git-ls-files:', l)
420
- return res
421
-
422
-lsTreeRE = re.compile(r'^([0-7]+) (\S+) ([0-9a-f]{40})\t(.*)\n$', re.S)
423
-def getCacheEntry(path, origTree, aTree, bTree):
424
- '''Returns a CacheEntry object which doesn't have to correspond to
425
- a real cache entry in Git's index.'''
426
-
427
- def parse(out):
428
- if out == '':
429
- return [None, None]
430
- else:
431
- m = lsTreeRE.match(out)
432
- if not m:
433
- die('Unexpected output from git-ls-tree:', out)
434
- elif m.group(2) == 'blob':
435
- return [m.group(3), int(m.group(1), 8)]
436
- else:
437
- return [None, None]
438
-
439
- res = CacheEntry(path)
440
-
441
- [oSha, oMode] = parse(runProgram(['git-ls-tree', origTree, '--', path]))
442
- [aSha, aMode] = parse(runProgram(['git-ls-tree', aTree, '--', path]))
443
- [bSha, bMode] = parse(runProgram(['git-ls-tree', bTree, '--', path]))
444
-
445
- res.stages[1].sha1 = oSha
446
- res.stages[1].mode = oMode
447
- res.stages[2].sha1 = aSha
448
- res.stages[2].mode = aMode
449
- res.stages[3].sha1 = bSha
450
- res.stages[3].mode = bMode
451
-
452
- return res
453
-
454
-# Rename detection and handling
455
-# -----------------------------
456
-
457
-class RenameEntry:
458
- def __init__(self,
459
- src, srcSha, srcMode, srcCacheEntry,
460
- dst, dstSha, dstMode, dstCacheEntry,
461
- score):
462
- self.srcName = src
463
- self.srcSha = srcSha
464
- self.srcMode = srcMode
465
- self.srcCacheEntry = srcCacheEntry
466
- self.dstName = dst
467
- self.dstSha = dstSha
468
- self.dstMode = dstMode
469
- self.dstCacheEntry = dstCacheEntry
470
- self.score = score
471
-
472
- self.processed = False
473
-
474
-class RenameEntryContainer:
475
- def __init__(self):
476
- self.entriesSrc = {}
477
- self.entriesDst = {}
478
-
479
- def add(self, entry):
480
- self.entriesSrc[entry.srcName] = entry
481
- self.entriesDst[entry.dstName] = entry
482
-
483
- def getSrc(self, path):
484
- return self.entriesSrc.get(path)
485
-
486
- def getDst(self, path):
487
- return self.entriesDst.get(path)
488
-
489
- def __iter__(self):
490
- return self.entriesSrc.itervalues()
491
-
492
-parseDiffRenamesRE = re.compile('^:([0-7]+) ([0-7]+) ([0-9a-f]{40}) ([0-9a-f]{40}) R([0-9]*)$')
493
-def getRenames(tree, oTree, aTree, bTree, cacheEntries):
494
- '''Get information of all renames which occured between 'oTree' and
495
- 'tree'. We need the three trees in the merge ('oTree', 'aTree' and
496
- 'bTree') to be able to associate the correct cache entries with
497
- the rename information. 'tree' is always equal to either aTree or bTree.'''
498
-
499
- assert(tree == aTree or tree == bTree)
500
- inp = runProgram(['git-diff-tree', '-M', '--diff-filter=R', '-r',
501
- '-z', oTree, tree])
502
-
503
- ret = RenameEntryContainer()
504
- try:
505
- recs = inp.split("\0")
506
- recs.pop() # remove last entry (which is '')
507
- it = recs.__iter__()
508
- while True:
509
- rec = it.next()
510
- m = parseDiffRenamesRE.match(rec)
511
-
512
- if not m:
513
- die('Unexpected output from git-diff-tree:', rec)
514
-
515
- srcMode = int(m.group(1), 8)
516
- dstMode = int(m.group(2), 8)
517
- srcSha = m.group(3)
518
- dstSha = m.group(4)
519
- score = m.group(5)
520
- src = it.next()
521
- dst = it.next()
522
-
523
- srcCacheEntry = cacheEntries.get(src)
524
- if not srcCacheEntry:
525
- srcCacheEntry = getCacheEntry(src, oTree, aTree, bTree)
526
- cacheEntries.add(srcCacheEntry)
527
-
528
- dstCacheEntry = cacheEntries.get(dst)
529
- if not dstCacheEntry:
530
- dstCacheEntry = getCacheEntry(dst, oTree, aTree, bTree)
531
- cacheEntries.add(dstCacheEntry)
532
-
533
- ret.add(RenameEntry(src, srcSha, srcMode, srcCacheEntry,
534
- dst, dstSha, dstMode, dstCacheEntry,
535
- score))
536
- except StopIteration:
537
- pass
538
- return ret
539
-
540
-def fmtRename(src, dst):
541
- srcPath = src.split('/')
542
- dstPath = dst.split('/')
543
- path = []
544
- endIndex = min(len(srcPath), len(dstPath)) - 1
545
- for x in range(0, endIndex):
546
- if srcPath[x] == dstPath[x]:
547
- path.append(srcPath[x])
548
- else:
549
- endIndex = x
550
- break
551
-
552
- if len(path) > 0:
553
- return '/'.join(path) + \
554
- '/{' + '/'.join(srcPath[endIndex:]) + ' => ' + \
555
- '/'.join(dstPath[endIndex:]) + '}'
556
- else:
557
- return src + ' => ' + dst
558
-
559
-def processRenames(renamesA, renamesB, branchNameA, branchNameB):
560
- srcNames = Set()
561
- for x in renamesA:
562
- srcNames.add(x.srcName)
563
- for x in renamesB:
564
- srcNames.add(x.srcName)
565
-
566
- cleanMerge = True
567
- for path in srcNames:
568
- if renamesA.getSrc(path):
569
- renames1 = renamesA
570
- renames2 = renamesB
571
- branchName1 = branchNameA
572
- branchName2 = branchNameB
573
- else:
574
- renames1 = renamesB
575
- renames2 = renamesA
576
- branchName1 = branchNameB
577
- branchName2 = branchNameA
578
-
579
- ren1 = renames1.getSrc(path)
580
- ren2 = renames2.getSrc(path)
581
-
582
- ren1.dstCacheEntry.processed = True
583
- ren1.srcCacheEntry.processed = True
584
-
585
- if ren1.processed:
586
- continue
587
-
588
- ren1.processed = True
589
-
590
- if ren2:
591
- # Renamed in 1 and renamed in 2
592
- assert(ren1.srcName == ren2.srcName)
593
- ren2.dstCacheEntry.processed = True
594
- ren2.processed = True
595
-
596
- if ren1.dstName != ren2.dstName:
597
- output('CONFLICT (rename/rename): Rename',
598
- fmtRename(path, ren1.dstName), 'in branch', branchName1,
599
- 'rename', fmtRename(path, ren2.dstName), 'in',
600
- branchName2)
601
- cleanMerge = False
602
-
603
- if ren1.dstName in currentDirectorySet:
604
- dstName1 = uniquePath(ren1.dstName, branchName1)
605
- output(ren1.dstName, 'is a directory in', branchName2,
606
- 'adding as', dstName1, 'instead.')
607
- removeFile(False, ren1.dstName)
608
- else:
609
- dstName1 = ren1.dstName
610
-
611
- if ren2.dstName in currentDirectorySet:
612
- dstName2 = uniquePath(ren2.dstName, branchName2)
613
- output(ren2.dstName, 'is a directory in', branchName1,
614
- 'adding as', dstName2, 'instead.')
615
- removeFile(False, ren2.dstName)
616
- else:
617
- dstName2 = ren2.dstName
618
- setIndexStages(dstName1,
619
- None, None,
620
- ren1.dstSha, ren1.dstMode,
621
- None, None)
622
- setIndexStages(dstName2,
623
- None, None,
624
- None, None,
625
- ren2.dstSha, ren2.dstMode)
626
-
627
- else:
628
- removeFile(True, ren1.srcName)
629
-
630
- [resSha, resMode, clean, merge] = \
631
- mergeFile(ren1.srcName, ren1.srcSha, ren1.srcMode,
632
- ren1.dstName, ren1.dstSha, ren1.dstMode,
633
- ren2.dstName, ren2.dstSha, ren2.dstMode,
634
- branchName1, branchName2)
635
-
636
- if merge or not clean:
637
- output('Renaming', fmtRename(path, ren1.dstName))
638
-
639
- if merge:
640
- output('Auto-merging', ren1.dstName)
641
-
642
- if not clean:
643
- output('CONFLICT (content): merge conflict in',
644
- ren1.dstName)
645
- cleanMerge = False
646
-
647
- if not cacheOnly:
648
- setIndexStages(ren1.dstName,
649
- ren1.srcSha, ren1.srcMode,
650
- ren1.dstSha, ren1.dstMode,
651
- ren2.dstSha, ren2.dstMode)
652
-
653
- updateFile(clean, resSha, resMode, ren1.dstName)
654
- else:
655
- removeFile(True, ren1.srcName)
656
-
657
- # Renamed in 1, maybe changed in 2
658
- if renamesA == renames1:
659
- stage = 3
660
- else:
661
- stage = 2
662
-
663
- srcShaOtherBranch = ren1.srcCacheEntry.stages[stage].sha1
664
- srcModeOtherBranch = ren1.srcCacheEntry.stages[stage].mode
665
-
666
- dstShaOtherBranch = ren1.dstCacheEntry.stages[stage].sha1
667
- dstModeOtherBranch = ren1.dstCacheEntry.stages[stage].mode
668
-
669
- tryMerge = False
670
-
671
- if ren1.dstName in currentDirectorySet:
672
- newPath = uniquePath(ren1.dstName, branchName1)
673
- output('CONFLICT (rename/directory): Rename',
674
- fmtRename(ren1.srcName, ren1.dstName), 'in', branchName1,
675
- 'directory', ren1.dstName, 'added in', branchName2)
676
- output('Renaming', ren1.srcName, 'to', newPath, 'instead')
677
- cleanMerge = False
678
- removeFile(False, ren1.dstName)
679
- updateFile(False, ren1.dstSha, ren1.dstMode, newPath)
680
- elif srcShaOtherBranch == None:
681
- output('CONFLICT (rename/delete): Rename',
682
- fmtRename(ren1.srcName, ren1.dstName), 'in',
683
- branchName1, 'and deleted in', branchName2)
684
- cleanMerge = False
685
- updateFile(False, ren1.dstSha, ren1.dstMode, ren1.dstName)
686
- elif dstShaOtherBranch:
687
- newPath = uniquePath(ren1.dstName, branchName2)
688
- output('CONFLICT (rename/add): Rename',
689
- fmtRename(ren1.srcName, ren1.dstName), 'in',
690
- branchName1 + '.', ren1.dstName, 'added in', branchName2)
691
- output('Adding as', newPath, 'instead')
692
- updateFile(False, dstShaOtherBranch, dstModeOtherBranch, newPath)
693
- cleanMerge = False
694
- tryMerge = True
695
- elif renames2.getDst(ren1.dstName):
696
- dst2 = renames2.getDst(ren1.dstName)
697
- newPath1 = uniquePath(ren1.dstName, branchName1)
698
- newPath2 = uniquePath(dst2.dstName, branchName2)
699
- output('CONFLICT (rename/rename): Rename',
700
- fmtRename(ren1.srcName, ren1.dstName), 'in',
701
- branchName1+'. Rename',
702
- fmtRename(dst2.srcName, dst2.dstName), 'in', branchName2)
703
- output('Renaming', ren1.srcName, 'to', newPath1, 'and',
704
- dst2.srcName, 'to', newPath2, 'instead')
705
- removeFile(False, ren1.dstName)
706
- updateFile(False, ren1.dstSha, ren1.dstMode, newPath1)
707
- updateFile(False, dst2.dstSha, dst2.dstMode, newPath2)
708
- dst2.processed = True
709
- cleanMerge = False
710
- else:
711
- tryMerge = True
712
-
713
- if tryMerge:
714
-
715
- oName, oSHA1, oMode = ren1.srcName, ren1.srcSha, ren1.srcMode
716
- aName, bName = ren1.dstName, ren1.srcName
717
- aSHA1, bSHA1 = ren1.dstSha, srcShaOtherBranch
718
- aMode, bMode = ren1.dstMode, srcModeOtherBranch
719
- aBranch, bBranch = branchName1, branchName2
720
-
721
- if renamesA != renames1:
722
- aName, bName = bName, aName
723
- aSHA1, bSHA1 = bSHA1, aSHA1
724
- aMode, bMode = bMode, aMode
725
- aBranch, bBranch = bBranch, aBranch
726
-
727
- [resSha, resMode, clean, merge] = \
728
- mergeFile(oName, oSHA1, oMode,
729
- aName, aSHA1, aMode,
730
- bName, bSHA1, bMode,
731
- aBranch, bBranch);
732
-
733
- if merge or not clean:
734
- output('Renaming', fmtRename(ren1.srcName, ren1.dstName))
735
-
736
- if merge:
737
- output('Auto-merging', ren1.dstName)
738
-
739
- if not clean:
740
- output('CONFLICT (rename/modify): Merge conflict in',
741
- ren1.dstName)
742
- cleanMerge = False
743
-
744
- if not cacheOnly:
745
- setIndexStages(ren1.dstName,
746
- oSHA1, oMode,
747
- aSHA1, aMode,
748
- bSHA1, bMode)
749
-
750
- updateFile(clean, resSha, resMode, ren1.dstName)
751
-
752
- return cleanMerge
753
-
754
-# Per entry merge function
755
-# ------------------------
756
-
757
-def processEntry(entry, branch1Name, branch2Name):
758
- '''Merge one cache entry.'''
759
-
760
- debug('processing', entry.path, 'clean cache:', cacheOnly)
761
-
762
- cleanMerge = True
763
-
764
- path = entry.path
765
- oSha = entry.stages[1].sha1
766
- oMode = entry.stages[1].mode
767
- aSha = entry.stages[2].sha1
768
- aMode = entry.stages[2].mode
769
- bSha = entry.stages[3].sha1
770
- bMode = entry.stages[3].mode
771
-
772
- assert(oSha == None or isSha(oSha))
773
- assert(aSha == None or isSha(aSha))
774
- assert(bSha == None or isSha(bSha))
775
-
776
- assert(oMode == None or type(oMode) is int)
777
- assert(aMode == None or type(aMode) is int)
778
- assert(bMode == None or type(bMode) is int)
779
-
780
- if (oSha and (not aSha or not bSha)):
781
- #
782
- # Case A: Deleted in one
783
- #
784
- if (not aSha and not bSha) or \
785
- (aSha == oSha and not bSha) or \
786
- (not aSha and bSha == oSha):
787
- # Deleted in both or deleted in one and unchanged in the other
788
- if aSha:
789
- output('Removing', path)
790
- removeFile(True, path)
791
- else:
792
- # Deleted in one and changed in the other
793
- cleanMerge = False
794
- if not aSha:
795
- output('CONFLICT (delete/modify):', path, 'deleted in',
796
- branch1Name, 'and modified in', branch2Name + '.',
797
- 'Version', branch2Name, 'of', path, 'left in tree.')
798
- mode = bMode
799
- sha = bSha
800
- else:
801
- output('CONFLICT (modify/delete):', path, 'deleted in',
802
- branch2Name, 'and modified in', branch1Name + '.',
803
- 'Version', branch1Name, 'of', path, 'left in tree.')
804
- mode = aMode
805
- sha = aSha
806
-
807
- updateFile(False, sha, mode, path)
808
-
809
- elif (not oSha and aSha and not bSha) or \
810
- (not oSha and not aSha and bSha):
811
- #
812
- # Case B: Added in one.
813
- #
814
- if aSha:
815
- addBranch = branch1Name
816
- otherBranch = branch2Name
817
- mode = aMode
818
- sha = aSha
819
- conf = 'file/directory'
820
- else:
821
- addBranch = branch2Name
822
- otherBranch = branch1Name
823
- mode = bMode
824
- sha = bSha
825
- conf = 'directory/file'
826
-
827
- if path in currentDirectorySet:
828
- cleanMerge = False
829
- newPath = uniquePath(path, addBranch)
830
- output('CONFLICT (' + conf + '):',
831
- 'There is a directory with name', path, 'in',
832
- otherBranch + '. Adding', path, 'as', newPath)
833
-
834
- removeFile(False, path)
835
- updateFile(False, sha, mode, newPath)
836
- else:
837
- output('Adding', path)
838
- updateFile(True, sha, mode, path)
839
-
840
- elif not oSha and aSha and bSha:
841
- #
842
- # Case C: Added in both (check for same permissions).
843
- #
844
- if aSha == bSha:
845
- if aMode != bMode:
846
- cleanMerge = False
847
- output('CONFLICT: File', path,
848
- 'added identically in both branches, but permissions',
849
- 'conflict', '0%o' % aMode, '->', '0%o' % bMode)
850
- output('CONFLICT: adding with permission:', '0%o' % aMode)
851
-
852
- updateFile(False, aSha, aMode, path)
853
- else:
854
- # This case is handled by git-read-tree
855
- assert(False)
856
- else:
857
- cleanMerge = False
858
- newPath1 = uniquePath(path, branch1Name)
859
- newPath2 = uniquePath(path, branch2Name)
860
- output('CONFLICT (add/add): File', path,
861
- 'added non-identically in both branches. Adding as',
862
- newPath1, 'and', newPath2, 'instead.')
863
- removeFile(False, path)
864
- updateFile(False, aSha, aMode, newPath1)
865
- updateFile(False, bSha, bMode, newPath2)
866
-
867
- elif oSha and aSha and bSha:
868
- #
869
- # case D: Modified in both, but differently.
870
- #
871
- output('Auto-merging', path)
872
- [sha, mode, clean, dummy] = \
873
- mergeFile(path, oSha, oMode,
874
- path, aSha, aMode,
875
- path, bSha, bMode,
876
- branch1Name, branch2Name)
877
- if clean:
878
- updateFile(True, sha, mode, path)
879
- else:
880
- cleanMerge = False
881
- output('CONFLICT (content): Merge conflict in', path)
882
-
883
- if cacheOnly:
884
- updateFile(False, sha, mode, path)
885
- else:
886
- updateFileExt(sha, mode, path, updateCache=False, updateWd=True)
887
- else:
888
- die("ERROR: Fatal merge failure, shouldn't happen.")
889
-
890
- return cleanMerge
891
-
892
-def usage():
893
- die('Usage:', sys.argv[0], ' <base>... -- <head> <remote>..')
894
-
895
-# main entry point as merge strategy module
896
-# The first parameters up to -- are merge bases, and the rest are heads.
897
-
898
-if len(sys.argv) < 4:
899
- usage()
900
-
901
-bases = []
902
-for nextArg in xrange(1, len(sys.argv)):
903
- if sys.argv[nextArg] == '--':
904
- if len(sys.argv) != nextArg + 3:
905
- die('Not handling anything other than two heads merge.')
906
- try:
907
- h1 = firstBranch = sys.argv[nextArg + 1]
908
- h2 = secondBranch = sys.argv[nextArg + 2]
909
- except IndexError:
910
- usage()
911
- break
912
- else:
913
- bases.append(sys.argv[nextArg])
914
-
915
-print 'Merging', h1, 'with', h2
916
-
917
-try:
918
- h1 = runProgram(['git-rev-parse', '--verify', h1 + '^0']).rstrip()
919
- h2 = runProgram(['git-rev-parse', '--verify', h2 + '^0']).rstrip()
920
-
921
- if len(bases) == 1:
922
- base = runProgram(['git-rev-parse', '--verify',
923
- bases[0] + '^0']).rstrip()
924
- ancestor = Commit(base, None)
925
- [dummy, clean] = merge(Commit(h1, None), Commit(h2, None),
926
- firstBranch, secondBranch, None, 0,
927
- ancestor)
928
- else:
929
- graph = buildGraph([h1, h2])
930
- [dummy, clean] = merge(graph.shaMap[h1], graph.shaMap[h2],
931
- firstBranch, secondBranch, graph)
932
-
933
- print ''
934
-except:
935
- if isinstance(sys.exc_info()[1], SystemExit):
936
- raise
937
- else:
938
- traceback.print_exc(None, sys.stderr)
939
- sys.exit(2)
940
-
941
-if clean:
942
- sys.exit(0)
943
-else:
944
- sys.exit(1)
git-merge.sh
+1
-4
@@ -9,16 +9,13 @@ USAGE='[-n] [--no-commit] [--squash] [-s <strategy>]... <merge-message> <head> <
9
LF='
10
'
11
12
-all_strategies='recur recursive recursive-old octopus resolve stupid ours'
12
+all_strategies='recur recursive octopus resolve stupid ours'
13
default_twohead_strategies='recursive'
14
default_octopus_strategies='octopus'
15
no_trivial_merge_strategies='ours'
16
use_strategies=
17
18
index_merge=t
19
-if test "@@NO_PYTHON@@"; then
20
- all_strategies='recur recursive resolve octopus stupid ours'
21
-fi
19
20
dropsave() {
21
rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" \
git-rebase.sh
-9
@@ -302,15 +302,6 @@ then
302
exit $?
303
fi
304
305
-if test "@@NO_PYTHON@@" && test "$strategy" = "recursive-old"
306
-then
307
- die 'The recursive-old merge strategy is written in Python,
308
-which this installation of git was not configured with. Please consider
309
-a different merge strategy (e.g. recursive, resolve, or stupid)
310
-or install Python and git with Python support.'
311
-
312
-fi
313
-
305
# start doing a rebase with git-merge
306
# this is rename-aware if the recursive (default) strategy is used
307
git.spec.in
+1
-1
@@ -24,7 +24,7 @@ This is a dummy package which brings in all subpackages.
24
%package core
25
Summary: Core git tools
26
Group: Development/Tools
27
-Requires: zlib >= 1.2, rsync, rcs, curl, less, openssh-clients, python >= 2.3, expat
27
+Requires: zlib >= 1.2, rsync, rcs, curl, less, openssh-clients, expat
28
%description core
29
This is a stupid (but extremely fast) directory content manager. It
30
doesn't do a whole lot, but what it _does_ do is track directory
gitMergeCommon.py
deleted
-275
@@ -1,275 +0,0 @@
1
-#
2
-# Copyright (C) 2005 Fredrik Kuivinen
3
-#
4
-
5
-import sys, re, os, traceback
6
-from sets import Set
7
-
8
-def die(*args):
9
- printList(args, sys.stderr)
10
- sys.exit(2)
11
-
12
-def printList(list, file=sys.stdout):
13
- for x in list:
14
- file.write(str(x))
15
- file.write(' ')
16
- file.write('\n')
17
-
18
-import subprocess
19
-
20
-# Debugging machinery
21
-# -------------------
22
-
23
-DEBUG = 0
24
-functionsToDebug = Set()
25
-
26
-def addDebug(func):
27
- if type(func) == str:
28
- functionsToDebug.add(func)
29
- else:
30
- functionsToDebug.add(func.func_name)
31
-
32
-def debug(*args):
33
- if DEBUG:
34
- funcName = traceback.extract_stack()[-2][2]
35
- if funcName in functionsToDebug:
36
- printList(args)
37
-
38
-# Program execution
39
-# -----------------
40
-
41
-class ProgramError(Exception):
42
- def __init__(self, progStr, error):
43
- self.progStr = progStr
44
- self.error = error
45
-
46
- def __str__(self):
47
- return self.progStr + ': ' + self.error
48
-
49
-addDebug('runProgram')
50
-def runProgram(prog, input=None, returnCode=False, env=None, pipeOutput=True):
51
- debug('runProgram prog:', str(prog), 'input:', str(input))
52
- if type(prog) is str:
53
- progStr = prog
54
- else:
55
- progStr = ' '.join(prog)
56
-
57
- try:
58
- if pipeOutput:
59
- stderr = subprocess.STDOUT
60
- stdout = subprocess.PIPE
61
- else:
62
- stderr = None
63
- stdout = None
64
- pop = subprocess.Popen(prog,
65
- shell = type(prog) is str,
66
- stderr=stderr,
67
- stdout=stdout,
68
- stdin=subprocess.PIPE,
69
- env=env)
70
- except OSError, e:
71
- debug('strerror:', e.strerror)
72
- raise ProgramError(progStr, e.strerror)
73
-
74
- if input != None:
75
- pop.stdin.write(input)
76
- pop.stdin.close()
77
-
78
- if pipeOutput:
79
- out = pop.stdout.read()
80
- else:
81
- out = ''
82
-
83
- code = pop.wait()
84
- if returnCode:
85
- ret = [out, code]
86
- else:
87
- ret = out
88
- if code != 0 and not returnCode:
89
- debug('error output:', out)
90
- debug('prog:', prog)
91
- raise ProgramError(progStr, out)
92
-# debug('output:', out.replace('\0', '\n'))
93
- return ret
94
-
95
-# Code for computing common ancestors
96
-# -----------------------------------
97
-
98
-currentId = 0
99
-def getUniqueId():
100
- global currentId
101
- currentId += 1
102
- return currentId
103
-
104
-# The 'virtual' commit objects have SHAs which are integers
105
-shaRE = re.compile('^[0-9a-f]{40}$')
106
-def isSha(obj):
107
- return (type(obj) is str and bool(shaRE.match(obj))) or \
108
- (type(obj) is int and obj >= 1)
109
-
110
-class Commit(object):
111
- __slots__ = ['parents', 'firstLineMsg', 'children', '_tree', 'sha',
112
- 'virtual']
113
-
114
- def __init__(self, sha, parents, tree=None):
115
- self.parents = parents
116
- self.firstLineMsg = None
117
- self.children = []
118
-
119
- if tree:
120
- tree = tree.rstrip()
121
- assert(isSha(tree))
122
- self._tree = tree
123
-
124
- if not sha:
125
- self.sha = getUniqueId()
126
- self.virtual = True
127
- self.firstLineMsg = 'virtual commit'
128
- assert(isSha(tree))
129
- else:
130
- self.virtual = False
131
- self.sha = sha.rstrip()
132
- assert(isSha(self.sha))
133
-
134
- def tree(self):
135
- self.getInfo()
136
- assert(self._tree != None)
137
- return self._tree
138
-
139
- def shortInfo(self):
140
- self.getInfo()
141
- return str(self.sha) + ' ' + self.firstLineMsg
142
-
143
- def __str__(self):
144
- return self.shortInfo()
145
-
146
- def getInfo(self):
147
- if self.virtual or self.firstLineMsg != None:
148
- return
149
- else:
150
- info = runProgram(['git-cat-file', 'commit', self.sha])
151
- info = info.split('\n')
152
- msg = False
153
- for l in info:
154
- if msg:
155
- self.firstLineMsg = l
156
- break
157
- else:
158
- if l.startswith('tree'):
159
- self._tree = l[5:].rstrip()
160
- elif l == '':
161
- msg = True
162
-
163
-class Graph:
164
- def __init__(self):
165
- self.commits = []
166
- self.shaMap = {}
167
-
168
- def addNode(self, node):
169
- assert(isinstance(node, Commit))
170
- self.shaMap[node.sha] = node
171
- self.commits.append(node)
172
- for p in node.parents:
173
- p.children.append(node)
174
- return node
175
-
176
- def reachableNodes(self, n1, n2):
177
- res = {}
178
- def traverse(n):
179
- res[n] = True
180
- for p in n.parents:
181
- traverse(p)
182
-
183
- traverse(n1)
184
- traverse(n2)
185
- return res
186
-
187
- def fixParents(self, node):
188
- for x in range(0, len(node.parents)):
189
- node.parents[x] = self.shaMap[node.parents[x]]
190
-
191
-# addDebug('buildGraph')
192
-def buildGraph(heads):
193
- debug('buildGraph heads:', heads)
194
- for h in heads:
195
- assert(isSha(h))
196
-
197
- g = Graph()
198
-
199
- out = runProgram(['git-rev-list', '--parents'] + heads)
200
- for l in out.split('\n'):
201
- if l == '':
202
- continue
203
- shas = l.split(' ')
204
-
205
- # This is a hack, we temporarily use the 'parents' attribute
206
- # to contain a list of SHA1:s. They are later replaced by proper
207
- # Commit objects.
208
- c = Commit(shas[0], shas[1:])
209
-
210
- g.commits.append(c)
211
- g.shaMap[c.sha] = c
212
-
213
- for c in g.commits:
214
- g.fixParents(c)
215
-
216
- for c in g.commits:
217
- for p in c.parents:
218
- p.children.append(c)
219
- return g
220
-
221
-# Write the empty tree to the object database and return its SHA1
222
-def writeEmptyTree():
223
- tmpIndex = os.environ.get('GIT_DIR', '.git') + '/merge-tmp-index'
224
- def delTmpIndex():
225
- try:
226
- os.unlink(tmpIndex)
227
- except OSError:
228
- pass
229
- delTmpIndex()
230
- newEnv = os.environ.copy()
231
- newEnv['GIT_INDEX_FILE'] = tmpIndex
232
- res = runProgram(['git-write-tree'], env=newEnv).rstrip()
233
- delTmpIndex()
234
- return res
235
-
236
-def addCommonRoot(graph):
237
- roots = []
238
- for c in graph.commits:
239
- if len(c.parents) == 0:
240
- roots.append(c)
241
-
242
- superRoot = Commit(sha=None, parents=[], tree=writeEmptyTree())
243
- graph.addNode(superRoot)
244
- for r in roots:
245
- r.parents = [superRoot]
246
- superRoot.children = roots
247
- return superRoot
248
-
249
-def getCommonAncestors(graph, commit1, commit2):
250
- '''Find the common ancestors for commit1 and commit2'''
251
- assert(isinstance(commit1, Commit) and isinstance(commit2, Commit))
252
-
253
- def traverse(start, set):
254
- stack = [start]
255
- while len(stack) > 0:
256
- el = stack.pop()
257
- set.add(el)
258
- for p in el.parents:
259
- if p not in set:
260
- stack.append(p)
261
- h1Set = Set()
262
- h2Set = Set()
263
- traverse(commit1, h1Set)
264
- traverse(commit2, h2Set)
265
- shared = h1Set.intersection(h2Set)
266
-
267
- if len(shared) == 0:
268
- shared = [addCommonRoot(graph)]
269
-
270
- res = Set()
271
-
272
- for s in shared:
273
- if len([c for c in s.children if c in shared]) == 0:
274
- res.add(s)
275
- return list(res)
t/Makefile
-4
@@ -13,10 +13,6 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
13
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
14
TSVN = $(wildcard t91[0-9][0-9]-*.sh)
15
16
-ifdef NO_PYTHON
17
- GIT_TEST_OPTS += --no-python
18
-endif
19
-
16
all: $(T) clean
17
18
$(T):
t/t0000-basic.sh
+4
-10
@@ -20,10 +20,10 @@ modification *should* take notice and update the test vectors here.
20
21
################################################################
22
# It appears that people are getting bitten by not installing
23
-# 'merge' (usually part of RCS package in binary distributions)
24
-# or have too old python without subprocess. Check them and error
25
-# out before running any tests. Also catch the bogosity of trying
26
-# to run tests without building while we are at it.
23
+# 'merge' (usually part of RCS package in binary distributions).
24
+# Check this and error out before running any tests. Also catch
25
+# the bogosity of trying to run tests without building while we
26
+# are at it.
27
28
../git >/dev/null
29
if test $? != 1
@@ -42,12 +42,6 @@ fi
42
43
. ./test-lib.sh
44
45
-test "$no_python" || "$PYTHON" -c 'import subprocess' || {
46
- echo >&2 'Your python seem to lack "subprocess" module.
47
-Please check INSTALL document.'
48
- exit 1
49
-}
50
-
45
################################################################
46
# init-db has been done in an empty repository.
47
# make sure it is empty.
t/test-lib.sh
+2
-13
@@ -76,7 +76,8 @@ do
76
-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
77
verbose=t; shift ;;
78
--no-python)
79
- no_python=t; shift ;;
79
+ # noop now...
80
+ shift ;;
81
*)
82
break ;;
83
esac
@@ -210,18 +211,6 @@ GIT_EXEC_PATH=$(pwd)/..
211
HOME=$(pwd)/trash
212
export PATH GIT_EXEC_PATH HOME
213
213
-# Similarly use ../compat/subprocess.py if our python does not
214
-# have subprocess.py on its own.
215
-PYTHON=`sed -e '1{
216
- s/^#!//
217
- q
218
-}' ../git-merge-recursive-old` || {
219
- error "You haven't built things yet, have you?"
220
-}
221
-"$PYTHON" -c 'import subprocess' 2>/dev/null || {
222
- PYTHONPATH=$(pwd)/../compat
223
- export PYTHONPATH
224
-}
214
GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
215
export GITPERLLIB
216
test -d ../templates/blt || {