hg import: better file accounting
authormpm@selenic.com
Wed, 15 Jun 2005 10:02:41 -0800
changeset 355 3e18360a8912
parent 354 e3667e3a18ac
child 356 7dec9a46d82a
hg import: better file accounting -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hg import: better file accounting From: Chris Mason <mason@suse.com> Change hg import to call hg addremove with the file list to make sure files added/deleted by the patch are properly accounted for. Instead of using lsdiff, the output of patch is parsed directly to find the file list. manifest hash: defed8cb90d6f976fb47949ac03dc4b88870ba77 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsG1BywK+sNU5EO8RAvV9AJ9H25L5vdnZB1xpAakuN3tGuMfRfgCfdAgP 3xBc3S4F74/7DdS2GXRNhGw= =oXXT -----END PGP SIGNATURE-----
mercurial/commands.py
--- a/mercurial/commands.py	Wed Jun 15 10:01:15 2005 -0800
+++ b/mercurial/commands.py	Wed Jun 15 10:02:41 2005 -0800
@@ -440,13 +440,18 @@
         # make sure text isn't empty
         if not text: text = "imported patch %s\n" % patch
 
-        f = os.popen("lsdiff --strip %d %s" % (strip, pf))
-        files = filter(None, map(lambda x: x.rstrip(), f.read().splitlines()))
+        f = os.popen("patch -p%d < %s" % (strip, pf))
+        files = []
+        for l in f.read().splitlines():
+            l.rstrip('\r\n');
+            if not quiet:
+                print l
+            if l[:14] == 'patching file ':
+                files.append(l[14:])
         f.close()
 
-        if files:
-            if os.system("patch -p%d < %s %s" % (strip, pf, quiet)):
-                raise "patch failed!"
+        if len(files) > 0:
+            addremove(ui, repo, *files)
         repo.commit(files, text)
 
 def pull(ui, repo, source="default"):