mercurial/metadata.py
changeset 45323 aea6a812f7cb
parent 44942 25512a65cefd
child 45325 c6eea5804551
equal deleted inserted replaced
45322:c3376a724e32 45323:aea6a812f7cb
    18 
    18 
    19 from .revlogutils import (
    19 from .revlogutils import (
    20     flagutil as sidedataflag,
    20     flagutil as sidedataflag,
    21     sidedata as sidedatamod,
    21     sidedata as sidedatamod,
    22 )
    22 )
       
    23 
       
    24 
       
    25 class ChangingFiles(object):
       
    26     """A class recording the changes made to a file by a revision
       
    27     """
       
    28 
       
    29     def __init__(
       
    30         self, touched=(), added=(), removed=(), p1_copies=(), p2_copies=(),
       
    31     ):
       
    32         self._added = set(added)
       
    33         self._removed = set(removed)
       
    34         self._touched = set(touched)
       
    35         self._touched.update(self._added)
       
    36         self._touched.update(self._removed)
       
    37         self._p1_copies = dict(p1_copies)
       
    38         self._p2_copies = dict(p2_copies)
       
    39 
       
    40     @property
       
    41     def added(self):
       
    42         return frozenset(self._added)
       
    43 
       
    44     def mark_added(self, filename):
       
    45         self._added.add(filename)
       
    46         self._touched.add(filename)
       
    47 
       
    48     def update_added(self, filenames):
       
    49         for f in filenames:
       
    50             self.mark_added(f)
       
    51 
       
    52     @property
       
    53     def removed(self):
       
    54         return frozenset(self._removed)
       
    55 
       
    56     def mark_removed(self, filename):
       
    57         self._removed.add(filename)
       
    58         self._touched.add(filename)
       
    59 
       
    60     def update_removed(self, filenames):
       
    61         for f in filenames:
       
    62             self.mark_removed(f)
       
    63 
       
    64     @property
       
    65     def touched(self):
       
    66         return frozenset(self._touched)
       
    67 
       
    68     def mark_touched(self, filename):
       
    69         self._touched.add(filename)
       
    70 
       
    71     def update_touched(self, filenames):
       
    72         for f in filenames:
       
    73             self.mark_touched(f)
       
    74 
       
    75     @property
       
    76     def copied_from_p1(self):
       
    77         return self._p1_copies.copy()
       
    78 
       
    79     def mark_copied_from_p1(self, source, dest):
       
    80         self._p1_copies[dest] = source
       
    81 
       
    82     def update_copies_from_p1(self, copies):
       
    83         for dest, source in copies.items():
       
    84             self.mark_copied_from_p1(source, dest)
       
    85 
       
    86     @property
       
    87     def copied_from_p2(self):
       
    88         return self._p2_copies.copy()
       
    89 
       
    90     def mark_copied_from_p2(self, source, dest):
       
    91         self._p2_copies[dest] = source
       
    92 
       
    93     def update_copies_from_p2(self, copies):
       
    94         for dest, source in copies.items():
       
    95             self.mark_copied_from_p2(source, dest)
    23 
    96 
    24 
    97 
    25 def computechangesetfilesadded(ctx):
    98 def computechangesetfilesadded(ctx):
    26     """return the list of files added in a changeset
    99     """return the list of files added in a changeset
    27     """
   100     """