Locally modified Mercurial dependencies are now detected. default tip
authorMartin Vejnar <avakar@ratatanek.cz>
Fri Apr 10 20:48:20 2009 +0200 (2009-04-10)
changeset 52ab2935095cb9
parent 51 103d5d5b0138
Locally modified Mercurial dependencies are now detected.

'hg depst' will now mark locally modified dependencies with 'L' modifier.
Unless forced, 'hg depup' and 'hg depci' will abort in the presence
of modified dependencies.
deps.py
     1.1 --- a/deps.py	Fri Apr 10 19:29:51 2009 +0200
     1.2 +++ b/deps.py	Fri Apr 10 20:48:20 2009 +0200
     1.3 @@ -182,7 +182,7 @@
     1.4              _save_config(ui, repo, config)
     1.5  
     1.6  
     1.7 -def depupdate(ui, repo, rev=None):
     1.8 +def depupdate(ui, repo, rev=None, force=False):
     1.9      '''update dependencies to a configured state
    1.10      
    1.11      Loads the dependency list from .hgdeps file and applies it.
    1.12 @@ -219,6 +219,8 @@
    1.13              for item in manifest.values():
    1.14                  if item.dest:
    1.15                      scmhandler = _get_scm_handler(ui, repo, manifest, item.alias_name)
    1.16 +                    if not force and scmhandler.is_locally_modified():
    1.17 +                        raise util.Abort(_('dependency is locally modified: %s (use -f to override)') % item.alias_name)
    1.18                      scmhandler.move(dest=None)
    1.19              
    1.20              for dependency in deplist:
    1.21 @@ -250,6 +252,7 @@
    1.22      M = modified
    1.23      A = added
    1.24      R = removed
    1.25 +    L = has local modifications
    1.26        = unmodified
    1.27      '''
    1.28      manifest = _load_manifest(repo)
    1.29 @@ -279,6 +282,9 @@
    1.30                  item.dest, _readable_rev(item.scmtype, rev),
    1.31                  dep.dest,
    1.32                  _readable_rev(alias.scmtype, dep.rev) if alias else dep.rev))
    1.33 +        elif scmhandler.is_locally_modified():
    1.34 +            ui.write("L %s %s %s\n" % (item.alias_name,
    1.35 +                item.dest, _readable_rev(item.scmtype, rev)))
    1.36          else:
    1.37              ui.note("  %s %s %s\n" % (item.alias_name, item.dest,
    1.38                  _readable_rev(item.scmtype, rev)))
    1.39 @@ -316,6 +322,8 @@
    1.40              continue
    1.41          
    1.42          scmhandler = _get_scm_handler(ui, repo, manifest, item.alias_name)
    1.43 +        if not force and scmhandler.is_locally_modified():
    1.44 +            raise util.Abort(_('dependency is locally modified: %s (use -f to override)') % item.alias_name)
    1.45          rev = scmhandler.get_revision()
    1.46          
    1.47          deplist.append(dependency(rev, item.alias_name, item.dest))
    1.48 @@ -635,6 +643,9 @@
    1.49                  return
    1.50              parts.pop()
    1.51      
    1.52 +    def is_locally_modified(self):
    1.53 +        return False
    1.54 +    
    1.55      def get_revision(self):
    1.56          return self.manifest[self.alias_name].rev
    1.57      
    1.58 @@ -701,6 +712,16 @@
    1.59          raise util.Abort(_('removed alias: %s') % self.alias_name)
    1.60  
    1.61  class scm_hg(scm_unknown):
    1.62 +    def is_locally_modified(self):
    1.63 +        dir = self.manifest.get_dir(self.alias_name)
    1.64 +        path = self._make_deppath(dir)
    1.65 +        
    1.66 +        current_repo = localrepo.localrepository(self.ui, path)
    1.67 +        for modlist in current_repo.status():
    1.68 +            if modlist:
    1.69 +                return True
    1.70 +        return False
    1.71 +    
    1.72      def get_revision(self):
    1.73          dir = self.manifest.get_dir(self.alias_name)
    1.74          path = self._make_deppath(dir)
    1.75 @@ -1100,7 +1121,11 @@
    1.76               ('d', 'dest', '', 'destination directory for the dependency')],
    1.77              'hg deps [-a ALIAS -r REV -d DEST] [NAME]'),
    1.78      
    1.79 -    'depupdate|depup|depsclone': (depupdate, [], '[NAME]'), 
    1.80 +    'depupdate|depup|depsclone':
    1.81 +        (depupdate, [
    1.82 +            ('f', 'force', None, 'update even if some dependency is locally modified'),
    1.83 +        ], '[NAME]'),
    1.84 +    
    1.85      'depstatus|depst': (depstatus, [], ''),
    1.86      
    1.87      'depcommit|depci':