hgext/extdiff.py
changeset 6747 f6c00b17387c
parent 6603 41eb20cc1c02
child 6760 4faaa0535ea7
equal deleted inserted replaced
6746:1dca460e7d1e 6747:f6c00b17387c
    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_node(ui, repo, files, node, tmproot):
    54     '''snapshot files as of some revision'''
    54     '''snapshot files as of some revision'''
    55     mf = repo.changectx(node).manifest()
       
    56     dirname = os.path.basename(repo.root)
    55     dirname = os.path.basename(repo.root)
    57     if dirname == "":
    56     if dirname == "":
    58         dirname = "root"
    57         dirname = "root"
    59     dirname = '%s.%s' % (dirname, short(node))
    58     dirname = '%s.%s' % (dirname, short(node))
    60     base = os.path.join(tmproot, dirname)
    59     base = os.path.join(tmproot, dirname)
    61     os.mkdir(base)
    60     os.mkdir(base)
    62     ui.note(_('making snapshot of %d files from rev %s\n') %
    61     ui.note(_('making snapshot of %d files from rev %s\n') %
    63             (len(files), short(node)))
    62             (len(files), short(node)))
       
    63     ctx = repo[node]
    64     for fn in files:
    64     for fn in files:
    65         if not fn in mf:
    65         wfn = util.pconvert(fn)
       
    66         if not wfn in ctx:
    66             # skipping new file after a merge ?
    67             # skipping new file after a merge ?
    67             continue
    68             continue
    68         wfn = util.pconvert(fn)
       
    69         ui.note('  %s\n' % wfn)
    69         ui.note('  %s\n' % wfn)
    70         dest = os.path.join(base, wfn)
    70         dest = os.path.join(base, wfn)
    71         destdir = os.path.dirname(dest)
    71         destdir = os.path.dirname(dest)
    72         if not os.path.isdir(destdir):
    72         if not os.path.isdir(destdir):
    73             os.makedirs(destdir)
    73             os.makedirs(destdir)
    74         data = repo.wwritedata(wfn, repo.file(wfn).read(mf[wfn]))
    74         data = repo.wwritedata(wfn, ctx[wfn].data())
    75         open(dest, 'wb').write(data)
    75         open(dest, 'wb').write(data)
    76     return dirname
    76     return dirname
    77 
    77 
    78 
    78 
    79 def snapshot_wdir(ui, repo, files, tmproot):
    79 def snapshot_wdir(ui, repo, files, tmproot):