62 dirname = "root" |
62 dirname = "root" |
63 dirname = '%s.%s' % (dirname, short(node)) |
63 dirname = '%s.%s' % (dirname, short(node)) |
64 base = os.path.join(tmproot, dirname) |
64 base = os.path.join(tmproot, dirname) |
65 os.mkdir(base) |
65 os.mkdir(base) |
66 ui.note(_('making snapshot of %d files from rev %s\n') % |
66 ui.note(_('making snapshot of %d files from rev %s\n') % |
67 (len(files), short(node))) |
67 (len(files), short(node))) |
68 for fn in files: |
68 for fn in files: |
69 if not fn in mf: |
69 if not fn in mf: |
70 # skipping new file after a merge ? |
70 # skipping new file after a merge ? |
71 continue |
71 continue |
72 wfn = util.pconvert(fn) |
72 wfn = util.pconvert(fn) |
88 if dirname == "": |
88 if dirname == "": |
89 dirname = "root" |
89 dirname = "root" |
90 base = os.path.join(tmproot, dirname) |
90 base = os.path.join(tmproot, dirname) |
91 os.mkdir(base) |
91 os.mkdir(base) |
92 ui.note(_('making snapshot of %d files from working dir\n') % |
92 ui.note(_('making snapshot of %d files from working dir\n') % |
93 (len(files))) |
93 (len(files))) |
94 for fn in files: |
94 for fn in files: |
95 wfn = util.pconvert(fn) |
95 wfn = util.pconvert(fn) |
96 ui.note(' %s\n' % wfn) |
96 ui.note(' %s\n' % wfn) |
97 dest = os.path.join(base, wfn) |
97 dest = os.path.join(base, wfn) |
98 destdir = os.path.dirname(dest) |
98 destdir = os.path.dirname(dest) |
100 os.makedirs(destdir) |
100 os.makedirs(destdir) |
101 fp = open(dest, 'wb') |
101 fp = open(dest, 'wb') |
102 for chunk in util.filechunkiter(repo.wopener(wfn)): |
102 for chunk in util.filechunkiter(repo.wopener(wfn)): |
103 fp.write(chunk) |
103 fp.write(chunk) |
104 return dirname |
104 return dirname |
105 |
105 |
106 |
106 |
107 def dodiff(ui, repo, diffcmd, diffopts, pats, opts): |
107 def dodiff(ui, repo, diffcmd, diffopts, pats, opts): |
108 node1, node2 = cmdutil.revpair(repo, opts['rev']) |
108 node1, node2 = cmdutil.revpair(repo, opts['rev']) |
109 files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) |
109 files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) |
110 modified, added, removed, deleted, unknown = repo.status( |
110 modified, added, removed, deleted, unknown = repo.status( |
131 |
131 |
132 # If only one change, diff the files instead of the directories |
132 # If only one change, diff the files instead of the directories |
133 if changes == 1 : |
133 if changes == 1 : |
134 if len(modified): |
134 if len(modified): |
135 dir1 = os.path.join(dir1, util.localpath(modified[0])) |
135 dir1 = os.path.join(dir1, util.localpath(modified[0])) |
136 dir2 = os.path.join(dir2root, dir2, util.localpath(modified[0])) |
136 dir2 = os.path.join(dir2root, dir2, util.localpath(modified[0])) |
137 elif len(removed) : |
137 elif len(removed) : |
138 dir1 = os.path.join(dir1, util.localpath(removed[0])) |
138 dir1 = os.path.join(dir1, util.localpath(removed[0])) |
139 dir2 = os.devnull |
139 dir2 = os.devnull |
140 else: |
140 else: |
141 dir1 = os.devnull |
141 dir1 = os.devnull |
142 dir2 = os.path.join(dir2root, dir2, util.localpath(added[0])) |
142 dir2 = os.path.join(dir2root, dir2, util.localpath(added[0])) |
143 |
143 |
144 cmdline = ('%s %s %s %s' % |
144 cmdline = ('%s %s %s %s' % |
145 (util.shellquote(diffcmd), ' '.join(diffopts), |
145 (util.shellquote(diffcmd), ' '.join(diffopts), |
146 util.shellquote(dir1), util.shellquote(dir2))) |
146 util.shellquote(dir1), util.shellquote(dir2))) |
147 ui.debug('running %r in %s\n' % (cmdline, tmproot)) |
147 ui.debug('running %r in %s\n' % (cmdline, tmproot)) |
148 util.system(cmdline, cwd=tmproot) |
148 util.system(cmdline, cwd=tmproot) |