1. Martin Vejnár
  2. hgdeps

Commits

Martin Vejnár  committed e1a699b

Allow depcommit only if there are no local modifications.

  • Participants
  • Parent commits e21d5e6
  • Branches default

Comments (0)

Files changed (1)

File deps.py

View file
  • Ignore whitespace
             ui.write('R %s (%s %s)\n' % (dep.alias, dep.dest,
                 _readable_rev(alias.scmtype, dep.rev) if alias else dep.rev))
 
-def depcommit(ui, repo, nocommit, **commitopts):
+def depcommit(ui, repo, nocommit, force, **commitopts):
     '''save dependency state
     
     Update the .hgdeps file to reflect the current state of dependecies.
     The command will not work, if the working copy has either
     none or more than one parents.
     '''
+    if not nocommit and not force:
+        status = repo.status()
+        for part in status:
+            if part:
+                raise util.Abort(_('there are local modifications (use -f to override)'))
+    
     manifest = _load_manifest(repo)
     deplist = []
     for item in manifest.itervalues():
             if not commitopts['message'] and not commitopts['logfile']:
                 commitopts['message'] = 'Updated dependency list for changeset %s' % rev[:12]
             mercurial.commands.commit(ui, repo, '.hgdeps', **commitopts)
+    else:
+        ui.note(_('no changes in the dependecy list\n'))
 
 def depalias(ui, repo, alias, location, type):
     '''bind an alias to a source location
     'depcommit|depci':
         (depcommit, [
             ('C', 'nocommit', None, 'don\'t commit changes immediately'),
+            ('f', 'force', None, 'commit even in the presence of local modifications')
             ] + mercurial.commands.commitopts + mercurial.commands.commitopts2,
         '[OPTION]...'),