Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG3d094bfaf885: subrepo: adjust subrepo prefix before calling subrepo.diff() (API)
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/logcmdutil.py (3 lines) | |||
M | mercurial/subrepo.py (18 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Feb 7 2019, 12:52 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
if node2 is not None: | if node2 is not None: | ||||
tempnode2 = ctx2.substate[subpath][1] | tempnode2 = ctx2.substate[subpath][1] | ||||
except KeyError: | except KeyError: | ||||
# A subrepo that existed in node1 was deleted between node1 and | # A subrepo that existed in node1 was deleted between node1 and | ||||
# node2 (inclusive). Thus, ctx2's substate won't contain that | # node2 (inclusive). Thus, ctx2's substate won't contain that | ||||
# subpath. The best we can do is to ignore it. | # subpath. The best we can do is to ignore it. | ||||
tempnode2 = None | tempnode2 = None | ||||
submatch = matchmod.subdirmatcher(subpath, match) | submatch = matchmod.subdirmatcher(subpath, match) | ||||
subprefix = repo.wvfs.reljoin(prefix, subpath) | |||||
sub.diff(ui, diffopts, tempnode2, submatch, changes=changes, | sub.diff(ui, diffopts, tempnode2, submatch, changes=changes, | ||||
stat=stat, fp=fp, prefix=prefix) | stat=stat, fp=fp, prefix=subprefix) | ||||
class changesetdiffer(object): | class changesetdiffer(object): | ||||
"""Generate diff of changeset with pre-configured filtering functions""" | """Generate diff of changeset with pre-configured filtering functions""" | ||||
def _makefilematcher(self, ctx): | def _makefilematcher(self, ctx): | ||||
return scmutil.matchall(ctx.repo()) | return scmutil.matchall(ctx.repo()) | ||||
def _makehunksfilter(self, ctx): | def _makehunksfilter(self, ctx): |
# subrepo.py - sub-repository classes and factory | # subrepo.py - sub-repository classes and factory | ||||
# | # | ||||
# Copyright 2009-2010 Matt Mackall <mpm@selenic.com> | # Copyright 2009-2010 Matt Mackall <mpm@selenic.com> | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
import copy | import copy | ||||
import errno | import errno | ||||
import hashlib | import hashlib | ||||
import os | import os | ||||
import posixpath | |||||
import re | import re | ||||
import stat | import stat | ||||
import subprocess | import subprocess | ||||
import sys | import sys | ||||
import tarfile | import tarfile | ||||
import xml.dom.minidom | import xml.dom.minidom | ||||
from .i18n import _ | from .i18n import _ | ||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def diff(self, ui, diffopts, node2, match, prefix, **opts): | def diff(self, ui, diffopts, node2, match, prefix, **opts): | ||||
try: | try: | ||||
node1 = node.bin(self._state[1]) | node1 = node.bin(self._state[1]) | ||||
# We currently expect node2 to come from substate and be | # We currently expect node2 to come from substate and be | ||||
# in hex format | # in hex format | ||||
if node2 is not None: | if node2 is not None: | ||||
node2 = node.bin(node2) | node2 = node.bin(node2) | ||||
logcmdutil.diffordiffstat(ui, self._repo, diffopts, | logcmdutil.diffordiffstat(ui, self._repo, diffopts, node1, node2, | ||||
node1, node2, match, | match, prefix=prefix, listsubrepos=True, | ||||
prefix=posixpath.join(prefix, self._path), | **opts) | ||||
listsubrepos=True, **opts) | |||||
except error.RepoLookupError as inst: | except error.RepoLookupError as inst: | ||||
self.ui.warn(_('warning: error "%s" in subrepository "%s"\n') | self.ui.warn(_('warning: error "%s" in subrepository "%s"\n') | ||||
% (inst, subrelpath(self))) | % (inst, subrelpath(self))) | ||||
@annotatesubrepoerror | @annotatesubrepoerror | ||||
def archive(self, archiver, prefix, match=None, decode=True): | def archive(self, archiver, prefix, match=None, decode=True): | ||||
self._get(self._state + ('hg',)) | self._get(self._state + ('hg',)) | ||||
files = self.files() | files = self.files() | ||||
node1 = self._state[1] | node1 = self._state[1] | ||||
cmd = ['diff', '--no-renames'] | cmd = ['diff', '--no-renames'] | ||||
if opts[r'stat']: | if opts[r'stat']: | ||||
cmd.append('--stat') | cmd.append('--stat') | ||||
else: | else: | ||||
# for Git, this also implies '-p' | # for Git, this also implies '-p' | ||||
cmd.append('-U%d' % diffopts.context) | cmd.append('-U%d' % diffopts.context) | ||||
gitprefix = self.wvfs.reljoin(prefix, self._path) | |||||
if diffopts.noprefix: | if diffopts.noprefix: | ||||
cmd.extend(['--src-prefix=%s/' % gitprefix, | cmd.extend(['--src-prefix=%s/' % prefix, | ||||
'--dst-prefix=%s/' % gitprefix]) | '--dst-prefix=%s/' % prefix]) | ||||
else: | else: | ||||
cmd.extend(['--src-prefix=a/%s/' % gitprefix, | cmd.extend(['--src-prefix=a/%s/' % prefix, | ||||
'--dst-prefix=b/%s/' % gitprefix]) | '--dst-prefix=b/%s/' % prefix]) | ||||
if diffopts.ignorews: | if diffopts.ignorews: | ||||
cmd.append('--ignore-all-space') | cmd.append('--ignore-all-space') | ||||
if diffopts.ignorewsamount: | if diffopts.ignorewsamount: | ||||
cmd.append('--ignore-space-change') | cmd.append('--ignore-space-change') | ||||
if self._gitversion(self._gitcommand(['--version'])) >= (1, 8, 4) \ | if self._gitversion(self._gitcommand(['--version'])) >= (1, 8, 4) \ | ||||
and diffopts.ignoreblanklines: | and diffopts.ignoreblanklines: | ||||
cmd.append('--ignore-blank-lines') | cmd.append('--ignore-blank-lines') |