annotate hgext/narrow/narrowcopies.py @ 36709:7f9a6f5f7612

archival: our filenames are bytes, not strs Differential Revision: https://phab.mercurial-scm.org/D2656
author Augie Fackler <augie@google.com>
date Sun, 04 Mar 2018 12:08:53 -0500
parents d0d5eef57fb0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
1 # narrowcopies.py - extensions to mercurial copies module to support narrow
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
2 # clones
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
3 #
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
4 # Copyright 2017 Google, Inc.
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
5 #
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
6 # This software may be used and distributed according to the terms of the
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
7 # GNU General Public License version 2 or any later version.
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
8
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
9 from __future__ import absolute_import
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
10
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
11 from mercurial import (
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
12 copies,
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
13 extensions,
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
14 )
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
15
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
16 def setup(repo):
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
17 def _computeforwardmissing(orig, a, b, match=None):
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
18 missing = orig(a, b, match)
36472
d0d5eef57fb0 narrow: drop safehasattr() checks for always-present repo.narrowmatch
Martin von Zweigbergk <martinvonz@google.com>
parents: 36345
diff changeset
19 narrowmatch = repo.narrowmatch()
d0d5eef57fb0 narrow: drop safehasattr() checks for always-present repo.narrowmatch
Martin von Zweigbergk <martinvonz@google.com>
parents: 36345
diff changeset
20 if narrowmatch.always():
d0d5eef57fb0 narrow: drop safehasattr() checks for always-present repo.narrowmatch
Martin von Zweigbergk <martinvonz@google.com>
parents: 36345
diff changeset
21 return missing
d0d5eef57fb0 narrow: drop safehasattr() checks for always-present repo.narrowmatch
Martin von Zweigbergk <martinvonz@google.com>
parents: 36345
diff changeset
22 missing = [f for f in missing if narrowmatch(f)]
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
23 return missing
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
24
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
25 def _checkcopies(orig, srcctx, dstctx, f, base, tca, remotebase, limit,
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
26 data):
36472
d0d5eef57fb0 narrow: drop safehasattr() checks for always-present repo.narrowmatch
Martin von Zweigbergk <martinvonz@google.com>
parents: 36345
diff changeset
27 narrowmatch = repo.narrowmatch()
d0d5eef57fb0 narrow: drop safehasattr() checks for always-present repo.narrowmatch
Martin von Zweigbergk <martinvonz@google.com>
parents: 36345
diff changeset
28 if not narrowmatch(f):
d0d5eef57fb0 narrow: drop safehasattr() checks for always-present repo.narrowmatch
Martin von Zweigbergk <martinvonz@google.com>
parents: 36345
diff changeset
29 return
36079
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
30 orig(srcctx, dstctx, f, base, tca, remotebase, limit, data)
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
31
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
32 extensions.wrapfunction(copies, '_computeforwardmissing',
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
33 _computeforwardmissing)
a2a6e724d61a narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff changeset
34 extensions.wrapfunction(copies, '_checkcopies', _checkcopies)